com.consol.citrus.TestAction Java Examples

The following examples show how to use com.consol.citrus.TestAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivityService.java    From citrus-simulator with Apache License 2.0 6 votes vote down vote up
public void completeTestAction(TestCase testCase, TestAction testAction) {
    if (skipTestAction(testAction)) {
        return;
    }

    ScenarioExecution te = lookupScenarioExecution(testCase);
    Iterator<ScenarioAction> iterator = te.getScenarioActions().iterator();
    ScenarioAction lastScenarioAction = null;
    while (iterator.hasNext()) {
        lastScenarioAction = iterator.next();
    }

    if (lastScenarioAction == null) {
        throw new CitrusRuntimeException(String.format("No test action found with name %s", testAction.getName()));
    }
    if (!lastScenarioAction.getName().equals(testAction.getName())) {
        throw new CitrusRuntimeException(String.format("Expected to find last test action with name %s but got %s", testAction.getName(), lastScenarioAction.getName()));
    }

    lastScenarioAction.setEndDate(getTimeNow());
}
 
Example #2
Source File: SoapScenarioRunnerActionBuilder.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
/**
 * Default scenario send response operation.
 * @return
 */
public TestAction send(SoapBuilderSupport<SoapServerResponseActionBuilder> configurer) {
    SoapScenarioActionBuilder builder = new SoapScenarioActionBuilder(scenarioEndpoint)
            .withApplicationContext(applicationContext);
    configurer.configure(builder.send());
    return runner.run(builder.build()).getDelegate();
}
 
Example #3
Source File: ValidateIban.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
private TestAction validateIban() {
    return new AbstractTestAction() {
        @Override
        public void doExecute(TestContext context) {
            final String queryParams = context.getVariable(QUERY_PARAMS.name(), String.class);
            final String iban = queryParameterService.getIban(queryParams);
            final String jsonResponse = bankService.validate(iban).asJson();
            context.setVariable(JSON_RESPONSE.name(), jsonResponse);
        }
    };
}
 
Example #4
Source File: CalculateIban.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
private TestAction calculateIban() {
    return new AbstractTestAction() {
        @Override
        public void doExecute(TestContext context) {
            final String queryParams = context.getVariable(QUERY_PARAMS.name(), String.class);
            final String sortCode = queryParameterService.getSortCode(queryParams);
            final String bankAccountNumber = queryParameterService.getBankAccountNumber(queryParams);
            final String jsonResponse = bankService.calculate(sortCode, bankAccountNumber).asJson();
            context.setVariable(JSON_RESPONSE.name(), jsonResponse);
        }
    };
}
 
Example #5
Source File: ActivityService.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
public void createTestAction(TestCase testCase, TestAction testAction) {
    if (skipTestAction(testAction)) {
        return;
    }

    ScenarioExecution te = lookupScenarioExecution(testCase);
    ScenarioAction ta = new ScenarioAction();
    ta.setName(testAction.getName());
    ta.setStartDate(getTimeNow());
    te.addScenarioAction(ta);
}
 
Example #6
Source File: HttpScenarioRunnerActionBuilder.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
/**
 * Default scenario send response operation.
 * @return
 */
public TestAction send(HttpBuilderSupport<HttpServerActionBuilder.HttpServerSendActionBuilder> configurer) {
    HttpScenarioActionBuilder builder = new HttpScenarioActionBuilder(scenarioEndpoint)
            .withApplicationContext(applicationContext);
    configurer.configure(builder.send());
    return runner.run(builder.build()).getDelegate();
}
 
Example #7
Source File: HttpScenarioRunnerActionBuilder.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
/**
 * Default scenario receive operation.
 * @return
 */
public TestAction receive(HttpBuilderSupport<HttpServerActionBuilder.HttpServerReceiveActionBuilder> configurer) {
    HttpScenarioActionBuilder builder = new HttpScenarioActionBuilder(scenarioEndpoint)
            .withApplicationContext(applicationContext);
    configurer.configure(builder.receive());
    return runner.run(builder.build()).getDelegate();
}
 
Example #8
Source File: SoapScenarioRunnerActionBuilder.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
/**
 * Default scenario send fault operation.
 * @return
 */
public TestAction sendFault(SoapBuilderSupport<SoapServerFaultResponseActionBuilder> configurer) {
    SoapScenarioActionBuilder builder = new SoapScenarioActionBuilder(scenarioEndpoint)
            .withApplicationContext(applicationContext);
    configurer.configure(builder.sendFault());
    return runner.run(builder.build()).getDelegate();
}
 
Example #9
Source File: SoapScenarioRunnerActionBuilder.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
/**
 * Default scenario receive operation.
 * @return
 */
public TestAction receive(SoapBuilderSupport<SoapServerRequestActionBuilder> configurer) {
    SoapScenarioActionBuilder builder = new SoapScenarioActionBuilder(scenarioEndpoint)
            .withApplicationContext(applicationContext);
    configurer.configure(builder.receive());
    return runner.run(builder.build()).getDelegate();
}
 
Example #10
Source File: SimulatorStatusListener.java    From citrus-simulator with Apache License 2.0 5 votes vote down vote up
@Override
public void onTestActionStart(TestCase testCase, TestAction testAction) {
    if (!ignoreTestAction(testAction)) {
        LOG.debug(testCase.getName() + "(" +
                StringUtils.arrayToCommaDelimitedString(getParameters(testCase)) + ") - " +
                testAction.getName() + ": " +
                (StringUtils.hasText(testAction.getDescription()) ? testAction.getDescription() : ""));
        executionService.createTestAction(testCase, testAction);
    }
}
 
Example #11
Source File: ActionConverter.java    From citrus-admin with Apache License 2.0 5 votes vote down vote up
@Override
public Object convertModel(TestAction model) {
    ActionModel action = new ObjectFactory().createActionModel();

    action.setReference(model.getName());
    action.setDescription(model.getDescription());

    return action;
}
 
Example #12
Source File: SimulatorStatusListener.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestActionSkipped(TestCase testCase, TestAction testAction) {
}
 
Example #13
Source File: AllureCitrus.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestActionStart(final TestCase testCase, final TestAction testAction) {
    final String parentUuid = getUuid(testCase);
    final String uuid = UUID.randomUUID().toString();
    getLifecycle().startStep(parentUuid, uuid, new StepResult().setName(testAction.getName()));
}
 
Example #14
Source File: SimulatorStatusListener.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
private boolean ignoreTestAction(TestAction testAction) {
    return testAction.getClass().equals(SleepAction.class);
}
 
Example #15
Source File: CorrelationHandlerBuilder.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
public TestAction stop() {
    return stopCorrelationAction;
}
 
Example #16
Source File: SimulatorStatusListener.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestActionFinish(TestCase testCase, TestAction testAction) {
    if (!ignoreTestAction(testAction)) {
        executionService.completeTestAction(testCase, testAction);
    }
}
 
Example #17
Source File: ActionConverter.java    From citrus-admin with Apache License 2.0 4 votes vote down vote up
@Override
public Class<com.consol.citrus.TestAction> getActionModelClass() {
    return com.consol.citrus.TestAction.class;
}
 
Example #18
Source File: ActivityService.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
private boolean skipTestAction(TestAction testAction) {
    List<String> ignoreList = Arrays.asList("create-variables");
    return ignoreList.contains(testAction.getName());
}
 
Example #19
Source File: AllureCitrus.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestActionSkipped(final TestCase testCase, final TestAction testAction) {
    //do nothing
}
 
Example #20
Source File: AllureCitrus.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onTestActionFinish(final TestCase testCase, final TestAction testAction) {
    getLifecycle().stopStep();
}