aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2022-05-11 13:10:40 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2022-08-17 12:53:13 +0200
commit97ace6245fb8b7238d2f7f871797ba03df2d435f (patch)
tree94f6f437cd0e62b192a23eabc58d95fc71f5b82b /a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
parenta3e382b49db0cbdee32396cf9c7028d9f9b4a231 (diff)
NONRTRIC PMS, Cherry-pick the recent changes into Jakarta Release1.3.3
Sqasch of cherrypicked commits for the maintenance release. Issue-ID: CCSDK-3742 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS added support for custom A1 adapters Added support for added external A1-P adapter. This makes it possible to design and include adapter to APIs for accessing of A1 policies (in a NearRT-RIC) without any changes in this SW. Issue-ID: CCSDK-3655 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS added support for custom A1 adapters Updates of the json schema for configuration. Made it stricter and added the customAdapterClass prpoperty. Issue-ID: CCSDK-3655 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS removalof usage of immutable Issue-ID: CCSDK-3629 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Attempt to stablize the synch. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Attempt to stablize the synch. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Some further simplifications and added test. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: I1ec98017d63047a0036db5ea12f770db00b1152b NONRTRIC PMS, updated SDNC rest interface Update path and output-json for SDNC rest interface - A1 Kohn Issue-ID: CCSDK-3193 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Bugfix If the auth-token-file parameter in the file application.yaml is missing, it would not default to an empty file name. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, updated certs Updated certificate (which was expired). Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: I34ffc932d855ba3b94cfff23dcb56f30780dbecc
Diffstat (limited to 'a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java89
1 files changed, 34 insertions, 55 deletions
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 a5795ac9..6386441c 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
@@ -46,7 +46,8 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.SecurityContext;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -56,6 +57,8 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric.RicState;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Service;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
+import org.springframework.web.reactive.function.client.WebClientRequestException;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -105,10 +108,9 @@ class RicSynchronizationTaskTest {
@BeforeEach
void init() {
- ric1 = new Ric(ImmutableRicConfig.builder() //
+ ric1 = new Ric(RicConfig.builder() //
.ricId(RIC_1_NAME) //
.baseUrl("baseUrl1") //
- .managedElementIds(Collections.emptyList()) //
.controllerName("controllerName") //
.build());
policy1 = createPolicy("policyId1", false);
@@ -149,6 +151,35 @@ class RicSynchronizationTaskTest {
}
@Test
+ void ricIdleAndErrorDeletingPoliciesAllTheTime_thenSynchronizationWithFailedRecovery() {
+ setUpCreationOfA1Client();
+ simulateRicWithNoPolicyTypes();
+ policies.put(policy1);
+ WebClientResponseException exception = new WebClientResponseException(404, "", null, null, null);
+ when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(exception));
+ RicSynchronizationTask synchronizerUnderTest = createTask();
+ ric1.setState(RicState.AVAILABLE);
+ synchronizerUnderTest.run(ric1);
+ await().untilAsserted(() -> RicState.UNAVAILABLE.equals(ric1.getState()));
+ assertThat(policies.size()).isZero();
+ assertThat(ric1.getState()).isEqualTo(RicState.UNAVAILABLE);
+ }
+
+ @Test
+ void testConnectionError() {
+ setUpCreationOfA1Client();
+ simulateRicWithNoPolicyTypes();
+ policies.put(policy1);
+ WebClientRequestException exception =
+ new WebClientRequestException(new ServiceException("x"), null, null, null);
+ when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(exception));
+ RicSynchronizationTask synchronizerUnderTest = createTask();
+ ric1.setState(RicState.AVAILABLE);
+ synchronizerUnderTest.run(ric1);
+ await().untilAsserted(() -> RicState.UNAVAILABLE.equals(ric1.getState()));
+ }
+
+ @Test
void ricIdlePolicyTypeInRepo_thenSynchronizationWithReuseOfTypeFromRepoAndCorrectServiceNotified() {
rics.put(ric1);
ric1.setState(RicState.AVAILABLE);
@@ -234,58 +265,6 @@ class RicSynchronizationTaskTest {
assertThat(ric1.getState()).isEqualTo(RicState.AVAILABLE);
}
- @Test
- void ricIdleAndErrorDeletingPoliciesFirstTime_thenSynchronizationWithDeletionOfPolicies() {
- ric1.setState(RicState.AVAILABLE);
- rics.put(ric1);
-
- policies.put(policy1);
-
- setUpCreationOfA1Client();
- simulateRicWithNoPolicyTypes();
-
- when(a1ClientMock.deleteAllPolicies()) //
- .thenReturn(Flux.error(new Exception("Exception"))) //
- .thenReturn(Flux.just("OK"));
-
- RicSynchronizationTask synchronizerUnderTest = createTask();
-
- ric1.setState(RicState.UNAVAILABLE);
- synchronizerUnderTest.run(ric1);
- await().untilAsserted(() -> RicState.AVAILABLE.equals(ric1.getState()));
-
- verify(a1ClientMock, times(2)).deleteAllPolicies();
- verifyNoMoreInteractions(a1ClientMock);
-
- assertThat(policyTypes.size()).isZero();
- assertThat(policies.size()).isZero();
- assertThat(ric1.getState()).isEqualTo(RicState.AVAILABLE);
- }
-
- @Test
- void ricIdleAndErrorDeletingPoliciesAllTheTime_thenSynchronizationWithFailedRecovery() {
- setUpCreationOfA1Client();
- simulateRicWithNoPolicyTypes();
-
- policies.put(policy1);
-
- String originalErrorMessage = "Exception";
- when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(new Exception(originalErrorMessage)));
-
- RicSynchronizationTask synchronizerUnderTest = createTask();
-
- ric1.setState(RicState.AVAILABLE);
- synchronizerUnderTest.run(ric1);
- await().untilAsserted(() -> RicState.UNAVAILABLE.equals(ric1.getState()));
-
- verify(a1ClientMock, times(2)).deleteAllPolicies();
- verifyNoMoreInteractions(a1ClientMock);
-
- assertThat(policyTypes.size()).isZero();
- assertThat(policies.size()).isZero();
- assertThat(ric1.getState()).isEqualTo(RicState.UNAVAILABLE);
- }
-
private void setUpCreationOfA1Client() {
when(a1ClientFactoryMock.createA1Client(any(Ric.class))).thenReturn(Mono.just(a1ClientMock));
doReturn(Flux.empty()).when(a1ClientMock).deleteAllPolicies();