/** * Expects that the target element contains the given value as text. * The inner text and 'value' attribute of the element is checked. * * @param locator * is the selenium locator * @param value * is the expected value * @return true or false */ public static ExpectedCondition<Boolean> textToBeEqualsToExpectedValue(final By locator, final String value) { return new ExpectedCondition<Boolean>() { /** * {@inheritDoc} */ @Override public Boolean apply(@Nullable WebDriver driver) { try { WebElement element = driver.findElement(locator); if (element != null && value != null) { if (element.getAttribute(VALUE) == null || !value.equals(element.getAttribute(VALUE).trim())) { if (!value.equals(element.getText())) { return false; } } return true; } } catch (Exception e) { } return false; } }; }
/** * @param currentHandles * is list of opened windows. * @return a string with new Window Opens (GUID) */ public static ExpectedCondition<String> newWindowOpens(final Set<String> currentHandles) { return new ExpectedCondition<String>() { /** * {@inheritDoc} */ @Override public String apply(@Nullable WebDriver driver) { if (driver != null && !currentHandles.equals(driver.getWindowHandles())) { for (String s : driver.getWindowHandles()) { if (!currentHandles.contains(s)) { return s; } } } return null; } }; }
public Client( ClientType clientType, String networkAddress, String project, @Nullable String subscription, ScheduledExecutorService executorService, @Nullable Supplier<LoadtestGrpc.LoadtestStub> stubFactory) { this.clientType = clientType; this.networkAddress = networkAddress; this.clientStatus = ClientStatus.NONE; this.project = project; this.topic = TOPIC_PREFIX + getTopicSuffix(clientType); this.subscription = subscription; this.executorService = executorService; this.stubFactory = stubFactory; }
/** * @param object The arg object expected to contain {@link Parameter} annotations. * @param bundle The bundle to use for the descriptions. Can be null. * @param args The arguments to parse (optional). */ public JCommander(Object object, @Nullable ResourceBundle bundle, String... args) { this(); addObject(object); if (bundle != null) { setDescriptionsBundle(bundle); } createDescriptions(); if (args != null) { parse(args); } }
Client( ClientType clientType, String networkAddress, String project, @Nullable String subscription, ScheduledExecutorService executorService) { this(clientType, networkAddress, project, subscription, executorService, null); }
public XHMMEmissionProbabilityCalculator(final double deletionMean, final double duplicationMean, final double emissionStdDev, @Nullable final RandomGenerator rng) { this.deletionMean = ParamUtils.isNegativeOrZero(deletionMean, "Deletion coverage shift must be negative."); this.duplicationMean = ParamUtils.isPositiveOrZero(duplicationMean, "Duplication coverage shift must be positive"); emissionStandardDeviation = ParamUtils.isPositive(emissionStdDev, "Emission standard deviation must be positive"); this.rng = rng; }
public static void sarsaRunFourier( final double discount, final String name, final int order, final double learningRate, final double lambda, NormalizedVariableFeatures inputFeatures, final PrototypeScenario scenario, final Path containerPath, final Steppable additionalSteppable, final double initialEpsilon, @Nullable Pair<ShodanStateOil,Action> baseline, String... featureNames) throws IOException, NoSuchFieldException, IllegalAccessException { //write a YAML for the results HashMap<String,Object> resultObject = new HashMap<>(); resultObject.put("method","sarsa"); resultObject.put("lambda",lambda); resultObject.put("discount",discount); resultObject.put("learning_rate",learningRate); resultObject.put("factors",featureNames); resultObject.put("name",name); resultObject.put("base","fourier"); resultObject.put("order",order); resultObject.put("initial_epsilon", initialEpsilon); resultObject.put("normalized",true); resultObject.put("baseline", baseline != null); //run sarsa, return last fitness double fitness = runSarsa(new FourierBasis(inputFeatures, order), name, discount, learningRate, lambda, containerPath, scenario,baseline, resultObject, initialEpsilon); double bestFitness = fitness; if(resultObject.containsKey("fitness")) bestFitness = Math.max(bestFitness, (Double) resultObject.get("fitness")); resultObject.put("fitness",bestFitness); resultObject.put("episodes",NUMBER_OF_EPISODES); //to file File yamlFile = containerPath.resolve("results").resolve(name + ".yaml").toFile(); Yaml yaml = new Yaml(); yaml.dump(resultObject,new FileWriter(yamlFile)); }
public static void sarsaRunFourier( final double discount, final String name, final int order, final double learningRate, final double lambda, NormalizedVariableFeatures inputFeatures, final PrototypeScenario scenario, final Path containerPath, final Steppable additionalSteppable, @Nullable Pair<ShodanStateOil,Action> baseline, String... featureNames) throws IOException, NoSuchFieldException, IllegalAccessException { ShodanEnvironment environment = new ShodanEnvironment(scenario, additionalSteppable); //write a YAML for the results HashMap<String,Object> resultObject = new HashMap<>(); resultObject.put("method","sarsa"); resultObject.put("lambda",lambda); resultObject.put("discount",discount); resultObject.put("learning_rate",learningRate); resultObject.put("factors",featureNames); resultObject.put("name",name); resultObject.put("base","fourier"); resultObject.put("order",order); resultObject.put("normalized",true); //run sarsa, return last fitness double fitness = runSarsa(new FourierBasis(inputFeatures, order), name, discount, learningRate, lambda, containerPath, environment,baseline , resultObject); double bestFitness = fitness; if(resultObject.containsKey("fitness")) bestFitness = Math.max(bestFitness, (Double) resultObject.get("fitness")); resultObject.put("fitness",bestFitness); resultObject.put("episodes",NUMBER_OF_EPISODES); //to file File yamlFile = containerPath.resolve("results").resolve(name + ".yaml").toFile(); Yaml yaml = new Yaml(); yaml.dump(resultObject,new FileWriter(yamlFile)); }
/** * @param object The arg object expected to contain {@link Parameter} annotations. * @param bundle The bundle to use for the descriptions. Can be null. */ public JCommander(Object object, @Nullable ResourceBundle bundle) { addObject(object); setDescriptionsBundle(bundle); }
/** * @param object The arg object expected to contain {@link Parameter} annotations. * @param bundle The bundle to use for the descriptions. Can be null. */ public JCommander(Object object, @Nullable ResourceBundle bundle) { this(object, bundle, (String[]) null); }