@Test public void testWhenNameAndResourceCrnComeFromTheResponsesValue() { RestCallDetails restCallDetails = new RestCallDetails(); RestRequestDetails request = new RestRequestDetails(); RestResponseDetails response = new RestResponseDetails(); response.setBody(new Json(Map.of("responses", List.of( Map.of("name", "name1", "crn", "crn1"), Map.of("name", "name2", "crn", "crn2") ))).getValue()); restCallDetails.setRestRequest(request); restCallDetails.setRestResponse(response); Map<String, Object> expected = new HashMap<>(); expected.put("names", "name1,name2"); expected.put("crns", "crn1,crn2"); Map<String, String> actual = underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), "names", "crns"); assertEquals(expected, actual); }
public Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams, String nameField, String crnField) { Map<String, String> params = new HashMap<>(); RestRequestDetails restRequest = restCallDetails.getRestRequest(); Json requestJson = getJson(restRequest.getBody()); Json responseJson = getJson(restCallDetails.getRestResponse().getBody()); Map<String, String> copyRestParams = new HashMap<>(restParams); copyRestParams.putAll(collectFromCrnOrNameProvider(restCallDetails, operationDetails, restParams, nameField, crnField)); String resourceCrn = getCrn(requestJson, responseJson, operationDetails, copyRestParams, crnField); String name = getName(requestJson, responseJson, operationDetails, copyRestParams, nameField); checkNameOrCrnProvided(restRequest, resourceCrn, name); addNameAndCrnIfNotEmpty(nameField, crnField, params, resourceCrn, name); return params; }
CDPRestCommonService { public Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams, String nameField, String crnField) { Map<String, String> params = new HashMap<>(); RestRequestDetails restRequest = restCallDetails.getRestRequest(); Json requestJson = getJson(restRequest.getBody()); Json responseJson = getJson(restCallDetails.getRestResponse().getBody()); Map<String, String> copyRestParams = new HashMap<>(restParams); copyRestParams.putAll(collectFromCrnOrNameProvider(restCallDetails, operationDetails, restParams, nameField, crnField)); String resourceCrn = getCrn(requestJson, responseJson, operationDetails, copyRestParams, crnField); String name = getName(requestJson, responseJson, operationDetails, copyRestParams, nameField); checkNameOrCrnProvided(restRequest, resourceCrn, name); addNameAndCrnIfNotEmpty(nameField, crnField, params, resourceCrn, name); return params; } }
CDPRestCommonService { public Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams, String nameField, String crnField) { Map<String, String> params = new HashMap<>(); RestRequestDetails restRequest = restCallDetails.getRestRequest(); Json requestJson = getJson(restRequest.getBody()); Json responseJson = getJson(restCallDetails.getRestResponse().getBody()); Map<String, String> copyRestParams = new HashMap<>(restParams); copyRestParams.putAll(collectFromCrnOrNameProvider(restCallDetails, operationDetails, restParams, nameField, crnField)); String resourceCrn = getCrn(requestJson, responseJson, operationDetails, copyRestParams, crnField); String name = getName(requestJson, responseJson, operationDetails, copyRestParams, nameField); checkNameOrCrnProvided(restRequest, resourceCrn, name); addNameAndCrnIfNotEmpty(nameField, crnField, params, resourceCrn, name); return params; }  }
CDPRestCommonService { public Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams, String nameField, String crnField) { Map<String, String> params = new HashMap<>(); RestRequestDetails restRequest = restCallDetails.getRestRequest(); Json requestJson = getJson(restRequest.getBody()); Json responseJson = getJson(restCallDetails.getRestResponse().getBody()); Map<String, String> copyRestParams = new HashMap<>(restParams); copyRestParams.putAll(collectFromCrnOrNameProvider(restCallDetails, operationDetails, restParams, nameField, crnField)); String resourceCrn = getCrn(requestJson, responseJson, operationDetails, copyRestParams, crnField); String name = getName(requestJson, responseJson, operationDetails, copyRestParams, nameField); checkNameOrCrnProvided(restRequest, resourceCrn, name); addNameAndCrnIfNotEmpty(nameField, crnField, params, resourceCrn, name); return params; }  Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams,
            String nameField, String crnField); }
CDPRestCommonService { public Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams, String nameField, String crnField) { Map<String, String> params = new HashMap<>(); RestRequestDetails restRequest = restCallDetails.getRestRequest(); Json requestJson = getJson(restRequest.getBody()); Json responseJson = getJson(restCallDetails.getRestResponse().getBody()); Map<String, String> copyRestParams = new HashMap<>(restParams); copyRestParams.putAll(collectFromCrnOrNameProvider(restCallDetails, operationDetails, restParams, nameField, crnField)); String resourceCrn = getCrn(requestJson, responseJson, operationDetails, copyRestParams, crnField); String name = getName(requestJson, responseJson, operationDetails, copyRestParams, nameField); checkNameOrCrnProvided(restRequest, resourceCrn, name); addNameAndCrnIfNotEmpty(nameField, crnField, params, resourceCrn, name); return params; }  Map<String, String> collectCrnAndNameIfPresent(RestCallDetails restCallDetails, CDPOperationDetails operationDetails, Map<String, String> restParams,
            String nameField, String crnField); static final List<String> NAME_PATHS; static final List<String> NAMES_PATHS; static final List<String> RESOURCE_CRN_PATHS; static final List<String> CRNS_PATHS; }