xt4k

Untitled

Apr 12th, 2021
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. @Step("Auto-test: API test that check expected child list items are present in any of child item (at any order) of actual response.")
  2. public Map<String, Object> checkInstructionItemInList(String apiMethodName, String childSectionName, Object postRequest,
  3. CsbResponse expectedResponse,Object objtype) throws JsonProcessingException {
  4. boolean foundChild = false;
  5. reportInfo("STARTED API AUTO-TEST.");
  6. String rootEl = apiMethodName + "Result";
  7. String expectedMessage = expectedResponse.getMessage( );
  8.  
  9. ТИП_ОБЬЕКТА expectedItem = (ТИП_ОБЬЕКТА) expectedResponse.getChild(0);
  10. request = new RequestFactory( );
  11. response = request.createPostRequest2(apiMethodName, postRequest);
  12. response.then( )
  13. .spec(responseSpec(apiMethodName))
  14. .assertThat( )
  15. .rootPath(rootEl)
  16. .body("Message", is(expectedMessage));
  17. JsonNode childs = response.as(JsonNode.class).path(rootEl).path(childSectionName);
  18. List<Instruction> actualChilds = mapper.readValue(childs.toString( ), new TypeReference<List<Instruction>>( ) {
  19. });
  20. for (Instruction actualItem : actualChilds)
  21. if (actualItem.getSeqNo( ) == (expectedItem.getSeqNo( )) && actualItem.getVesselId( ) == ((expectedItem.getVesselId( )))) {
  22. reportInfo(format("Item:`%s` values are equal: (%s %s)", expectedItem.getCode( ), expectedItem.getSeqNo( ), expectedItem.getVesselId( )));
  23. reportInfo("expected Item: " + expectedItem.toString( ));
  24. reportInfo("actual Item: " + actualItem.toString( ));
  25. assertThat(actualItem).usingRecursiveComparison( ).ignoringActualNullFields( ).isEqualTo(expectedItem);
  26. foundChild = true;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment