How to use checkNotInGlobalScope method of com.paypal.selion.configuration.LocalConfig class

Best SeLion code snippet using com.paypal.selion.configuration.LocalConfig.checkNotInGlobalScope

Source:LocalConfig.java Github

copy

Full Screen

...63 public LocalConfig(ConfigProperty configProperty, String value) {64 this();65 checkArgument(configProperty != null, "Config property cannot be null");66 checkArgument(value != null, "Config property value cannot be null");67 checkArgument(checkNotInGlobalScope(configProperty),68 String.format("The configuration property (%s) is not supported in local config.", configProperty)); // NOSONAR69 baseConfig.setProperty(configProperty.getName(), value);70 }71 /**72 * Constructs a new instance of this class from the specified initial values.73 * 74 * @param initialValues75 * Map The initial MAP of ConfigProperty values used to create the local configuration.76 */77 public LocalConfig(Map<ConfigProperty, String> initialValues) {78 this();79 if (initialValues != null && !initialValues.isEmpty()) {80 for (Map.Entry<ConfigProperty, String> entry : initialValues.entrySet()) {81 if (entry.getKey().isGlobalScopeOnly()) {82 String message = String.format("The configuration property (%s) is not supported in local config.",83 entry.getKey());84 throw new IllegalArgumentException(message);85 }86 baseConfig.setProperty(entry.getKey().getName(), entry.getValue());87 }88 }89 }90 /**91 * Get the configuration property value for configProperty.92 * 93 * @param configProperty94 * The configuration property value to get95 * 96 * @return The configuration property value or null if property does not exit.97 */98 public synchronized String getConfigProperty(Config.ConfigProperty configProperty) {99 SeLionLogger.getLogger().entering(configProperty);100 checkArgument(configProperty != null, "Config property cannot be null");101 // Search locally then query SeLionConfig if not found102 String propValue = null;103 if (baseConfig.containsKey(configProperty.getName())) {104 propValue = baseConfig.getString(configProperty.getName());105 }106 if (StringUtils.isBlank(propValue)) {107 propValue = Config.getConfigProperty(configProperty);108 }109 SeLionLogger.getLogger().exiting(propValue);110 return propValue;111 }112 public synchronized List<Object> getListConfigProperty(Config.ConfigProperty configProperty) {113 SeLionLogger.getLogger().entering(configProperty);114 checkArgument(configProperty != null, "Config property cannot be null");115 // Search locally then query SeLionConfig if not found116 List<Object> propValue = null;117 if (baseConfig.containsKey(configProperty.getName())) {118 propValue = baseConfig.getList(configProperty.getName());119 }120 if (propValue == null || propValue.isEmpty()) {121 propValue = Config.getListConfigProperty(configProperty);122 }123 SeLionLogger.getLogger().exiting(propValue);124 return propValue;125 }126 public synchronized int getIntConfigProperty(Config.ConfigProperty configProperty) {127 SeLionLogger.getLogger().entering(configProperty);128 checkArgument(configProperty != null, "Config property cannot be null");129 // start with the global value, then update from the local value, if it exists130 int propValue = Config.getIntConfigProperty(configProperty);131 if (baseConfig.containsKey(configProperty.getName())) {132 propValue = baseConfig.getInt(configProperty.getName());133 }134 SeLionLogger.getLogger().exiting(propValue);135 return propValue;136 }137 public synchronized boolean getBooleanConfigProperty(Config.ConfigProperty configProperty) {138 SeLionLogger.getLogger().entering(configProperty);139 checkArgument(configProperty != null, "Config property cannot be null");140 // start with the global value, then update from the local value, if it exists141 boolean propValue = Config.getBoolConfigProperty(configProperty);142 if (baseConfig.containsKey(configProperty.getName())) {143 propValue = baseConfig.getBoolean(configProperty.getName());144 }145 SeLionLogger.getLogger().exiting(propValue);146 return propValue;147 }148 /**149 * Sets the SeLion configuration property value.150 * 151 * @param configProperty152 * The configuration property to set.153 * @param configPropertyValue154 * The configuration property value to set.155 */156 public synchronized void setConfigProperty(Config.ConfigProperty configProperty, Object configPropertyValue) {157 checkArgument(configProperty != null, "Config property cannot be null");158 checkArgument(checkNotInGlobalScope(configProperty),159 String.format("The configuration property (%s) is not supported in local config.", configProperty)); // NOSONAR160 checkArgument(configPropertyValue != null, "Config property value cannot be null");161 baseConfig.setProperty(configProperty.getName(), configPropertyValue);162 }163 /**164 * Prints the configuration values associated with the LocalConfig. Used for logging/debug.165 * 166 * @param testName167 * The &lt;test&gt; to which this configuration pertains to.168 */169 public synchronized void printConfigValues(String testName) {170 if (baseConfig.isEmpty()) {171 return;172 }173 StringBuilder builder = new StringBuilder(String.format("Configuration for <%s>: {", testName));174 boolean isFirst = true;175 for (ConfigProperty configProperty : ConfigProperty.values()) {176 if (!isFirst) {177 builder.append(", ");178 }179 String value = getConfigProperty(configProperty);180 builder.append(String.format("(%s: %s)", configProperty, value));181 isFirst = false;182 }183 builder.append("}\n");184 SeLionLogger.getLogger().info(builder.toString());185 }186 /**187 * Returns only the local configuration values associated with the Local Config. Used for logging/reporting.188 * 189 * @return The local configuration property name/values as map.190 */191 public synchronized Map<String, String> getLocalConfigValues() {192 Map<String, String> result = new HashMap<String, String>();193 Iterator<String> iter = baseConfig.getKeys();194 while (iter.hasNext()) {195 String key = iter.next();196 result.put(key, baseConfig.getString(key));197 }198 return result;199 }200 /**201 * Answer if local configuration contains a value for specified property.202 * 203 * @return True if local configuration has value for configProperty.204 */205 public synchronized boolean isLocalValuePresent(ConfigProperty configProperty) {206 checkArgument(configProperty != null, "Config property cannot be null");207 String value = baseConfig.getString(configProperty.getName());208 return value != null;209 }210 private boolean checkNotInGlobalScope(ConfigProperty configProperty) {211 return !configProperty.isGlobalScopeOnly();212 }213}...

Full Screen

Full Screen

checkNotInGlobalScope

Using AI Code Generation

copy

Full Screen

1LocalConfig.checkNotInGlobalScope();2Config.checkNotInGlobalScope();3ConfigManager.checkNotInGlobalScope();4ConfigManagerImpl.checkNotInGlobalScope();5ConfigReader.checkNotInGlobalScope();6ConfigReaderImpl.checkNotInGlobalScope();7ConfigReaderMap.checkNotInGlobalScope();8ConfigReaderMapImpl.checkNotInGlobalScope();9ConfigReaderMapImpl.checkNotInGlobalScope();10ConfigReaderMapImpl.checkNotInGlobalScope();11ConfigReaderMapImpl.checkNotInGlobalScope();12ConfigReaderMapImpl.checkNotInGlobalScope();13ConfigReaderMapImpl.checkNotInGlobalScope();14ConfigReaderMapImpl.checkNotInGlobalScope();15ConfigReaderMapImpl.checkNotInGlobalScope();16ConfigReaderMapImpl.checkNotInGlobalScope();

Full Screen

Full Screen

checkNotInGlobalScope

Using AI Code Generation

copy

Full Screen

1LocalConfig lc = LocalConfig.getInstance();2Config config = Config.getConfig();3Config config = Config.getConfig();4Config config = Config.getConfig();5Config config = Config.getConfig();6Config config = Config.getConfig();7Config config = Config.getConfig();8Config config = Config.getConfig();9Config config = Config.getConfig();10Config config = Config.getConfig();11Config config = Config.getConfig();12Config config = Config.getConfig();

Full Screen

Full Screen

checkNotInGlobalScope

Using AI Code Generation

copy

Full Screen

1if (LocalConfig.getInstance().checkNotInGlobalScope()) {2 throw new RuntimeException("Test is running in global scope");3}4if (LocalConfig.getInstance().checkNotInGlobalScope("Test is running in global scope")) {5 throw new RuntimeException("Test is running in global scope");6}7if (LocalConfig.getInstance().checkNotInGlobalScope("Test is running in global scope", true)) {8 throw new RuntimeException("Test is running in global scope");9}10if (LocalConfig.getInstance().checkNotInGlobalScope("Test is running in global scope", true, true)) {11 throw new RuntimeException("Test is running in global scope");12}13if (LocalConfig.getInstance().checkNotInGlobalScope("Test is running in global scope", true, true, false)) {14 throw new RuntimeException("Test is running in global scope");15}16if (LocalConfig.getInstance().checkNotInGlobalScope("Test is running in global scope", true, true, true)) {17 throw new RuntimeException("Test is running in global scope");18}

Full Screen

Full Screen

checkNotInGlobalScope

Using AI Code Generation

copy

Full Screen

1 String config = System.getProperty("config");2 if (config == null) {3 config = "config.properties";4 }5 LocalConfig.checkNotInGlobalScope(config);6 Grid grid = Grid.getNewInstanceForConfig(config);7 grid.startGrid();8 grid.stopGrid();9 }10}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful