@Step("I run step (.*)") public String runAStep(String stepName) { return stepName; } }
public SimpleMethodInvoker(Step step, Object handlerInstance, Method method, Pattern stepPattern, String pendingMessage, StepRetry stepRetry, String handlerName, boolean isDeprecated) { super(pendingMessage, stepPattern, stepRetry, handlerName, isDeprecated); this.handlerInstance = handlerInstance; this.method = method; String stepId = step.id(); //If the user has set a custom id in the Step annotation, we can use that, otherwise use a UUID based identifier //which includes the class name and method as prefix to help with debugging this.id = Step.AUTO_GENERATE_ID.equals(stepId) ? handlerInstance.getClass().getSimpleName() + ":" + method.getName() + ":" + UUID.randomUUID() : stepId; }
public static StepRetry fromStepAnnotation(Step step) { long durationInMillis = TimeUnit.MILLISECONDS.convert(step.retryDuration(), step.retryTimeUnit()); return createStepRetry(durationInMillis, step.retryIntervalMillis()); }
@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(".*wait (?:for )?([0-9]*) milliseconds?.*") public void waitForMilliseconds(int millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { log.error("Thread interrupted while sleeping", e); } }
@Step("I call a step method exported by handler one") public String exportHandlerOne() { return "One"; } }
@Step("call a remote method") public String callARemoteMethod() { return "true"; } }
@Step("I can call an exported method on scoped") public String callAMethod() { return "OK"; } }
@Step(".*wait (?:for )?half a second.*") public void waitForHalfASecond() { try { Thread.sleep(500); } catch (InterruptedException e) { log.error("Thread interrupted while sleeping", e); } }
@Step("I can call an exported method on myNotScoped") public String callAMethod() { return "OK"; } }
@Step(".*I call a step passing the value (.*) and the (?:variable gets|variables get) expanded") public String expandStep(String value) { return value; } }
@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("I call a method which throws a NullPointerException") public void throwANullPointer() { throw new NullPointerException(); } }
@Step(".*accept a string with value '(.*)'") public void accept(String s) { System.out.println(s); } }
@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 connect to the " + HandlerPatterns.namePattern + " database") public void connectToDatabase(String configName) { Properties properties = getConfig(configName); sqlManager.connectToDatabase(configName, properties); }
@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); }