diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-03 16:24:57 -0400 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2020-09-03 17:12:29 -0400 |
commit | 7788a0b2ef5ca1dbdad19cc2f39245c4a91ec066 (patch) | |
tree | 6f02d3eca27d2237c9355e6ff86f9613caa0ab8e /a1-policy-management/src/test/java/org | |
parent | 25473e2b1596a01687940edfbad7533d99e1717a (diff) |
Fixing and Refactoring POM's
Adding missing xml tag and parent pom referencing
Issue-ID: CCSDK-2730
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I2fa6eb3aea80480452122a62b417a2e944732645
Diffstat (limited to 'a1-policy-management/src/test/java/org')
22 files changed, 575 insertions, 577 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java index 6ccf162c..ab318615 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java @@ -57,8 +57,7 @@ import org.springframework.util.StringUtils; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) class MockPolicyManagementService { @@ -170,7 +169,7 @@ class MockPolicyManagementService { await().until(() -> rics.size() == noOfRicsInConfigFile); } catch (Exception e) { logger.info("Loaded rics: {}, and no of rics in config file: {} never matched!", rics.size(), - StringUtils.countOccurrencesOf(json, "baseUrl")); + StringUtils.countOccurrencesOf(json, "baseUrl")); } } @@ -186,14 +185,14 @@ class MockPolicyManagementService { String json = getConfigJsonFromFile(); Policy policy = ImmutablePolicy.builder() // - .id("typelessPolicy") // - .json(json) // - .ownerServiceId("MockPolicyManagementService") // - .ric(ric) // - .type(unnamedPolicyType) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id("typelessPolicy") // + .json(json) // + .ownerServiceId("MockPolicyManagementService") // + .ric(ric) // + .type(unnamedPolicyType) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); this.policies.put(policy); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java index 685c5611..89adf68a 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java @@ -70,11 +70,11 @@ class A1ClientFactoryTest { private static ImmutableRicConfig ricConfig(String controllerName) { return ImmutableRicConfig.builder() // - .ricId(RIC_NAME) // - .baseUrl("baseUrl") // - .managedElementIds(new Vector<>()) // - .controllerName(controllerName) // - .build(); + .ricId(RIC_NAME) // + .baseUrl("baseUrl") // + .managedElementIds(new Vector<>()) // + .controllerName(controllerName) // + .build(); } @BeforeEach @@ -114,9 +114,9 @@ class A1ClientFactoryTest { doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any()); StepVerifier.create(factoryUnderTest.createA1Client(ric)) // - .expectSubscription() // - .expectError() // - .verify(); + .expectSubscription() // + .expectError() // + .verify(); assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Protocol negotiation failed for " + ric.id()); } @@ -156,11 +156,11 @@ class A1ClientFactoryTest { private void whenGetGetControllerConfigReturn() throws ServiceException { ControllerConfig controllerCfg = ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password("pass") // - .userName("user") // - .build(); + .name("name") // + .baseUrl("baseUrl") // + .password("pass") // + .userName("user") // + .build(); when(applicationConfigMock.getControllerConfig(any())).thenReturn(controllerCfg); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java index 855a917f..cec5c2c6 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java @@ -36,8 +36,7 @@ import reactor.core.publisher.Mono; public class A1ClientHelper { - private A1ClientHelper() { - } + private A1ClientHelper() {} protected static Mono<String> createOutputJsonResponse(String key, String value) { JSONObject paramsJson = new JSONObject(); @@ -49,23 +48,23 @@ public class A1ClientHelper { protected static Ric createRic(String url) { RicConfig cfg = ImmutableRicConfig.builder().ricId("ric") // - .baseUrl(url) // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("") // - .build(); + .baseUrl(url) // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("") // + .build(); return new Ric(cfg); } protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) { return ImmutablePolicy.builder() // - .id(policyId) // - .json(json) // - .ownerServiceId("service") // - .ric(createRic(nearRtRicUrl)) // - .type(createPolicyType(type)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(policyId) // + .json(json) // + .ownerServiceId("service") // + .ric(createRic(nearRtRicUrl)) // + .type(createPolicyType(type)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); } protected static PolicyType createPolicyType(String name) { diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java index 28343322..36bbda57 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java @@ -69,8 +69,8 @@ class AsyncRestClientTest { @Test void testGetNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -82,14 +82,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPutNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -101,7 +101,7 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test @@ -118,14 +118,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPostNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -137,14 +137,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPostWithAuthHeaderNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -156,6 +156,6 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java index d6d12ba1..6aacc914 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java @@ -67,11 +67,11 @@ class OscA1ClientTest { @BeforeEach void init() { RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId("name") // - .baseUrl("RicBaseUrl") // - .managedElementIds(new ArrayList<>()) // - .controllerName("") // - .build(); + .ricId("name") // + .baseUrl("RicBaseUrl") // + .managedElementIds(new ArrayList<>()) // + .controllerName("") // + .build(); asyncRestClientMock = mock(AsyncRestClient.class); clientUnderTest = new OscA1Client(ricConfig, asyncRestClientMock); } @@ -93,7 +93,7 @@ class OscA1ClientTest { Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString()); Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString()); when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp) - .thenReturn(policyIdsType2Resp); + .thenReturn(policyIdsType2Resp); List<String> returned = clientUnderTest.getPolicyIdentities().block(); @@ -113,7 +113,7 @@ class OscA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).get(POLICYTYPES_URL + POLICY_TYPE_1_ID); StepVerifier.create(returnedMono).expectNext(A1ClientHelper.getCreateSchema(policyType, POLICY_TYPE_1_ID)) - .expectComplete().verify(); + .expectComplete().verify(); } @Test @@ -144,9 +144,10 @@ class OscA1ClientTest { when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty()); clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)).block(); + .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) + .block(); verify(asyncRestClientMock).put(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID, - POLICY_JSON_VALID); + POLICY_JSON_VALID); } @Test @@ -154,7 +155,7 @@ class OscA1ClientTest { when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).delete(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID); StepVerifier.create(returnedMono).expectComplete().verify(); } @@ -165,7 +166,7 @@ class OscA1ClientTest { Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString()); Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString()); when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp) - .thenReturn(policyIdsType2Resp); + .thenReturn(policyIdsType2Resp); when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty()); Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java index b1323859..c2118c12 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java @@ -69,78 +69,78 @@ class SdncOnapA1ClientTest { void init() { asyncRestClientMock = mock(AsyncRestClient.class); ControllerConfig controllerCfg = ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password(CONTROLLER_PASSWORD) // - .userName(CONTROLLER_USERNAME) // - .build(); - - clientUnderTest = - new SdncOnapA1Client(A1ClientHelper.createRic(RIC_1_URL).getConfig(), controllerCfg, asyncRestClientMock); + .name("name") // + .baseUrl("baseUrl") // + .password(CONTROLLER_PASSWORD) // + .userName(CONTROLLER_USERNAME) // + .build(); + + clientUnderTest = new SdncOnapA1Client(A1ClientHelper.createRic(RIC_1_URL).getConfig(), controllerCfg, + asyncRestClientMock); } @Test void testGetPolicyTypeIdentities() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); whenAsyncPostThenReturn(policyTypeIdsResp); Mono<List<String>> returnedMono = clientUnderTest.getPolicyTypeIdentities(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectNext(policyTypeIds).expectComplete().verify(); } @Test void testGetPolicyIdentities() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .build(); String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID); Mono<String> policyIdsType1Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID); Mono<String> policyIdsType2Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(policyIdsType2Resp); Mono<List<String>> returnedMono = clientUnderTest.getPolicyIdentities(); StepVerifier.create(returnedMono).expectNext(Arrays.asList(POLICY_1_ID, POLICY_2_ID)).expectComplete().verify(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); } @Test void testGetValidPolicyType() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_VALID + ", \"statusSchema\": {} }"; @@ -149,16 +149,16 @@ class SdncOnapA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectNext(POLICY_TYPE_SCHEMA_VALID).expectComplete().verify(); } @Test void testGetInvalidPolicyType() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_INVALID + ", \"statusSchema\": {} }"; @@ -167,105 +167,105 @@ class SdncOnapA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectErrorMatches(throwable -> throwable instanceof JSONException).verify(); } @Test void testPutPolicy() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .policyInstance(POLICY_JSON_VALID) // - .properties(new ArrayList<String>()) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .policyInstance(POLICY_JSON_VALID) // + .properties(new ArrayList<String>()) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); whenAsyncPostThenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).postWithAuthHeader(PUT_POLICY_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectComplete().verify(); } @Test void testDeletePolicy() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); whenAsyncPostThenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectComplete().verify(); } @Test void testDeleteAllPolicies() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .build(); String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .build(); String inputJsonStringDeletePolicy1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .policyInstanceId(POLICY_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .policyInstanceId(POLICY_2_ID) // + .build(); String inputJsonStringDeletePolicy2 = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID); Mono<String> policyIdsType1Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID); Mono<String> policyIdsType2Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(Mono.empty()) - .thenReturn(policyIdsType2Resp).thenReturn(Mono.empty()); + .thenReturn(policyIdsType2Resp).thenReturn(Mono.empty()); Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies(); StepVerifier.create(returnedFlux).expectComplete().verify(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); } private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) { return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString())) - .thenReturn(response); + .thenReturn(response); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java index 1e9695c7..bbb2b8e9 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java @@ -78,11 +78,11 @@ class SdncOscA1ClientTest { private ControllerConfig controllerConfig() { return ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password(CONTROLLER_PASSWORD) // - .userName(CONTROLLER_USERNAME) // - .build(); + .name("name") // + .baseUrl("baseUrl") // + .password(CONTROLLER_PASSWORD) // + .userName(CONTROLLER_USERNAME) // + .build(); } @BeforeEach @@ -90,7 +90,7 @@ class SdncOscA1ClientTest { Ric ric = A1ClientHelper.createRic(RIC_1_URL); clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), controllerConfig(), - asyncRestClientMock); + asyncRestClientMock); } @Test @@ -111,8 +111,8 @@ class SdncOscA1ClientTest { @Test void getPolicyTypeIdentities_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); String response = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID)); whenAsyncPostThenReturn(Mono.just(response)); @@ -124,11 +124,11 @@ class SdncOscA1ClientTest { String expUrl = RIC_1_URL + "/a1-p/policytypes"; ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -141,8 +141,8 @@ class SdncOscA1ClientTest { @Test void getTypeSchema_OSC() throws IOException { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); String ricResponse = loadFile("test_osc_get_schema_response.json"); JsonElement elem = gson().fromJson(ricResponse, JsonElement.class); @@ -153,7 +153,7 @@ class SdncOscA1ClientTest { JsonElement respJson = gson().fromJson(response, JsonElement.class); assertEquals("policyTypeId", respJson.getAsJsonObject().get("title").getAsString(), - "title should be updated to contain policyType ID"); + "title should be updated to contain policyType ID"); } @Test @@ -178,19 +178,19 @@ class SdncOscA1ClientTest { assertEquals(2, returned.size()); ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(policiesUrl()) // - .build(); + .nearRtRicUrl(policiesUrl()) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test void getPolicyIdentities_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); String policytypeIdsResp = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID)); String policyIdsResp = createOkResponseWithBody(Arrays.asList(POLICY_1_ID, POLICY_2_ID)); @@ -201,11 +201,11 @@ class SdncOscA1ClientTest { assertEquals(2, returned.size()); ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") // - .build(); + .nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -213,15 +213,15 @@ class SdncOscA1ClientTest { whenPostReturnOkResponse(); String returned = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) - .block(); + .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) + .block(); assertEquals("OK", returned); final String expUrl = policiesUrl() + "/" + POLICY_1_ID; AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .body(POLICY_JSON_VALID) // - .build(); + .nearRtRicUrl(expUrl) // + .body(POLICY_JSON_VALID) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD); @@ -231,30 +231,30 @@ class SdncOscA1ClientTest { void putPolicyRejected() { final String policyJson = "{}"; AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() // - .body("NOK") // - .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR - .build(); + .body("NOK") // + .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR + .build(); String resp = SdncJsonHelper.createOutputJsonString(adapterOutput); whenAsyncPostThenReturn(Mono.just(resp)); Mono<String> returnedMono = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID)); + .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID)); StepVerifier.create(returnedMono) // - .expectSubscription() // - .expectErrorMatches(t -> t instanceof WebClientResponseException) // - .verify(); + .expectSubscription() // + .expectErrorMatches(t -> t instanceof WebClientResponseException) // + .verify(); final String expUrl = policiesUrl() + "/" + POLICY_1_ID; AdapterRequest expRequestParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .body(policyJson) // - .build(); + .nearRtRicUrl(expUrl) // + .body(policyJson) // + .build(); String expRequest = SdncJsonHelper.createInputJsonString(expRequestParams); verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expRequest, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test @@ -262,18 +262,18 @@ class SdncOscA1ClientTest { whenPostReturnOkResponse(); String returned = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) - .block(); + .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) + .block(); assertEquals("OK", returned); final String expUrl = policiesUrl() + "/" + POLICY_1_ID; AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -288,12 +288,12 @@ class SdncOscA1ClientTest { final String expUrl = policiesUrl() + "/" + POLICY_1_ID + "/status"; AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -314,8 +314,8 @@ class SdncOscA1ClientTest { @Test void getVersion_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); whenAsyncPostThenReturn(Mono.error(new Exception("Error"))).thenReturn(Mono.just(createOkResponseString(true))); @@ -349,9 +349,9 @@ class SdncOscA1ClientTest { private String createOkResponseWithBody(Object body) { AdapterOutput output = ImmutableAdapterOutput.builder() // - .body(gson().toJson(body)) // - .httpStatus(HttpStatus.OK.value()) // - .build(); + .body(gson().toJson(body)) // + .httpStatus(HttpStatus.OK.value()) // + .build(); return SdncJsonHelper.createOutputJsonString(output); } @@ -367,6 +367,6 @@ class SdncOscA1ClientTest { private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) { return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString())) - .thenReturn(response); + .thenReturn(response); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java index 834a2a2f..b4709767 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java @@ -102,7 +102,7 @@ class StdA1ClientTest { when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.just(POLICY_JSON)); Mono<String> policyMono = - clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE)); + clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE)); verify(asyncRestClientMock).put(policiesBaseUrl() + POLICY_1_ID, POLICY_JSON); StepVerifier.create(policyMono).expectNext(POLICY_JSON).expectComplete().verify(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java index d0417a0a..0a75fd30 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java @@ -57,17 +57,17 @@ class ApplicationConfigParserTest { topicUrl = result.dmaapConsumerTopicUrl(); assertEquals( - "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100", - topicUrl, "controller contents"); + "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100", + topicUrl, "controller contents"); Map<String, ControllerConfig> controllers = result.controllerConfigs(); assertEquals(1, controllers.size(), "size"); ImmutableControllerConfig expectedControllerConfig = ImmutableControllerConfig.builder() // - .baseUrl("http://localhost:8083/") // - .name("controller1") // - .userName("user") // - .password("password") // - .build(); // + .baseUrl("http://localhost:8083/") // + .name("controller1") // + .userName("user") // + .password("password") // + .build(); // assertEquals(expectedControllerConfig, controllers.get("controller1"), "controller contents"); } @@ -78,7 +78,7 @@ class ApplicationConfigParserTest { private static InputStream getCorrectJson() throws IOException { URL url = ApplicationConfigParser.class.getClassLoader() - .getResource("test_application_configuration_with_dmaap_config.json"); + .getResource("test_application_configuration_with_dmaap_config.json"); String string = Resources.toString(url, Charsets.UTF_8); return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); } @@ -92,12 +92,12 @@ class ApplicationConfigParserTest { json.add("fake_info_object", new Gson().toJsonTree(fake_info_object)); DataPublishing data = new Gson().fromJson(json.toString(), DataPublishing.class); final String expectedMessage = - "Invalid configuration. Number of streams must be one, config: " + data.toString(); + "Invalid configuration. Number of streams must be one, config: " + data.toString(); Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject)); assertEquals(expectedMessage, actualException.getMessage(), - "Wrong error message when the DMaaP config has several streams publishing"); + "Wrong error message when the DMaaP config has several streams publishing"); } class DataPublishing { @@ -107,7 +107,7 @@ class ApplicationConfigParserTest { @Override public String toString() { return String.format("[dmaap_publisher=%s, fake_info_object=%s]", dmaap_publisher.toString(), - fake_info_object.toString()); + fake_info_object.toString()); } } @@ -120,12 +120,12 @@ class ApplicationConfigParserTest { json.add("fake_info_object", new Gson().toJsonTree(fake_info_object)); DataSubscribing data = new Gson().fromJson(json.toString(), DataSubscribing.class); final String expectedMessage = - "Invalid configuration. Number of streams must be one, config: " + data.toString(); + "Invalid configuration. Number of streams must be one, config: " + data.toString(); Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject)); assertEquals(expectedMessage, actualException.getMessage(), - "Wrong error message when the DMaaP config has several streams subscribing"); + "Wrong error message when the DMaaP config has several streams subscribing"); } private class DataSubscribing { @@ -135,7 +135,7 @@ class ApplicationConfigParserTest { @Override public String toString() { return String.format("[dmaap_subscriber=%s, fake_info_object=%s]", dmaap_subscriber.toString(), - fake_info_object.toString()); + fake_info_object.toString()); } } @@ -152,8 +152,8 @@ class ApplicationConfigParserTest { } JsonObject getDmaapInfo(JsonObject jsonRootObject, String streamsPublishesOrSubscribes, - String dmaapPublisherOrSubscriber) throws Exception { + String dmaapPublisherOrSubscriber) throws Exception { return jsonRootObject.getAsJsonObject("config").getAsJsonObject(streamsPublishesOrSubscribes) - .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info"); + .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info"); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java index eb2c1477..cf4739c8 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java @@ -40,19 +40,19 @@ import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException class ApplicationConfigTest { private static final ImmutableRicConfig RIC_CONFIG_1 = ImmutableRicConfig.builder() // - .ricId("ric1") // - .baseUrl("ric1_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric1") // + .baseUrl("ric1_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); ConfigParserResult configParserResult(RicConfig... rics) { return ImmutableConfigParserResult.builder() // - .ricConfigs(Arrays.asList(rics)) // - .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") // - .dmaapProducerTopicUrl("dmaapProducerTopicUrl") // - .controllerConfigs(new HashMap<>()) // - .build(); + .ricConfigs(Arrays.asList(rics)) // + .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") // + .dmaapProducerTopicUrl("dmaapProducerTopicUrl") // + .controllerConfigs(new HashMap<>()) // + .build(); } @Test @@ -77,7 +77,7 @@ class ApplicationConfigTest { assertTrue(appConfigUnderTest.getRicConfigs().contains(RIC_CONFIG_1), "Ric not added to configurations."); assertEquals(RIC_CONFIG_1, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()), - "Not correct Ric retrieved from configurations."); + "Not correct Ric retrieved from configurations."); update = appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)).blockFirst(); assertNull(update, "Nothing should be updated"); @@ -92,17 +92,17 @@ class ApplicationConfigTest { appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)); ImmutableRicConfig changedRicConfig = ImmutableRicConfig.builder() // - .ricId("ric1") // - .baseUrl("changed_ric1_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric1") // + .baseUrl("changed_ric1_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); RicConfigUpdate update = appConfigUnderTest.setConfiguration(configParserResult(changedRicConfig)).blockFirst(); assertEquals(RicConfigUpdate.Type.CHANGED, update.getType()); assertEquals(changedRicConfig, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()), - "Changed Ric not retrieved from configurations."); + "Changed Ric not retrieved from configurations."); } @Test @@ -110,11 +110,11 @@ class ApplicationConfigTest { ApplicationConfig appConfigUnderTest = new ApplicationConfig(); ImmutableRicConfig ricConfig2 = ImmutableRicConfig.builder() // - .ricId("ric2") // - .baseUrl("ric2_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric2") // + .baseUrl("ric2_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1, ricConfig2)); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java index 043524b8..f8c15b6a 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java @@ -88,8 +88,7 @@ import reactor.util.annotation.Nullable; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) class ApplicationTest { @@ -120,8 +119,8 @@ class ApplicationTest { Services services; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // public static class MockApplicationConfig extends ApplicationConfig { @Override @@ -219,13 +218,13 @@ class ApplicationTest { // This tests also validation of trusted certs restClient(true) rsp = restClient(true).get(url).block(); assertThat(rsp).contains("ric2") // - .doesNotContain("ric1") // - .contains("AVAILABLE"); + .doesNotContain("ric1") // + .contains("AVAILABLE"); // All RICs rsp = restClient().get("/rics").block(); assertThat(rsp).contains("ric2") // - .contains("ric1"); + .contains("ric1"); // Non existing policy type url = "/rics?policyType=XXXX"; @@ -285,13 +284,13 @@ class ApplicationTest { } private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId, - boolean isTransient) { + boolean isTransient) { String url; if (policyTypeName.isEmpty()) { url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName; } else { url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type=" - + policyTypeName; + + policyTypeName; } if (isTransient) { url += "&transient=true"; @@ -373,7 +372,7 @@ class ApplicationTest { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null, - responseBodyBytes, StandardCharsets.UTF_8, null); + responseBodyBytes, StandardCharsets.UTF_8, null); doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any()); // PUT Policy @@ -461,7 +460,7 @@ class ApplicationTest { String url = "/policy_schemas"; String rsp = this.restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("[{\"title\":\"type2\"}"); + .contains("{\"title\":\"type2\"}"); List<String> info = parseSchemas(rsp); assertThat(info).hasSize(2); @@ -486,7 +485,7 @@ class ApplicationTest { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("type1") // - .contains("title"); + .contains("title"); // Get non existing schema url = "/policy_schema?id=type1XX"; @@ -537,15 +536,15 @@ class ApplicationTest { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policies?type=type1&service=service2"; rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).doesNotContain("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); // Test get policies for non existing type url = "/policies?type=type1XXX"; @@ -566,8 +565,8 @@ class ApplicationTest { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policy_ids?type=type1&service=service1&ric=ric1"; rsp = restClient().get(url).block(); @@ -623,7 +622,7 @@ class ApplicationTest { testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST); testErrorCode(restClient().put("/service", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST); testErrorCode(restClient().put("/service", createServiceJson(serviceName, 0, "missing.portandprotocol.com")), - HttpStatus.BAD_REQUEST); + HttpStatus.BAD_REQUEST); // GET non existing service testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND); @@ -663,14 +662,14 @@ class ApplicationTest { private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException { addRic(ric); Policy policy = ImmutablePolicy.builder() // - .id(id) // - .json(jsonString()) // - .ownerServiceId(service) // - .ric(rics.getRic(ric)) // - .type(addPolicyType(typeName, ric)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json(jsonString()) // + .ownerServiceId(service) // + .ric(rics.getRic(ric)) // + .type(addPolicyType(typeName, ric)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); policies.put(policy); return policy; } @@ -714,14 +713,14 @@ class ApplicationTest { private AsyncRestClient restClient(boolean useTrustValidation) { WebClientConfig config = this.applicationConfig.getWebClientConfig(); config = ImmutableWebClientConfig.builder() // - .keyStoreType(config.keyStoreType()) // - .keyStorePassword(config.keyStorePassword()) // - .keyStore(config.keyStore()) // - .keyPassword(config.keyPassword()) // - .isTrustStoreUsed(useTrustValidation) // - .trustStore(config.trustStore()) // - .trustStorePassword(config.trustStorePassword()) // - .build(); + .keyStoreType(config.keyStoreType()) // + .keyStorePassword(config.keyStorePassword()) // + .keyStore(config.keyStore()) // + .keyPassword(config.keyPassword()) // + .isTrustStoreUsed(useTrustValidation) // + .trustStore(config.trustStore()) // + .trustStorePassword(config.trustStorePassword()) // + .build(); return new AsyncRestClient(baseUrl(), config); } @@ -736,9 +735,9 @@ class ApplicationTest { private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) { StepVerifier.create(request) // - .expectSubscription() // - .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) // - .verify(); + .expectSubscription() // + .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) // + .verify(); } private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) { @@ -755,9 +754,9 @@ class ApplicationTest { private PolicyType createPolicyType(String policyTypeName) { return ImmutablePolicyType.builder() // - .id(policyTypeName) // - .schema("{\"title\":\"" + policyTypeName + "\"}") // - .build(); + .id(policyTypeName) // + .schema("{\"title\":\"" + policyTypeName + "\"}") // + .build(); } private PolicyType addPolicyType(String policyTypeName, String ricName) { @@ -780,11 +779,11 @@ class ApplicationTest { mes.add(managedElement); } RicConfig conf = ImmutableRicConfig.builder() // - .ricId(ricName) // - .baseUrl(ricName) // - .managedElementIds(mes) // - .controllerName("") // - .build(); + .ricId(ricName) // + .baseUrl(ricName) // + .managedElementIds(mes) // + .controllerName("") // + .build(); Ric ric = new Ric(conf); ric.setState(Ric.RicState.AVAILABLE); this.rics.put(ric); 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 243ded43..87589f22 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 @@ -87,8 +87,7 @@ import reactor.util.annotation.Nullable; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) class ApplicationTest { @@ -119,8 +118,8 @@ class ApplicationTest { Services services; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // public static class MockApplicationConfig extends ApplicationConfig { @Override @@ -218,13 +217,13 @@ class ApplicationTest { // This tests also validation of trusted certs restClient(true) rsp = restClient(true).get(url).block(); assertThat(rsp).contains("ric2") // - .doesNotContain("ric1") // - .contains("AVAILABLE"); + .doesNotContain("ric1") // + .contains("AVAILABLE"); // All RICs rsp = restClient().get("/rics").block(); assertThat(rsp).contains("ric2") // - .contains("ric1"); + .contains("ric1"); // Non existing policy type url = "/rics?policytype_id=XXXX"; @@ -293,13 +292,13 @@ class ApplicationTest { } private String putPolicyUrl(String serviceName, String ricId, String policyTypeName, String policyInstanceId, - boolean isTransient) { + boolean isTransient) { String url; if (policyTypeName.isEmpty()) { url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName; } else { url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName - + "&policytype_id=" + policyTypeName; + + "&policytype_id=" + policyTypeName; } if (isTransient) { url += "&transient=true"; @@ -381,7 +380,7 @@ class ApplicationTest { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null, - responseBodyBytes, StandardCharsets.UTF_8, null); + responseBodyBytes, StandardCharsets.UTF_8, null); doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any()); // PUT Policy @@ -472,7 +471,7 @@ class ApplicationTest { String url = "/policy-schemas"; String rsp = this.restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("[{\"title\":\"type2\"}"); + .contains("{\"title\":\"type2\"}"); PolicySchemaList info = parseSchemas(rsp); assertThat(info.schemas).hasSize(2); @@ -487,7 +486,7 @@ class ApplicationTest { url = "/policy-schemas?policytype_id=type1"; rsp = restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("title"); + .contains("title"); // Both type and ric specified url = "/policy-schemas?ric_id=ric1&policytype_id=type1"; @@ -562,15 +561,15 @@ class ApplicationTest { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policies?policytype_id=type1&service_id=service2"; rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).doesNotContain("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); // Test get policies for non existing type url = "/policies?policytype_id=type1XXX"; @@ -591,8 +590,8 @@ class ApplicationTest { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policy-ids?policytype_id=type1&service_id=service1&ric=ric1"; rsp = restClient().get(url).block(); @@ -648,9 +647,9 @@ class ApplicationTest { testErrorCode(restClient().put("/services", "crap"), HttpStatus.BAD_REQUEST, false); testErrorCode(restClient().put("/services", "{}"), HttpStatus.BAD_REQUEST, false); testErrorCode(restClient().put("/services", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST, - false); + false); testErrorCode(restClient().put("/services", createServiceJson(serviceName, 0, "missing.portandprotocol.com")), - HttpStatus.BAD_REQUEST, false); + HttpStatus.BAD_REQUEST, false); // GET non existing service testErrorCode(restClient().get("/services?service_id=XXX"), HttpStatus.NOT_FOUND); @@ -690,14 +689,14 @@ class ApplicationTest { private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException { addRic(ric); Policy policy = ImmutablePolicy.builder() // - .id(id) // - .json(jsonString()) // - .ownerServiceId(service) // - .ric(rics.getRic(ric)) // - .type(addPolicyType(typeName, ric)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json(jsonString()) // + .ownerServiceId(service) // + .ric(rics.getRic(ric)) // + .type(addPolicyType(typeName, ric)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); policies.put(policy); return policy; } @@ -751,7 +750,7 @@ class ApplicationTest { for (int i = 0; i < 10; ++i) { AsyncRestClient restClient = restClient(); ConcurrencyTestRunnable test = - new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes); + new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes); Thread thread = new Thread(test, "TestThread_" + i); thread.start(); threads.add(thread); @@ -770,14 +769,14 @@ class ApplicationTest { private AsyncRestClient restClient(boolean useTrustValidation) { WebClientConfig config = this.applicationConfig.getWebClientConfig(); config = ImmutableWebClientConfig.builder() // - .keyStoreType(config.keyStoreType()) // - .keyStorePassword(config.keyStorePassword()) // - .keyStore(config.keyStore()) // - .keyPassword(config.keyPassword()) // - .isTrustStoreUsed(useTrustValidation) // - .trustStore(config.trustStore()) // - .trustStorePassword(config.trustStorePassword()) // - .build(); + .keyStoreType(config.keyStoreType()) // + .keyStorePassword(config.keyStorePassword()) // + .keyStore(config.keyStore()) // + .keyPassword(config.keyPassword()) // + .isTrustStoreUsed(useTrustValidation) // + .trustStore(config.trustStore()) // + .trustStorePassword(config.trustStorePassword()) // + .build(); return new AsyncRestClient(baseUrl(), config); } @@ -799,12 +798,12 @@ class ApplicationTest { } private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains, - boolean expectApplicationProblemJsonMediaType) { + boolean expectApplicationProblemJsonMediaType) { StepVerifier.create(request) // - .expectSubscription() // - .expectErrorMatches( - t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) // - .verify(); + .expectSubscription() // + .expectErrorMatches( + t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) // + .verify(); } private void waitForRicState(String ricId, RicState state) throws ServiceException { @@ -813,7 +812,7 @@ class ApplicationTest { } private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains, - boolean expectApplicationProblemJsonMediaType) { + boolean expectApplicationProblemJsonMediaType) { assertTrue(throwable instanceof WebClientResponseException); WebClientResponseException responseException = (WebClientResponseException) throwable; assertThat(responseException.getStatusCode()).isEqualTo(expStatus); @@ -830,9 +829,9 @@ class ApplicationTest { private PolicyType createPolicyType(String policyTypeName) { return ImmutablePolicyType.builder() // - .id(policyTypeName) // - .schema("{\"title\":\"" + policyTypeName + "\"}") // - .build(); + .id(policyTypeName) // + .schema("{\"title\":\"" + policyTypeName + "\"}") // + .build(); } private PolicyType addPolicyType(String policyTypeName, String ricId) { @@ -855,11 +854,11 @@ class ApplicationTest { mes.add(managedElement); } RicConfig conf = ImmutableRicConfig.builder() // - .ricId(ricId) // - .baseUrl(ricId) // - .managedElementIds(mes) // - .controllerName("") // - .build(); + .ricId(ricId) // + .baseUrl(ricId) // + .managedElementIds(mes) // + .controllerName("") // + .build(); Ric ric = new Ric(conf); ric.setState(Ric.RicState.AVAILABLE); this.rics.put(ric); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java index 45eddf84..89a76e95 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java @@ -53,7 +53,7 @@ class ConcurrencyTestRunnable implements Runnable { private boolean failed = false; ConcurrencyTestRunnable(AsyncRestClient client, RicSupervision supervision, MockA1ClientFactory a1ClientFactory, - Rics rics, PolicyTypes types) { + Rics rics, PolicyTypes types) { this.count = nextCount.incrementAndGet(); this.supervision = supervision; this.a1ClientFactory = a1ClientFactory; @@ -108,14 +108,14 @@ class ConcurrencyTestRunnable implements Runnable { Ric ric = this.rics.get("ric"); PolicyType type = this.types.get("type1"); return ImmutablePolicy.builder() // - .id(id) // - .json("{}") // - .type(type) // - .ric(ric) // - .ownerServiceId("") // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json("{}") // + .type(type) // + .ric(ric) // + .ownerServiceId("") // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); } private void createInconsistency() { diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java index 2bd8c7f4..b6d3cc07 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java @@ -143,12 +143,12 @@ class DmaapMessageConsumerTest { when(messageRouterConsumerMock.getForEntity(any())).thenReturn(response); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN); + LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN); messageConsumerUnderTest.start().join(); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error"); + .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error"); verify(messageConsumerUnderTest).sleep(DmaapMessageConsumer.TIME_BETWEEN_DMAAP_RETRIES); } @@ -204,9 +204,9 @@ class DmaapMessageConsumerTest { doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler(); doReturn(Mono.just("OK")).when(messageHandlerMock).sendDmaapResponse(any(), any(), any()); Exception actualException = - assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); + assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); assertThat(actualException.getMessage()) - .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException"); + .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException"); verify(messageHandlerMock).sendDmaapResponse(any(), any(), any()); } @@ -216,9 +216,9 @@ class DmaapMessageConsumerTest { messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock)); doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler(); doReturn(Mono.error(new Exception("Sending response failed"))).when(messageHandlerMock).sendDmaapResponse(any(), - any(), any()); + any(), any()); Exception actualException = - assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); + assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); assertThat(actualException.getMessage()).contains("Sending response failed"); verify(messageHandlerMock).sendDmaapResponse(any(), any(), any()); @@ -239,16 +239,16 @@ class DmaapMessageConsumerTest { private DmaapRequestMessage dmaapRequestMessage(Operation operation) { return ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(operation) // - .originatorId("originatorId") // - .payload(new JsonObject()) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url("URL") // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(operation) // + .originatorId("originatorId") // + .payload(new JsonObject()) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url("URL") // + .build(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java index 3656ec1a..bab09931 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java @@ -80,19 +80,19 @@ class DmaapMessageHandlerTest { DmaapRequestMessage dmaapRequestMessage(Operation operation) { Optional<JsonObject> payload = - ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson()) - : Optional.empty()); + ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson()) + : Optional.empty()); return ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(operation) // - .originatorId("originatorId") // - .payload(payload) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url(URL) // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(operation) // + .originatorId("originatorId") // + .payload(payload) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url(URL) // + .build(); } private Mono<ResponseEntity<String>> okResponse() { @@ -113,10 +113,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.DELETE); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).deleteForEntity(URL); verifyNoMoreInteractions(pmsClient); @@ -133,10 +133,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.GET); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).getForEntity(URL); verifyNoMoreInteractions(pmsClient); @@ -149,21 +149,21 @@ class DmaapMessageHandlerTest { void exceptionFromPmsWhenGet_thenPostError() throws IOException { String errorBody = "Unavailable"; WebClientResponseException webClientResponseException = new WebClientResponseException( - HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null); + HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null); doReturn(Mono.error(webClientResponseException)).when(pmsClient).getForEntity(anyString()); doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString()); DmaapRequestMessage message = dmaapRequestMessage(Operation.GET); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .verifyComplete(); // ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(dmaapClient).post(anyString(), captor.capture()); String actualMessage = captor.getValue(); assertThat(actualMessage).contains(HttpStatus.SERVICE_UNAVAILABLE.toString()) // - .contains(errorBody); + .contains(errorBody); } @Test @@ -173,10 +173,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.PUT); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).putForEntity(URL, payloadAsString()); verifyNoMoreInteractions(pmsClient); @@ -192,10 +192,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.POST); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).postForEntity(URL, payloadAsString()); verifyNoMoreInteractions(pmsClient); @@ -220,7 +220,7 @@ class DmaapMessageHandlerTest { verify(dmaapClient).post(anyString(), captor.capture()); String actualMessage = captor.getValue(); assertThat(actualMessage).as("Message \"%s\" sent to DMaaP contains %s", actualMessage, HttpStatus.BAD_GATEWAY) - .contains(HttpStatus.BAD_GATEWAY.toString()); + .contains(HttpStatus.BAD_GATEWAY.toString()); verifyNoMoreInteractions(dmaapClient); } @@ -228,24 +228,24 @@ class DmaapMessageHandlerTest { @Test void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception { DmaapRequestMessage message = ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(DmaapRequestMessage.Operation.PUT) // - .originatorId("originatorId") // - .payload(Optional.empty()) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url(URL) // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(DmaapRequestMessage.Operation.PUT) // + .originatorId("originatorId") // + .payload(Optional.empty()) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url(URL) // + .build(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN); + LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN); testedObject.handleDmaapMsg(message); assertThat(logAppender.list.get(0).getFormattedMessage()) - .startsWith("Expected payload in message from DMAAP: "); + .startsWith("Expected payload in message from DMAAP: "); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java index 520e5c7a..a63f15f1 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java @@ -73,14 +73,14 @@ class LockTest { Lock lock = new Lock(); Mono<Lock> seq = lock.lock(LockType.EXCLUSIVE) // - .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) // - .flatMap(l -> lock.unlock()); + .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) // + .flatMap(l -> lock.unlock()); asynchUnlock(lock); StepVerifier.create(seq) // - .expectSubscription() // - .expectNext(lock) // - .verifyComplete(); + .expectSubscription() // + .expectNext(lock) // + .verifyComplete(); assertThat(lock.getLockCounter()).isZero(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java index e2bc8700..5a1dbea7 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java @@ -55,14 +55,14 @@ class EnvironmentProcessorTest { systemEnvironment.put(HOSTNAME, HOSTNAME_VALUE); EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(consulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(consulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); } @Test @@ -70,9 +70,9 @@ class EnvironmentProcessorTest { Properties systemEnvironment = new Properties(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException - && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined")) - .verify(); + .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException + && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined")) + .verify(); } @Test @@ -84,20 +84,20 @@ class EnvironmentProcessorTest { String defaultConsulPort = "8500"; EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(defaultConsulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(defaultConsulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN); + LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort); + .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort); } @Test @@ -106,9 +106,9 @@ class EnvironmentProcessorTest { systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException - && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined")) - .verify(); + .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException + && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined")) + .verify(); } @Test @@ -121,14 +121,14 @@ class EnvironmentProcessorTest { systemEnvironment.put("SERVICE_NAME", HOSTNAME_VALUE); EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(consulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(consulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); } @Test @@ -138,8 +138,9 @@ class EnvironmentProcessorTest { systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage() - .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")) - .verify(); + .expectErrorMatches( + throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage() + .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")) + .verify(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java index 572ba0b5..c62626c1 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java @@ -102,19 +102,19 @@ class RefreshConfigTaskTest { private static final String RIC_1_NAME = "ric1"; private static final RicConfig CORRECT_RIC_CONIFG = ImmutableRicConfig.builder() // - .ricId(RIC_1_NAME) // - .baseUrl("http://localhost:8080/") // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("") // - .build(); + .ricId(RIC_1_NAME) // + .baseUrl("http://localhost:8080/") // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("") // + .build(); private static EnvProperties properties() { return ImmutableEnvProperties.builder() // - .consulHost("host") // - .consulPort(123) // - .cbsName("cbsName") // - .appName("appName") // - .build(); + .consulHost("host") // + .consulPort(123) // + .cbsName("cbsName") // + .appName("appName") // + .build(); } private RefreshConfigTask createTestObject(boolean configFileExists) { @@ -122,9 +122,9 @@ class RefreshConfigTaskTest { } private RefreshConfigTask createTestObject(boolean configFileExists, Rics rics, Policies policies, - boolean stubConfigFileExists) { + boolean stubConfigFileExists) { RefreshConfigTask obj = spy(new RefreshConfigTask(appConfig, rics, policies, new Services(), new PolicyTypes(), - new A1ClientFactory(appConfig))); + new A1ClientFactory(appConfig))); if (stubConfigFileExists) { doReturn(configFileExists).when(obj).fileExists(any()); } @@ -163,12 +163,12 @@ class RefreshConfigTaskTest { doReturn("fileName").when(appConfig).getLocalConfigurationFilePath(); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNext(Type.ADDED) // - .expectNext(Type.ADDED) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNext(Type.ADDED) // + .expectNext(Type.ADDED) // + .thenCancel() // + .verify(); // Then verify(refreshTaskUnderTest).loadConfigurationFromFile(); @@ -194,11 +194,11 @@ class RefreshConfigTaskTest { final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(100)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(100)) // + .thenCancel() // + .verify(); // Then verify(refreshTaskUnderTest).loadConfigurationFromFile(); @@ -206,7 +206,7 @@ class RefreshConfigTaskTest { await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()) - .startsWith("Local configuration file not loaded: fileName, "); + .startsWith("Local configuration file not loaded: fileName, "); } @Test @@ -223,15 +223,15 @@ class RefreshConfigTaskTest { final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, WARN); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(1000)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(1000)) // + .thenCancel() // + .verify(); await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("Could not refresh application configuration. java.io.IOException"); + .isEqualTo("Could not refresh application configuration. java.io.IOException"); } @Test @@ -262,13 +262,13 @@ class RefreshConfigTaskTest { doNothing().when(refreshTaskUnderTest).runRicSynchronization(any(Ric.class)); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNext(Type.CHANGED) // - .expectNext(Type.ADDED) // - .expectNext(Type.REMOVED) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNext(Type.CHANGED) // + .expectNext(Type.ADDED) // + .expectNext(Type.REMOVED) // + .thenCancel() // + .verify(); assertThat(appConfig.getRicConfigs()).hasSize(2); assertThat(appConfig.getRic(RIC_1_NAME).baseUrl()).isEqualTo(newBaseUrl); @@ -301,61 +301,61 @@ class RefreshConfigTaskTest { final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(1000)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(1000)) // + .thenCancel() // + .verify(); await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith( - "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: "); + "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: "); } private RicConfig getRicConfig(String name) { RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId(name) // - .baseUrl("url") // - .managedElementIds(Collections.emptyList()) // - .controllerName("controllerName") // - .build(); + .ricId(name) // + .baseUrl("url") // + .managedElementIds(Collections.emptyList()) // + .controllerName("controllerName") // + .build(); return ricConfig; } private Policy getPolicy(Ric ric) { ImmutablePolicyType type = ImmutablePolicyType.builder() // - .id("type") // - .schema("{}") // - .build(); + .id("type") // + .schema("{}") // + .build(); Policy policy = ImmutablePolicy.builder() // - .id("id") // - .type(type) // - .lastModified(Instant.now()) // - .ric(ric) // - .json("{}") // - .ownerServiceId("ownerServiceId") // - .isTransient(false) // - .build(); + .id("id") // + .type(type) // + .lastModified(Instant.now()) // + .ric(ric) // + .json("{}") // + .ownerServiceId("ownerServiceId") // + .isTransient(false) // + .build(); return policy; } ConfigParserResult configParserResult(RicConfig... rics) { return ImmutableConfigParserResult.builder() // - .ricConfigs(Arrays.asList(rics)) // - .dmaapConsumerTopicUrl("") // - .dmaapProducerTopicUrl("") // - .controllerConfigs(new HashMap<>()) // - .build(); + .ricConfigs(Arrays.asList(rics)) // + .dmaapConsumerTopicUrl("") // + .dmaapProducerTopicUrl("") // + .controllerConfigs(new HashMap<>()) // + .build(); } private void modifyTheRicConfiguration(JsonObject configAsJson, String newBaseUrl) { ((JsonObject) configAsJson.getAsJsonObject("config") // - .getAsJsonArray("ric").get(0)) // - .addProperty("baseUrl", newBaseUrl); + .getAsJsonArray("ric").get(0)) // + .addProperty("baseUrl", newBaseUrl); } private JsonObject getJsonRootObject(InputStream inStream) - throws JsonIOException, JsonSyntaxException, IOException { + throws JsonIOException, JsonSyntaxException, IOException { JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject(); return rootObject; } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java index bb3b3461..25a7ddc4 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java @@ -60,37 +60,37 @@ import reactor.core.publisher.Mono; class RicSupervisionTest { private static final String POLICY_TYPE_1_NAME = "type1"; private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() // - .id(POLICY_TYPE_1_NAME) // - .schema("") // - .build(); + .id(POLICY_TYPE_1_NAME) // + .schema("") // + .build(); private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() // - .ricId("ric_1") // - .baseUrl("baseUrl1") // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("controllerName") // - .build()); + .ricId("ric_1") // + .baseUrl("baseUrl1") // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("controllerName") // + .build()); private static final String POLICY_1_ID = "policyId1"; private static final Policy POLICY_1 = ImmutablePolicy.builder() // - .id(POLICY_1_ID) // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(POLICY_1_ID) // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); private static final Policy POLICY_2 = ImmutablePolicy.builder() // - .id("policyId2") // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id("policyId2") // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); @Mock private A1Client a1ClientMock; @@ -285,9 +285,9 @@ class RicSupervisionTest { void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() { doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class)); PolicyType policyType2 = ImmutablePolicyType.builder() // - .id("policyType2") // - .schema("") // - .build(); + .id("policyType2") // + .schema("") // + .build(); RIC_1.setState(RicState.AVAILABLE); RIC_1.addSupportedPolicyType(POLICY_TYPE_1); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java index 93d252f7..e1c0c6b8 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java @@ -69,28 +69,28 @@ import reactor.core.publisher.Mono; class RicSynchronizationTaskTest { private static final String POLICY_TYPE_1_NAME = "type1"; private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() // - .id(POLICY_TYPE_1_NAME) // - .schema("") // - .build(); + .id(POLICY_TYPE_1_NAME) // + .schema("") // + .build(); private static final String RIC_1_NAME = "ric1"; private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() // - .ricId(RIC_1_NAME) // - .baseUrl("baseUrl1") // - .managedElementIds(Collections.emptyList()) // - .controllerName("controllerName") // - .build()); + .ricId(RIC_1_NAME) // + .baseUrl("baseUrl1") // + .managedElementIds(Collections.emptyList()) // + .controllerName("controllerName") // + .build()); private static Policy createPolicy(String policyId, boolean isTransient) { return ImmutablePolicy.builder() // - .id(policyId) // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(isTransient) // - .build(); + .id(policyId) // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(isTransient) // + .build(); } private static final Policy POLICY_1 = createPolicy("policyId1", false); @@ -127,7 +127,7 @@ class RicSynchronizationTaskTest { policies.put(POLICY_1); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -153,7 +153,7 @@ class RicSynchronizationTaskTest { simulateRicWithOnePolicyType(); RicSynchronizationTask synchronizerUnderTest = - spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); + spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest); when(restClientMock.put(anyString(), anyString())).thenReturn(Mono.just("Ok")); @@ -185,7 +185,7 @@ class RicSynchronizationTaskTest { when(a1ClientMock.getPolicyTypeSchema(POLICY_TYPE_1_NAME)).thenReturn(Mono.just(typeSchema)); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -214,7 +214,7 @@ class RicSynchronizationTaskTest { when(a1ClientMock.putPolicy(any(Policy.class))).thenReturn(Mono.just("OK")); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -237,11 +237,11 @@ class RicSynchronizationTaskTest { simulateRicWithNoPolicyTypes(); when(a1ClientMock.deleteAllPolicies()) // - .thenReturn(Flux.error(new Exception("Exception"))) // - .thenReturn(Flux.just("OK")); + .thenReturn(Flux.error(new Exception("Exception"))) // + .thenReturn(Flux.just("OK")); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -266,15 +266,15 @@ class RicSynchronizationTaskTest { when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(new Exception(originalErrorMessage))); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); + LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); synchronizerUnderTest.run(RIC_1); verifyCorrectLogMessage(0, logAppender, - "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage); + "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage); verify(a1ClientMock, times(2)).deleteAllPolicies(); verifyNoMoreInteractions(a1ClientMock); @@ -296,10 +296,10 @@ class RicSynchronizationTaskTest { simulateRicWithOnePolicyType(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); + LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); RicSynchronizationTask synchronizerUnderTest = - spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); + spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest); String originalErrorMessage = "Exception"; @@ -310,7 +310,7 @@ class RicSynchronizationTaskTest { ILoggingEvent loggingEvent = logAppender.list.get(0); assertThat(loggingEvent.getLevel()).isEqualTo(WARN); verifyCorrectLogMessage(0, logAppender, - "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage); + "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage); } private void setUpCreationOfA1Client() { @@ -333,7 +333,7 @@ class RicSynchronizationTaskTest { } private void verifyCorrectLogMessage(int messageIndex, ListAppender<ILoggingEvent> logAppender, - String expectedMessage) { + String expectedMessage) { ILoggingEvent loggingEvent = logAppender.list.get(messageIndex); assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedMessage); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java index 3e7bea64..1a8e9b3e 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java @@ -72,25 +72,25 @@ class ServiceSupervisionTest { private Service service; private Policies policies; private RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId(RIC_NAME) // - .baseUrl("baseUrl") // - .managedElementIds(Collections.emptyList()) // - .controllerName("") // - .build(); + .ricId(RIC_NAME) // + .baseUrl("baseUrl") // + .managedElementIds(Collections.emptyList()) // + .controllerName("") // + .build(); private Ric ric = new Ric(ricConfig); private PolicyType policyType = ImmutablePolicyType.builder() // - .id("policyTypeName") // - .schema("schema") // - .build(); + .id("policyTypeName") // + .schema("schema") // + .build(); private Policy policy = ImmutablePolicy.builder() // - .id(POLICY_ID) // - .json("json") // - .ownerServiceId(SERVICE_NAME) // - .ric(ric) // - .type(policyType) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(POLICY_ID) // + .json("json") // + .ownerServiceId(SERVICE_NAME) // + .ric(ric) // + .type(policyType) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); @Test void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() { @@ -100,7 +100,7 @@ class ServiceSupervisionTest { when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.just("Policy deleted")); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired); @@ -122,7 +122,7 @@ class ServiceSupervisionTest { when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.error(new Exception(originalErrorMessage))); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired); @@ -136,7 +136,7 @@ class ServiceSupervisionTest { ILoggingEvent loggingEvent = logAppender.list.get(0); assertThat(loggingEvent.getLevel()).isEqualTo(WARN); String expectedLogMessage = - "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage; + "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage; assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedLogMessage); } @@ -145,7 +145,7 @@ class ServiceSupervisionTest { setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2)); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); serviceSupervisionUnderTest.checkAllServices().blockLast(); @@ -161,7 +161,7 @@ class ServiceSupervisionTest { setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0)); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); serviceSupervisionUnderTest.checkAllServices().blockLast(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java index 14de691d..482fa395 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java @@ -101,7 +101,7 @@ public class MockA1Client implements A1Client { public Flux<String> deleteAllPolicies() { this.policies.clear(); return mono("OK") // - .flatMapMany(Flux::just); + .flatMapMany(Flux::just); } @Override @@ -120,7 +120,7 @@ public class MockA1Client implements A1Client { Mono<String> monoError(String responseBody, HttpStatus status) { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(status.value(), - status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null); + status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null); return Mono.error(a1Exception); } |