@Test public void testWhenNamesAndCrnAreList() { RestCallDetails restCallDetails = new RestCallDetails(); RestRequestDetails request = new RestRequestDetails(); request.setBody(new Json(Map.of("names", List.of("names1", "names2"), "crns", List.of("crns1", "crns2"))).getValue()); RestResponseDetails response = new RestResponseDetails(); restCallDetails.setRestRequest(request); restCallDetails.setRestResponse(response); Map<String, Object> expected = new HashMap<>(); expected.put(CLUSTER_NAME, "names1,names2"); expected.put(CLUSTER_CRN, "crns1,crns2"); Map<String, String> actual = underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), CLUSTER_NAME, CLUSTER_CRN); 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; }