|
25 | 25 | import com.chutneytesting.server.core.domain.execution.report.StepExecutionReportCoreBuilder;
|
26 | 26 | import com.fasterxml.jackson.core.JsonProcessingException;
|
27 | 27 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 28 | +import java.time.Instant; |
28 | 29 | import java.util.HashMap;
|
29 | 30 | import java.util.List;
|
30 | 31 | import java.util.Map;
|
|
33 | 34 | public class ScenarioExecutionTest {
|
34 | 35 |
|
35 | 36 | @Test
|
36 |
| - public void should_serialize_and_deserialize_input_and_output_in_report() throws JsonProcessingException { |
| 37 | + public void should_serialize_and_deserialize_simple_input_and_output_in_report() throws JsonProcessingException { |
| 38 | + // Given |
| 39 | + ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules(); |
| 40 | + Map<String, Object> mapStringObject = Map.of("TUTU", "TITI"); |
| 41 | + |
| 42 | + Step.StepContextSnapshot stepContextSnapshot = new Step.StepContextSnapshot(mapStringObject, mapStringObject, objectMapper); |
| 43 | + StepExecutionReportCore stepExecutionReport = new StepExecutionReportCoreBuilder() |
| 44 | + .setStepOutputs(new HashMap<>(stepContextSnapshot.getOutputsSnapshot())) |
| 45 | + .setEvaluatedInputs(new HashMap<>(stepContextSnapshot.getInputsSnapshot())) |
| 46 | + .createStepExecutionReport(); |
| 47 | + ScenarioExecutionReport scenarioExecutionReport = new ScenarioExecutionReport(1L, "", "", "", List.of(), stepExecutionReport); |
| 48 | + |
| 49 | + // When |
| 50 | + String serializedReport = objectMapper.writeValueAsString(scenarioExecutionReport); |
| 51 | + |
| 52 | + // Then |
| 53 | + assertThat(serializedReport).isEqualTo("{\"executionId\":1,\"scenarioName\":\"\",\"environment\":\"\",\"user\":\"\",\"tags\":[],\"constants\":{},\"datatable\":[],\"report\":{\"name\":null,\"duration\":0,\"startDate\":null,\"status\":null,\"information\":[],\"errors\":[],\"steps\":[],\"type\":null,\"targetName\":\"\",\"targetUrl\":\"\",\"strategy\":\"sequential\",\"evaluatedInputs\":{\"TUTU\":\"TITI\"},\"stepOutputs\":{\"TUTU\":\"TITI\"}},\"contextVariables\":{}}"); |
| 54 | + |
| 55 | + } |
| 56 | + @Test |
| 57 | + public void should_serialize_and_deserialize_complex_input_and_output_in_report() throws JsonProcessingException { |
37 | 58 | // Given
|
38 | 59 | ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
|
39 | 60 | Map<String, Object> mapStringObject = Map.of("TUTU", Map.of("TOTO", Map.of("BUBU",Map.of("VIVI","LALA"))));
|
40 | 61 |
|
41 | 62 | Step.StepContextSnapshot stepContextSnapshot = new Step.StepContextSnapshot(mapStringObject, mapStringObject, objectMapper);
|
42 |
| - StepExecutionReportCore stepExecutionReport = new StepExecutionReportCoreBuilder().setStepOutputs(new HashMap<>(stepContextSnapshot.getOutputsSnapshot())).createStepExecutionReport(); |
| 63 | + StepExecutionReportCore stepExecutionReport = new StepExecutionReportCoreBuilder() |
| 64 | + .setStepOutputs(new HashMap<>(stepContextSnapshot.getOutputsSnapshot())) |
| 65 | + .setEvaluatedInputs(new HashMap<>(stepContextSnapshot.getInputsSnapshot())) |
| 66 | + .createStepExecutionReport(); |
43 | 67 | ScenarioExecutionReport scenarioExecutionReport = new ScenarioExecutionReport(1L, "", "", "", List.of(), stepExecutionReport);
|
44 | 68 |
|
45 | 69 | // When
|
46 | 70 | String serializedReport = objectMapper.writeValueAsString(scenarioExecutionReport);
|
47 | 71 |
|
48 | 72 | // Then
|
49 |
| - assertThat(serializedReport).isEqualTo("{\"executionId\":1,\"scenarioName\":\"\",\"environment\":\"\",\"user\":\"\",\"tags\":[],\"constants\":{},\"datatable\":[],\"report\":{\"name\":null,\"duration\":0,\"startDate\":null,\"status\":null,\"information\":[],\"errors\":[],\"steps\":[],\"type\":null,\"targetName\":\"\",\"targetUrl\":\"\",\"strategy\":\"sequential\",\"evaluatedInputs\":{\"TUTU\":{\"TOTO\":{\"BUBU\":{\"VIVI\":\"LALA\"}}}}},\"stepOutputs\":{\"TUTU\":{\"TOTO\":{\"BUBU\":{\"VIVI\":\"LALA\"}}}}},\"contextVariables\":{}}"); |
| 73 | + assertThat(serializedReport).isEqualTo("{\"executionId\":1,\"scenarioName\":\"\",\"environment\":\"\",\"user\":\"\",\"tags\":[],\"constants\":{},\"datatable\":[],\"report\":{\"name\":null,\"duration\":0,\"startDate\":null,\"status\":null,\"information\":[],\"errors\":[],\"steps\":[],\"type\":null,\"targetName\":\"\",\"targetUrl\":\"\",\"strategy\":\"sequential\",\"evaluatedInputs\":{\"TUTU\":{\"TOTO\":{\"BUBU\":{\"VIVI\":\"LALA\"}}}},\"stepOutputs\":{\"TUTU\":{\"TOTO\":{\"BUBU\":{\"VIVI\":\"LALA\"}}}}},\"contextVariables\":{}}"); |
50 | 74 |
|
51 | 75 | }
|
52 | 76 | }
|
0 commit comments