diff options
author | raviteja.karumuri <raviteja.karumuri@est.tech> | 2023-09-14 12:38:49 +0100 |
---|---|---|
committer | raviteja.karumuri <raviteja.karumuri@est.tech> | 2023-10-16 10:39:20 +0100 |
commit | 9dcf49ce143dc318442568dd3bb1250e453b437a (patch) | |
tree | 2a9b3dc8a155e9244d788cea7bc4eb21a25aeab3 /a1-policy-management/src/test/java/org | |
parent | 7ff7a43d664bbba016aab7c571846faec8088865 (diff) |
Adding Schema reference in the API definition instead of declaring Object Type
Issue-ID: CCSDK-3937
Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech>
Change-Id: Ic301c785a39a0f6d0e5057e67dc592eda01a3d0b
Diffstat (limited to 'a1-policy-management/src/test/java/org')
-rw-r--r-- | a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java index 9afa42f6..2ff44169 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java @@ -22,8 +22,7 @@ package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; @@ -65,7 +64,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.P import org.onap.ccsdk.oran.a1policymanagementservice.controllers.authorization.PolicyAuthorizationRequest.Input.AccessType; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.RicInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.PolicyTypeDefinition; import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.PolicyTypeIdList; import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.PolicyInfo; import org.onap.ccsdk.oran.a1policymanagementservice.models.v2.PolicyInfoList; @@ -745,8 +743,8 @@ class ApplicationTest { { String response = restClient().get(url).block(); PolicyInfo policyInfo = objectMapper.readValue(response, PolicyInfo.class); - String policyData = gson.toJson(policyInfo.getPolicyData()); - assertThat(policyData).isEqualTo(policy.getJson()); + String expectedResponse = "{\"ric_id\":\"ric1\",\"service_id\":\"service1\",\"policy_id\":\"id\",\"policy_data\":{\"servingCellNrcgi\":\"1\"},\"status_notification_uri\":\"/policy-status?id=XXX\",\"policytype_id\":\"typeName\",\"transient\":false}"; + assertEquals(objectMapper.readTree(expectedResponse), objectMapper.readTree(response)); } { policies.remove(policy); @@ -1030,7 +1028,7 @@ class ApplicationTest { @Test @DisplayName("test Get Service Status") - void testGetServiceStatus() throws Exception { + void testGetServiceStatus() { String url = "/status"; String rsp = restClient().get(url).block(); assertThat(rsp).contains("success"); @@ -1071,19 +1069,23 @@ class ApplicationTest { } private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException { - addRic(ric); - Policy policy = Policy.builder() - .id(id) - .json(gson.toJson(jsonString())) - .ownerServiceId(service) - .ric(rics.getRic(ric)) - .type(addPolicyType(typeName, ric)) - .lastModified(Instant.now()) - .isTransient(false) - .statusNotificationUri("/policy-status?id=XXX") - .build(); - policies.put(policy); - return policy; + try { + addRic(ric); + Policy policy = Policy.builder() + .id(id) + .json(objectMapper.writeValueAsString(jsonString())) + .ownerServiceId(service) + .ric(rics.getRic(ric)) + .type(addPolicyType(typeName, ric)) + .lastModified(Instant.now()) + .isTransient(false) + .statusNotificationUri("/policy-status?id=XXX") + .build(); + policies.put(policy); + return policy; + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } } private Policy addPolicy(String id, String typeName, String service) throws ServiceException { @@ -1112,6 +1114,7 @@ class ApplicationTest { String body = createServiceJson(name, keepAliveIntervalSeconds); ResponseEntity<String> resp = restClient().putForEntity(url, body).block(); if (expectedStatus != null) { + assertNotNull(resp); assertEquals(expectedStatus, resp.getStatusCode(), ""); } } @@ -1232,7 +1235,7 @@ class ApplicationTest { return true; } - private MockA1Client getA1Client(String ricId) throws ServiceException { + private MockA1Client getA1Client(String ricId) { return a1ClientFactory.getOrCreateA1Client(ricId); } |