@Step("I run step (.*)") public String runAStep(String stepName) { return stepName; } }
@Step("I can run a step with value (.*)") public String canRunAFeature(String value) { return value; } }
@Step(".*call an exported method") public String callMethod() { return "dumbledore"; } }
@Step("Processes start " + HandlerPatterns.nameListPattern) public void startProcessDirective(String processNameList) throws Exception { Map<String,String> processNames = HandlerPatterns.getNamesWithAliases(processNameList); for ( Map.Entry<String,String> e : processNames.entrySet()) { startNamedProcessFromConfig(e.getValue(), e.getKey()); } }
@Step(".*type of (?:the )?context variable (.*) is (.*)") public void checkType(String varName, String type) { Object actual = ChorusContext.getContext().get(varName); ChorusAssert.assertNotNull("no such variable exists: " + varName, actual); Class<?> clazz = actual.getClass(); ChorusAssert.assertTrue(varName + " should be of type " + type + " was " + clazz.getSimpleName(), clazz.getSimpleName().equals(type) || clazz.getName().equals(type) ); }
@Step(".*(?:the )?context variable (.*) is a (.*)") public void checkVariableType(String varName, String type) { Object o = ChorusContext.getContext().get(varName); ChorusAssert.assertNotNull("Check " + varName + " is not null"); ChorusAssert.assertTrue( "Check type is a " + type, o.getClass().getSimpleName().equalsIgnoreCase(type) || o.getClass().getName().equalsIgnoreCase(type) ); }
@Step("I increment a value with a timer task") public void incrementWithTimer() { Timer t = new Timer(); t.schedule(new TimerTask() { public void run() { timeCount++; } }, 300); }
@Step(".*start a (.*) process") public void startProcessFromConfig(String configName) throws Exception { //no user process name was supplied so use the config name, //or the config name with a count appended if this config has already been started during the scenario Properties config = getConfig(configName); String processName = nextProcessName(configName); processManager.startProcess(configName, processName, config); }
@Step(value = ".* call a step with a step retry and the step is polled until it passes", retryDuration = 1, retryIntervalMillis = 100) public int stepWhichFailsAtFirst() throws InterruptedException { tryCount ++; if ( tryCount < 10) { throw new ChorusException("Simulate Failure"); } return tryCount; }
@Step(".*disconnect the web socket publisher") public void disconnectAndReconnect() { scheduledExecutorService.schedule(() -> { try { stepPublisher.disconnect(); } catch (InterruptedException e) { e.printStackTrace(); } }, 200, TimeUnit.MILLISECONDS); } }
@Step("the abstract superclass timers handler is injected in a scenario scoped handler") public void abstractTimersHandlerIsSet() { ChorusAssert.assertNotNull(timersHandler); } }
@Step("the abstract superclass feature.dir resource is set correctly in a scenario scoped handler") public void abstractFeatureDirIsSet() { ChorusAssert.assertNotNull(featureDir); ChorusAssert.assertTrue("is dir", featureDir.isDirectory()); }
@Step("the feature.dir resource is set correctly in a scenario scoped handler") public void featureDirIsSet() { ChorusAssert.assertNotNull(featureDir); ChorusAssert.assertTrue("is dir", featureDir.isDirectory()); }
@Step("I set the context variable (.*) to (.*)") public void setAContextVariable(String variableName, Object value) { ChorusContext c = ChorusContext.getContext(); c.put(variableName, value); }
@Step("the size of map (.*) is (\\d+)") public void checkMapSize(String mapName, int size) { ChorusContext c = ChorusContext.getContext(); Map m = (Map)c.get(mapName); assertEquals("size should be " + size + " but is " + m.size(), m.size(), size); } }
@Step("the value is not (\\d) within 0.2 seconds so this step should fail") @PassesWithin(length = 200, timeUnit = TimeUnit.MILLISECONDS, pollFrequencyInMilliseconds = 50) public void passesWithinPointTwoSeconds(int expectCount) { assertEquals("Expect " + expectCount, expectCount, timeCount); }
@Step("the value is (\\d) for half a second") @PassesWithin(length = 500, timeUnit = TimeUnit.MILLISECONDS, pollFrequencyInMilliseconds = 50, pollMode = PollMode.PASS_THROUGHOUT_PERIOD) public void passesForHalfASecond(int expectCount) { passesForPollCount++; assertEquals("Expect " + expectCount, expectCount, timeCount); }
@Step("the feature.token resource is set correctly in a feature scoped handler") public void featureTokenIsSet() { ChorusAssert.assertNotNull(featureToken); ChorusAssert.assertEquals("Chorus Resource", featureToken.getName()); }
@Step("the abstract superclass feature.token resource is set correctly in a scenario scoped handler") public void abstractFeatureTokenIsSet() { ChorusAssert.assertNotNull(featureToken); ChorusAssert.assertEquals("Chorus Resource", featureToken.getName()); }
@Step("the abstract superclass feature.token resource is set correctly in a feature scoped handler") public void abstractFeatureTokenIsSet() { ChorusAssert.assertNotNull(featureToken); ChorusAssert.assertEquals("Chorus Resource", featureToken.getName()); }