+ @Test
+ public void startup_unableToConnectToGetTypes() {
+ Mono<?> error = Mono.error(new Exception("Unable to contact ric."));
+ doReturn(error, error).when(a1ClientMock).getPolicyTypeIdentities();
+
+ Rics rics = new Rics();
+ PolicyTypes policyTypes = new PolicyTypes();
+ StartupService serviceUnderTest = new StartupService(appConfigMock, refreshTaskMock, rics, policyTypes,
+ a1ClientFactory, new Policies(), new Services());
+
+ serviceUnderTest.startup();
+ serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, FIRST_RIC_URL, MANAGED_NODE_A),
+ ApplicationConfig.RicConfigUpdate.ADDED);
+
+ assertEquals(RicState.UNDEFINED, rics.get(FIRST_RIC_NAME).state(), "Not correct state for " + FIRST_RIC_NAME);
+ }
+
+ @Test
+ public void startup_unableToConnectToDeleteAllPolicies() {
+
+ Mono<List<String>> policyTypes = Mono.just(Arrays.asList(POLICY_TYPE_1_NAME));
+ when(a1ClientMock.getPolicyTypeIdentities()).thenReturn(policyTypes);
+ when(a1ClientMock.getPolicyTypeSchema(anyString())).thenReturn(Mono.just("Schema"));
+ Flux<?> error = Flux.error(new Exception("Unable to contact ric."));
+ doReturn(error).when(a1ClientMock).deleteAllPolicies();
+
+ Rics rics = new Rics();
+ StartupService serviceUnderTest = new StartupService(appConfigMock, refreshTaskMock, rics, new PolicyTypes(),
+ a1ClientFactory, new Policies(), new Services());
+
+ serviceUnderTest.startup();
+ serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, FIRST_RIC_URL, MANAGED_NODE_A),
+ ApplicationConfig.RicConfigUpdate.ADDED);
+
+ assertEquals(RicState.UNDEFINED, rics.get(FIRST_RIC_NAME).state(), "Not correct state for " + FIRST_RIC_NAME);
+ }
+
+ @SafeVarargs
+ private <T> Vector<T> toVector(T... objs) {
+ Vector<T> result = new Vector<>();
+ for (T o : objs) {
+ result.add(o);