com.consol.citrus.actions.AbstractTestAction Java Examples

The following examples show how to use com.consol.citrus.actions.AbstractTestAction. 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: InjectEnvVarsHook.java    From yaks with Apache License 2.0 6 votes vote down vote up
@Before
public void injectEnvVars(Scenario scenario) {
    runner.run(new AbstractTestAction() {
        @Override
        public void doExecute(TestContext context) {
            if (scenario != null) {
                context.setVariable("SCENARIO_ID", scenario.getId());
                context.setVariable("SCENARIO_NAME", scenario.getName());
            }

            Optional<String> namespaceEnv = getEnvSetting(YAKS_NAMESPACE);
            Optional<String> domainEnv = getEnvSetting(CLUSTER_WILDCARD_DOMAIN);

            if (namespaceEnv.isPresent()) {
                context.setVariable(YAKS_NAMESPACE, namespaceEnv.get());

                if (!domainEnv.isPresent()) {
                    context.setVariable(CLUSTER_WILDCARD_DOMAIN, namespaceEnv.get() + DEFAULT_DOMAIN_SUFFIX);
                }
            }

            domainEnv.ifPresent(var -> context.setVariable(CLUSTER_WILDCARD_DOMAIN, var));
        }
    });
}
 
Example #2
Source File: AllureCitrusTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.FailedTests
@Test
void shouldSetFailedStatus() {
    final DefaultTestDesigner designer = new DefaultTestDesigner();
    designer.name("Simple test");
    designer.action(new AbstractTestAction() {
        @Override
        public void doExecute(final TestContext context) {
            assertThat(true).isFalse();
        }
    });

    final AllureResults results = run(designer);
    assertThat(results.getTestResults())
            .extracting(TestResult::getStatus)
            .containsExactly(Status.FAILED);
}
 
Example #3
Source File: AllureCitrusTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@AllureFeatures.Steps
@Test
void shouldAddAllureSteps() {
    final DefaultTestDesigner designer = new DefaultTestDesigner();
    designer.name("Simple test");
    designer.action(new AbstractTestAction() {
        @Override
        public void doExecute(final TestContext context) {
            Allure.step("a");
            Allure.step("b");
            Allure.step("c");
        }
    });

    final AllureResults results = run(designer);
    assertThat(results.getTestResults())
            .flatExtracting(TestResult::getSteps)
            .flatExtracting(StepResult::getSteps)
            .extracting(StepResult::getName)
            .containsExactly("a", "b", "c");
}
 
Example #4
Source File: TestFailureHook.java    From yaks with Apache License 2.0 5 votes vote down vote up
@After(order = Integer.MAX_VALUE)
public void checkTestFailure(Scenario scenario) {
    if (scenario.isFailed()) {
        runner.run(new AbstractTestAction() {
            @Override
            public void doExecute(TestContext context) {
                context.getExceptions().add(new CitrusRuntimeException(
                        String.format("Scenario %s:%s status %s", scenario.getId(), scenario.getLine(), scenario.getStatus().toString())));
            }
        });
    }
}
 
Example #5
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 #6
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);
        }
    };
}