Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jsmart.zerocode.core.engine.validators.ZeroCodeValidator;
import static org.jsmart.zerocode.core.kafka.helper.KafkaCommonUtils.printBrokerProperties;
import org.jsmart.zerocode.core.logbuilder.ZerocodeCorrelationshipLogger;
import org.jsmart.zerocode.core.utils.ApiType;
import org.jsmart.zerocode.core.utils.ApiTypeUtils;
import static org.jsmart.zerocode.core.utils.ApiTypeUtils.apiType;
import static org.jsmart.zerocode.core.utils.RunnerUtils.getFullyQualifiedUrl;
Expand Down Expand Up @@ -434,7 +435,8 @@ private String executeApi(String logPrefixRelationshipId,
String resolvedRequestJson,
ScenarioExecutionState scenarioExecutionState) {

String url = thisStep.getUrl();
// A step without a url is an echo step: no call, the request is the response
String url = ofNullable(thisStep.getUrl()).orElse("");
String operationName = thisStep.getOperation();
String stepId = thisStep.getId();
String thisStepName = displayNameOf(thisStep);
Expand Down Expand Up @@ -573,6 +575,15 @@ private int getParameterSize(Parameterized parameterized) {
private List<FieldAssertionMatcher> compareStepResults(Step thisStep, String actualResult, String expectedResult, String resolvedScenarioState) {
List<FieldAssertionMatcher> failureResults = new ArrayList<>();

// ------------------------------------------------
// Echo step (no call made) with nothing to compare
// ------------------------------------------------
if (apiType(thisStep.getUrl(), thisStep.getOperation()) == ApiType.NONE
&& thisStep.getAssertions() == null
&& thisStep.getValidators() == null) {
return failureResults;
}

// --------------------
// Validators (pyrest)
// --------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jsmart.zerocode.core.runner;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import org.jsmart.zerocode.core.runner.e2e.EchoStepShortForm;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class ZeroCodeMultiStepsScenarioRunner_EchoStepTest {

@Test
public void test_echoStepWithoutUrlOperationAndAssertionsPasses_javaCallWithoutAssertionsFails() {

Result result = JUnitCore.runClasses(EchoStepShortForm.class);

assertThat(result.getRunCount(), is(2));
assertThat(result.getFailureCount(), is(1));

Failure failure = result.getFailures().get(0);
assertThat(failure.getDescription().getMethodName(), is("testJavaCallWithoutAssertions"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jsmart.zerocode.core.runner.e2e;

import org.jsmart.zerocode.core.domain.HostProperties;
import org.jsmart.zerocode.core.domain.JsonTestCase;
import org.jsmart.zerocode.core.tests.customrunner.TestOnlyZeroCodeUnitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

@HostProperties(host="http://localhost", port=9998, context = "")
@RunWith(TestOnlyZeroCodeUnitRunner.class)
public class EchoStepShortForm {

@Test
@JsonTestCase("integration_test_files/echo_step/01_echo_step_short_form.json")
public void testEchoStepShortForm() throws Exception {

}

@Test
@JsonTestCase("integration_test_files/echo_step/02_java_call_without_assertions.json")
public void testJavaCallWithoutAssertions() throws Exception {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"scenarioName": "Echo step - url, operation and assertions omitted",
"steps": [
{
"name": "store_ids",
"request": {
"orderId": 1001,
"customer": "Jane"
}
},
{
"name": "echo_with_assertions",
"request": {
"orderId": "${$.store_ids.response.orderId}"
},
"assertions": {
"orderId": "1001"
}
},
{
"name": "echo_with_empty_values",
"url": "",
"operation": "",
"request": {
"customer": "${$.store_ids.response.customer}"
},
"assertions": {
"customer": "Jane"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"scenarioName": "Java call - assertions omitted",
"steps": [
{
"name": "java_call_without_assertions",
"url": "org.jsmart.zerocode.converter.MimeTypeConverter",
"operation": "jsonBlockToJson",
"request": {
"body": {
"id": 1001
}
}
}
]
}
Loading