Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Step("Auto-test: API test that check expected child list items are present in any of child item (at any order) of actual response.")
- public Map<String, Object> checkInstructionItemInList(String apiMethodName, String childSectionName, Object postRequest,
- CsbResponse expectedResponse,Object objtype) throws JsonProcessingException {
- boolean foundChild = false;
- reportInfo("STARTED API AUTO-TEST.");
- String rootEl = apiMethodName + "Result";
- String expectedMessage = expectedResponse.getMessage( );
- ТИП_ОБЬЕКТА expectedItem = (ТИП_ОБЬЕКТА) expectedResponse.getChild(0);
- request = new RequestFactory( );
- response = request.createPostRequest2(apiMethodName, postRequest);
- response.then( )
- .spec(responseSpec(apiMethodName))
- .assertThat( )
- .rootPath(rootEl)
- .body("Message", is(expectedMessage));
- JsonNode childs = response.as(JsonNode.class).path(rootEl).path(childSectionName);
- List<Instruction> actualChilds = mapper.readValue(childs.toString( ), new TypeReference<List<Instruction>>( ) {
- });
- for (Instruction actualItem : actualChilds)
- if (actualItem.getSeqNo( ) == (expectedItem.getSeqNo( )) && actualItem.getVesselId( ) == ((expectedItem.getVesselId( )))) {
- reportInfo(format("Item:`%s` values are equal: (%s %s)", expectedItem.getCode( ), expectedItem.getSeqNo( ), expectedItem.getVesselId( )));
- reportInfo("expected Item: " + expectedItem.toString( ));
- reportInfo("actual Item: " + actualItem.toString( ));
- assertThat(actualItem).usingRecursiveComparison( ).ignoringActualNullFields( ).isEqualTo(expectedItem);
- foundChild = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment