aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-04-08 12:44:44 +0000
committerGerrit Code Review <gerrit@onap.org>2021-04-08 12:44:44 +0000
commitab7baa0563069bc403c840b39f22a9e7e900fb72 (patch)
tree52eff5bfd43dc43cd9c699e76bd904a48cc4f810 /a1-policy-management/src/test
parentac6773591fcfc1e0d5f23038b3c37e9612ca9a9e (diff)
parent97a9001fe632b0eaed48d324dc8d6c2c3c630f8c (diff)
Merge "PMS Persistent storage of policies and type definitions - A1 Istanbul"
Diffstat (limited to 'a1-policy-management/src/test')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java33
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java6
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java57
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java96
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java15
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java11
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java15
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java21
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java14
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java10
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java17
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java9
15 files changed, 140 insertions, 172 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 e6834e77..b0076405 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
@@ -34,8 +34,6 @@ import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -59,8 +57,10 @@ import org.springframework.util.StringUtils;
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
-@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se, but a mock
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
+@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se,
+ // but a mock
// of the server.
class MockPolicyManagementService {
private static final Logger logger = LoggerFactory.getLogger(MockPolicyManagementService.class);
@@ -91,9 +91,8 @@ class MockPolicyManagementService {
@TestConfiguration
static class TestBeanFactory {
+ private final ApplicationConfig applicationConfig = new MockApplicationConfig();
private final Rics rics = new Rics();
- private final Policies policies = new Policies();
- private final PolicyTypes policyTypes = new PolicyTypes();
@Bean
public ApplicationConfig getApplicationConfig() {
@@ -101,20 +100,10 @@ class MockPolicyManagementService {
}
@Bean
- public MockA1ClientFactory getA1ClientFactory() {
- PolicyTypes ricTypes = new PolicyTypes();
+ public MockA1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig) {
+ PolicyTypes ricTypes = new PolicyTypes(applicationConfig);
loadTypes(ricTypes);
- return new MockA1ClientFactory(ricTypes);
- }
-
- @Bean
- public Policies getPolicies() {
- return this.policies;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
+ return new MockA1ClientFactory(appConfig, ricTypes);
}
@Bean
@@ -136,13 +125,13 @@ class MockPolicyManagementService {
try {
String schema = readFile(file);
String typeName = title(schema);
- PolicyType type = ImmutablePolicyType.builder().id(typeName).schema(schema).build();
+ PolicyType type = PolicyType.builder().id(typeName).schema(schema).build();
policyTypes.put(type);
} catch (Exception e) {
logger.error("Could not load json schema ", e);
}
}
- policyTypes.put(ImmutablePolicyType.builder().id("").schema("{}").build());
+ policyTypes.put(PolicyType.builder().id("").schema("{}").build());
}
}
@@ -186,7 +175,7 @@ class MockPolicyManagementService {
Ric ric = rics.get("ric1");
String json = getConfigJsonFromFile();
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id("typelessPolicy") //
.json(json) //
.ownerServiceId("MockPolicyManagementService") //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
index 65dc8b5a..dbfc7d90 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/aspect/LogAspectTest.java
@@ -48,6 +48,8 @@ class LogAspectTest {
private LogAspect sampleAspect = new LogAspect();
+ LoggingUtils utils;
+
@Test
void testExecutetimeTime_shouldLogTime() throws Throwable {
when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
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 100e95e2..eb007138 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
@@ -27,8 +27,6 @@ import java.util.Vector;
import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
@@ -57,7 +55,7 @@ public class A1ClientHelper {
protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) {
String callbackUrl = "https://test.com";
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(policyId) //
.json(json) //
.ownerServiceId("service") //
@@ -70,7 +68,7 @@ public class A1ClientHelper {
}
protected static PolicyType createPolicyType(String name) {
- return ImmutablePolicyType.builder().id(name).schema("schema").build();
+ return PolicyType.builder().id(name).schema("schema").build();
}
protected static String getCreateSchema(String policyType, String policyTypeId) {
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 b5164889..bc22c14d 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
@@ -40,9 +40,9 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
@@ -51,8 +51,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableWebC
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -91,7 +89,8 @@ import reactor.util.annotation.Nullable;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
class ApplicationTest {
private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
@@ -126,6 +125,7 @@ class ApplicationTest {
public String getLocalConfigurationFilePath() {
return ""; // No config file loaded for the test
}
+
}
/**
@@ -133,10 +133,6 @@ class ApplicationTest {
*/
@TestConfiguration
static class TestBeanFactory {
- private final PolicyTypes policyTypes = new PolicyTypes();
- private final Services services = new Services();
- private final Policies policies = new Policies();
- MockA1ClientFactory a1ClientFactory = null;
@Bean
public ApplicationConfig getApplicationConfig() {
@@ -144,32 +140,15 @@ class ApplicationTest {
}
@Bean
- MockA1ClientFactory getA1ClientFactory() {
- if (a1ClientFactory == null) {
- this.a1ClientFactory = new MockA1ClientFactory(this.policyTypes);
- }
- return this.a1ClientFactory;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
+ MockA1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig, @Autowired PolicyTypes types) {
+ return new MockA1ClientFactory(appConfig, types);
}
@Bean
- Policies getPolicies() {
- return this.policies;
- }
-
- @Bean
- Services getServices() {
- return this.services;
- }
-
- @Bean
- public ServiceSupervision getServiceSupervision() {
+ public ServiceSupervision getServiceSupervision(@Autowired Services services,
+ @Autowired A1ClientFactory a1ClientFactory, @Autowired Policies policies) {
Duration checkInterval = Duration.ofMillis(1);
- return new ServiceSupervision(this.services, this.policies, this.getA1ClientFactory(), checkInterval);
+ return new ServiceSupervision(services, policies, a1ClientFactory, checkInterval);
}
@Bean
@@ -182,7 +161,7 @@ class ApplicationTest {
@LocalServerPort
private int port;
- @BeforeEach
+ @AfterEach
void reset() {
rics.clear();
policies.clear();
@@ -233,7 +212,7 @@ class ApplicationTest {
@Test
void testSynchronization() throws Exception {
// Two polictypes will be put in the NearRT RICs
- PolicyTypes nearRtRicPolicyTypes = new PolicyTypes();
+ PolicyTypes nearRtRicPolicyTypes = new PolicyTypes(this.applicationConfig);
nearRtRicPolicyTypes.put(createPolicyType("typeName"));
nearRtRicPolicyTypes.put(createPolicyType("typeName2"));
this.a1ClientFactory.setPolicyTypes(nearRtRicPolicyTypes);
@@ -259,7 +238,7 @@ class ApplicationTest {
Policies ricPolicies = getA1Client(ric1Name).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
Policy ricPolicy = ricPolicies.get(policyId);
- assertThat(ricPolicy.json()).isEqualTo(policy.json());
+ assertThat(ricPolicy.getJson()).isEqualTo(policy.getJson());
// Both types should be in the Policy Management Service's storage after the
// synch
@@ -320,9 +299,9 @@ class ApplicationTest {
Policy policy = policies.getPolicy(policyInstanceId);
assertThat(policy).isNotNull();
- assertThat(policy.id()).isEqualTo(policyInstanceId);
- assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
- assertThat(policy.ric().id()).isEqualTo("ric1");
+ assertThat(policy.getId()).isEqualTo(policyInstanceId);
+ assertThat(policy.getOwnerServiceId()).isEqualTo(serviceName);
+ assertThat(policy.getRic().id()).isEqualTo("ric1");
assertThat(policy.isTransient()).isTrue();
// Put a non transient policy
@@ -428,7 +407,7 @@ class ApplicationTest {
Policy policy = addPolicy("id", "typeName", "service1", "ric1");
{
String rsp = restClient().get(url).block();
- assertThat(rsp).isEqualTo(policy.json());
+ assertThat(rsp).isEqualTo(policy.getJson());
}
{
policies.remove(policy);
@@ -660,7 +639,7 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(id) //
.json(jsonString()) //
.ownerServiceId(service) //
@@ -755,7 +734,7 @@ class ApplicationTest {
}
private PolicyType createPolicyType(String policyTypeName) {
- return ImmutablePolicyType.builder() //
+ return PolicyType.builder() //
.id(policyTypeName) //
.schema("{\"title\":\"" + policyTypeName + "\"}") //
.build();
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 68255953..84ac596f 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
@@ -44,9 +44,9 @@ import java.util.List;
import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
@@ -56,8 +56,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.controllers.ServiceCallbackInfo;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -98,7 +96,10 @@ import reactor.util.annotation.Nullable;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target/testdata", //
+ "app.filepath=" //
+})
class ApplicationTest {
private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
@@ -131,68 +132,34 @@ class ApplicationTest {
private static Gson gson = new GsonBuilder().create();
- public static class MockApplicationConfig extends ApplicationConfig {
- @Override
- public String getLocalConfigurationFilePath() {
- return ""; // No config file loaded for the test
- }
- }
-
/**
* Overrides the BeanFactory.
*/
@TestConfiguration
static class TestBeanFactory {
- private final PolicyTypes policyTypes = new PolicyTypes();
- private final Services services = new Services();
- private final Policies policies = new Policies();
- MockA1ClientFactory a1ClientFactory = null;
-
- @Bean
- public ApplicationConfig getApplicationConfig() {
- return new MockApplicationConfig();
- }
-
- @Bean
- MockA1ClientFactory getA1ClientFactory() {
- if (a1ClientFactory == null) {
- this.a1ClientFactory = new MockA1ClientFactory(this.policyTypes);
- }
- return this.a1ClientFactory;
- }
-
- @Bean
- public PolicyTypes getPolicyTypes() {
- return this.policyTypes;
- }
-
- @Bean
- Policies getPolicies() {
- return this.policies;
- }
@Bean
- Services getServices() {
- return this.services;
+ A1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig appConfig, @Autowired PolicyTypes types) {
+ return new MockA1ClientFactory(appConfig, types);
}
@Bean
- public ServiceSupervision getServiceSupervision() {
+ public ServiceSupervision getServiceSupervision(@Autowired Services services,
+ @Autowired A1ClientFactory a1ClientFactory, @Autowired Policies policies) {
Duration checkInterval = Duration.ofMillis(1);
- return new ServiceSupervision(this.services, this.policies, this.getA1ClientFactory(), checkInterval);
+ return new ServiceSupervision(services, policies, a1ClientFactory, checkInterval);
}
@Bean
public ServletWebServerFactory servletContainer() {
return new TomcatServletWebServerFactory();
}
-
}
@LocalServerPort
private int port;
- @BeforeEach
+ @AfterEach
void reset() {
rics.clear();
policies.clear();
@@ -229,6 +196,31 @@ class ApplicationTest {
}
@Test
+ void testPersistence() throws ServiceException {
+ Ric ric = this.addRic("ric1");
+ PolicyType type = this.addPolicyType("type1", ric.id());
+ PolicyTypes types = new PolicyTypes(this.applicationConfig);
+ assertThat(types.size()).isEqualTo(1);
+
+ addPolicy("id", type.getId(), "service", ric.id());
+ addPolicy("id2", type.getId(), "service", ric.id());
+
+ {
+ Policies policies = new Policies(this.applicationConfig);
+ policies.restoreFromDatabase(ric, types);
+ assertThat(policies.size()).isEqualTo(2);
+ }
+
+ {
+ restClient().delete("/policies/id2").block();
+ Policies policies = new Policies(this.applicationConfig);
+ policies.restoreFromDatabase(ric, types);
+ assertThat(policies.size()).isEqualTo(1);
+ }
+
+ }
+
+ @Test
void testGetRics() throws Exception {
addRic("ric1");
this.addPolicyType("type1", "ric1");
@@ -260,7 +252,7 @@ class ApplicationTest {
@Test
void testSynchronization() throws Exception {
// Two polictypes will be put in the NearRT RICs
- PolicyTypes nearRtRicPolicyTypes = new PolicyTypes();
+ PolicyTypes nearRtRicPolicyTypes = new PolicyTypes(this.applicationConfig);
nearRtRicPolicyTypes.put(createPolicyType("typeName"));
nearRtRicPolicyTypes.put(createPolicyType("typeName2"));
this.a1ClientFactory.setPolicyTypes(nearRtRicPolicyTypes);
@@ -286,7 +278,7 @@ class ApplicationTest {
Policies ricPolicies = getA1Client(ric1Name).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
Policy ricPolicy = ricPolicies.get(policyId);
- assertThat(ricPolicy.json()).isEqualTo(policy.json());
+ assertThat(ricPolicy.getJson()).isEqualTo(policy.getJson());
// Both types should be in the Policy Management Service's storage after the
// synch
@@ -357,9 +349,9 @@ class ApplicationTest {
Policy policy = policies.getPolicy(policyInstanceId);
assertThat(policy).isNotNull();
- assertThat(policy.id()).isEqualTo(policyInstanceId);
- assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
- assertThat(policy.ric().id()).isEqualTo(ricId);
+ assertThat(policy.getId()).isEqualTo(policyInstanceId);
+ assertThat(policy.getOwnerServiceId()).isEqualTo(serviceName);
+ assertThat(policy.getRic().id()).isEqualTo(ricId);
assertThat(policy.isTransient()).isTrue();
// Put a non transient policy
@@ -460,7 +452,7 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
PolicyInfo info = gson.fromJson(rsp, PolicyInfo.class);
String policyStr = gson.toJson(info.policyData);
- assertThat(policyStr).isEqualTo(policy.json());
+ assertThat(policyStr).isEqualTo(policy.getJson());
}
{
policies.remove(policy);
@@ -711,7 +703,7 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id(id) //
.json(jsonString()) //
.ownerServiceId(service) //
@@ -861,7 +853,7 @@ class ApplicationTest {
}
private PolicyType createPolicyType(String policyTypeName) {
- return ImmutablePolicyType.builder() //
+ return PolicyType.builder() //
.id(policyTypeName) //
.schema("{\"title\":\"" + policyTypeName + "\"}") //
.build();
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 ded864f7..3a4aae86 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
@@ -27,7 +27,6 @@ import java.time.Instant;
import java.util.concurrent.atomic.AtomicInteger;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
@@ -112,7 +111,7 @@ class ConcurrencyTestRunnable implements Runnable {
private Policy createPolicyObject(String id) {
Ric ric = this.rics.get("ric");
PolicyType type = this.types.get("type1");
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(id) //
.json("{}") //
.type(type) //
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
index 482c94fb..6192c932 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
@@ -59,7 +59,8 @@ import reactor.test.StepVerifier;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks"})
+ "app.webclient.trust-store=./config/truststore.jks", //
+ "app.vardata-directory=./target"})
class ConfigurationControllerTest {
@Autowired
ApplicationContext context;
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 72ca84a5..3b810ad6 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
@@ -22,7 +22,6 @@ package org.onap.ccsdk.oran.a1policymanagementservice.dmaap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
@@ -37,6 +36,7 @@ import com.google.gson.JsonObject;
import java.util.ArrayList;
+import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -99,7 +99,7 @@ class DmaapMessageConsumerTest {
String s = messageConsumerUnderTest.createTask().blockLast();
assertEquals("responseFromHandler", s);
verify(messageConsumerUnderTest, times(2)).delay();
- verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(dmaapRequestMessage());
+ verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(any());
}
@Test
@@ -123,7 +123,7 @@ class DmaapMessageConsumerTest {
verify(messageConsumerUnderTest, times(2)).getFromMessageRouter(anyString());
verify(messageConsumerUnderTest, times(0)).sendErrorResponse(anyString());
verify(messageConsumerUnderTest, times(1)).delay();
- verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(dmaapRequestMessage());
+ verify(messageConsumerUnderTest, times(1)).handleDmaapMsg(any());
assertEquals("response1", s);
}
@@ -164,14 +164,17 @@ class DmaapMessageConsumerTest {
DmaapRequestMessage parsedMessage =
messageConsumerUnderTest.parseReceivedMessage(jsonArrayOfObject).blockLast();
assertNotNull(parsedMessage);
- assertTrue(parsedMessage.payload().isPresent());
+ assertNotNull(parsedMessage.getPayload());
+
+ Assert.assertEquals(dmaapRequestMessage(), parsedMessage);
}
{
String jsonArrayOfString = jsonArray(quote(json));
DmaapRequestMessage parsedMessage =
messageConsumerUnderTest.parseReceivedMessage(jsonArrayOfString).blockLast();
assertNotNull(parsedMessage);
- assertTrue(parsedMessage.payload().isPresent());
+ assertNotNull(parsedMessage.getPayload());
+ Assert.assertEquals(dmaapRequestMessage(), parsedMessage);
}
}
@@ -190,7 +193,7 @@ class DmaapMessageConsumerTest {
}
private DmaapRequestMessage dmaapRequestMessage() {
- return ImmutableDmaapRequestMessage.builder() //
+ return DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(Operation.PUT) //
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 df84ae05..285f3c4a 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
@@ -38,7 +38,6 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.nio.charset.Charset;
-import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -76,10 +75,8 @@ class DmaapMessageHandlerTest {
}
DmaapRequestMessage dmaapRequestMessage(Operation operation) {
- Optional<JsonObject> payload =
- ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson())
- : Optional.empty());
- return ImmutableDmaapRequestMessage.builder() //
+ JsonObject payload = ((operation == Operation.PUT || operation == Operation.POST) ? payloadAsJson() : null);
+ return DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(operation) //
@@ -224,12 +221,12 @@ class DmaapMessageHandlerTest {
@Test
void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
- DmaapRequestMessage message = ImmutableDmaapRequestMessage.builder() //
+ DmaapRequestMessage message = DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
.correlationId("correlationId") //
.operation(DmaapRequestMessage.Operation.PUT) //
.originatorId("originatorId") //
- .payload(Optional.empty()) //
+ .payload(null) //
.requestId("requestId") //
.target("target") //
.timestamp("timestamp") //
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 e789de62..045b1107 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
@@ -65,10 +65,9 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.Configuration
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableConfigParserResult;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
@@ -116,14 +115,14 @@ class RefreshConfigTaskTest {
}
private RefreshConfigTask createTestObject(boolean configFileExists) {
- return createTestObject(configFileExists, new Rics(), new Policies(), true);
+ return createTestObject(configFileExists, new Rics(), new Policies(appConfig), true);
}
private RefreshConfigTask createTestObject(boolean configFileExists, Rics rics, Policies policies,
boolean stubConfigFileExists) {
RefreshConfigTask obj = spy(new RefreshConfigTask(configurationFileMock, appConfig, rics, policies,
- new Services(), new PolicyTypes(), new A1ClientFactory(appConfig)));
+ new Services(), new PolicyTypes(appConfig), new A1ClientFactory(appConfig)));
if (stubConfigFileExists) {
when(configurationFileMock.readFile()).thenReturn(Optional.empty());
}
@@ -203,7 +202,7 @@ class RefreshConfigTaskTest {
@Test
void whenPeriodicConfigRefreshSuccess_thenNewConfigIsCreatedAndRepositoryUpdated() throws Exception {
Rics rics = new Rics();
- Policies policies = new Policies();
+ Policies policies = new Policies(appConfig);
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -251,7 +250,7 @@ class RefreshConfigTaskTest {
@Test
void whenPeriodicConfigRefreshInvalidJson_thenErrorIsLogged() throws Exception {
Rics rics = new Rics();
- Policies policies = new Policies();
+ Policies policies = new Policies(appConfig);
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -289,11 +288,11 @@ class RefreshConfigTaskTest {
}
private Policy getPolicy(Ric ric) {
- ImmutablePolicyType type = ImmutablePolicyType.builder() //
+ PolicyType type = PolicyType.builder() //
.id("type") //
.schema("{}") //
.build();
- Policy policy = ImmutablePolicy.builder() //
+ Policy policy = Policy.builder() //
.id("id") //
.type(type) //
.lastModified(Instant.now()) //
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 4e72bbf6..525eeff7 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
@@ -45,8 +45,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -60,7 +58,7 @@ import reactor.core.publisher.Mono;
@ExtendWith(MockitoExtension.class)
class RicSupervisionTest {
private static final String POLICY_TYPE_1_NAME = "type1";
- private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
+ private static final PolicyType POLICY_TYPE_1 = PolicyType.builder() //
.id(POLICY_TYPE_1_NAME) //
.schema("") //
.build();
@@ -73,7 +71,7 @@ class RicSupervisionTest {
.build());
private static final String POLICY_1_ID = "policyId1";
- private static final Policy POLICY_1 = ImmutablePolicy.builder() //
+ private static final Policy POLICY_1 = Policy.builder() //
.id(POLICY_1_ID) //
.json("") //
.ownerServiceId("service") //
@@ -84,7 +82,7 @@ class RicSupervisionTest {
.statusNotificationUri("statusNotificationUri") //
.build();
- private static final Policy POLICY_2 = ImmutablePolicy.builder() //
+ private static final Policy POLICY_2 = Policy.builder() //
.id("policyId2") //
.json("") //
.ownerServiceId("service") //
@@ -104,14 +102,17 @@ class RicSupervisionTest {
@Mock
private RicSynchronizationTask synchronizationTaskMock;
- private final PolicyTypes types = new PolicyTypes();
- private Policies policies = new Policies();
+ private final ApplicationConfig appConfig = new ApplicationConfig();
+
+ private PolicyTypes types;
+ private Policies policies;
private Rics rics = new Rics();
@BeforeEach
void init() {
- types.clear();
- policies.clear();
+ types = new PolicyTypes(appConfig);
+ policies = new Policies(appConfig);
+
rics.clear();
RIC_1.setState(RicState.UNAVAILABLE);
RIC_1.clearSupportedPolicyTypes();
@@ -287,7 +288,7 @@ class RicSupervisionTest {
@Test
void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
- PolicyType policyType2 = ImmutablePolicyType.builder() //
+ PolicyType policyType2 = PolicyType.builder() //
.id("policyType2") //
.schema("") //
.build();
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 ea4ca97b..2902d45b 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
@@ -49,8 +49,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -68,7 +66,7 @@ import reactor.core.publisher.Mono;
@ExtendWith(MockitoExtension.class)
class RicSynchronizationTaskTest {
private static final String POLICY_TYPE_1_NAME = "type1";
- private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
+ private static final PolicyType POLICY_TYPE_1 = PolicyType.builder() //
.id(POLICY_TYPE_1_NAME) //
.schema("") //
.build();
@@ -82,7 +80,7 @@ class RicSynchronizationTaskTest {
.build());
private static Policy createPolicy(String policyId, boolean isTransient) {
- return ImmutablePolicy.builder() //
+ return Policy.builder() //
.id(policyId) //
.json("") //
.ownerServiceId("service") //
@@ -111,10 +109,12 @@ class RicSynchronizationTaskTest {
private Services services;
private Rics rics;
+ private final ApplicationConfig appConfig = new ApplicationConfig();
+
@BeforeEach
void init() {
- policyTypes = new PolicyTypes();
- policies = new Policies();
+ policyTypes = new PolicyTypes(appConfig);
+ policies = new Policies(appConfig);
services = new Services();
rics = new Rics();
RIC_1.setState(RicState.UNAVAILABLE);
@@ -196,7 +196,7 @@ class RicSynchronizationTaskTest {
verifyNoMoreInteractions(a1ClientMock);
assertThat(policyTypes.size()).isEqualTo(1);
- assertThat(policyTypes.getType(POLICY_TYPE_1_NAME).schema()).isEqualTo(typeSchema);
+ assertThat(policyTypes.getType(POLICY_TYPE_1_NAME).getSchema()).isEqualTo(typeSchema);
assertThat(policies.size()).isZero();
assertThat(RIC_1.getState()).isEqualTo(RicState.AVAILABLE);
}
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 c8476221..4c0e96f5 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
@@ -43,10 +43,9 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
+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.repository.ImmutablePolicy;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -78,11 +77,11 @@ class ServiceSupervisionTest {
.controllerName("") //
.build();
private Ric ric = new Ric(ricConfig);
- private PolicyType policyType = ImmutablePolicyType.builder() //
+ private PolicyType policyType = PolicyType.builder() //
.id("policyTypeName") //
.schema("schema") //
.build();
- private Policy policy = ImmutablePolicy.builder() //
+ private Policy policy = Policy.builder() //
.id(POLICY_ID) //
.json("json") //
.ownerServiceId(SERVICE_NAME) //
@@ -182,7 +181,8 @@ class ServiceSupervisionTest {
service = new Service(SERVICE_NAME, keepAliveInterval, "callbackUrl");
services.put(service);
- policies = new Policies();
+ ApplicationConfig appConfig = new ApplicationConfig();
+ policies = new Policies(appConfig);
policies.put(policy);
}
}
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 482fa395..22ac2437 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
@@ -20,12 +20,16 @@
package org.onap.ccsdk.oran.a1policymanagementservice.utils;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Vector;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType;
@@ -38,20 +42,23 @@ import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
public class MockA1Client implements A1Client {
- Policies policies = new Policies();
+ Policies policies;
private final PolicyTypes policyTypes;
private final Duration asynchDelay;
- public MockA1Client(PolicyTypes policyTypes, Duration asynchDelay) {
+ public MockA1Client(String ricId, ApplicationConfig appConfig, PolicyTypes policyTypes, Duration asynchDelay) {
this.policyTypes = policyTypes;
this.asynchDelay = asynchDelay;
+ ApplicationConfig cfg = spy(appConfig);
+ when(cfg.getVardataDirectory()).thenReturn(null);
+ this.policies = new Policies(cfg);
}
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
List<String> result = new Vector<>();
for (PolicyType p : this.policyTypes.getAll()) {
- result.add(p.id());
+ result.add(p.getId());
}
return mono(result);
}
@@ -60,7 +67,7 @@ public class MockA1Client implements A1Client {
public Mono<List<String>> getPolicyIdentities() {
Vector<String> result = new Vector<>();
for (Policy policy : policies.getAll()) {
- result.add(policy.id());
+ result.add(policy.getId());
}
return mono(result);
@@ -69,7 +76,7 @@ public class MockA1Client implements A1Client {
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
try {
- return mono(this.policyTypes.getType(policyTypeId).schema());
+ return mono(this.policyTypes.getType(policyTypeId).getSchema());
} catch (Exception e) {
return Mono.error(e);
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
index d474daa6..05df70ac 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1ClientFactory.java
@@ -20,7 +20,6 @@
package org.onap.ccsdk.oran.a1policymanagementservice.utils;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import java.lang.invoke.MethodHandles;
@@ -42,10 +41,12 @@ public class MockA1ClientFactory extends A1ClientFactory {
private final Map<String, MockA1Client> clients = new HashMap<>();
private PolicyTypes policyTypes;
private Duration asynchDelay = Duration.ofSeconds(0);
+ private final ApplicationConfig appConfig;
- public MockA1ClientFactory(PolicyTypes policyTypes) {
- super(mock(ApplicationConfig.class));
+ public MockA1ClientFactory(ApplicationConfig config, PolicyTypes policyTypes) {
+ super(config);
this.policyTypes = policyTypes;
+ this.appConfig = config;
}
@Override
@@ -56,7 +57,7 @@ public class MockA1ClientFactory extends A1ClientFactory {
public MockA1Client getOrCreateA1Client(String ricId) {
if (!clients.containsKey(ricId)) {
logger.debug("Creating client for RIC: {}", ricId);
- MockA1Client client = spy(new MockA1Client(policyTypes, asynchDelay));
+ MockA1Client client = spy(new MockA1Client(ricId, appConfig, policyTypes, asynchDelay));
clients.put(ricId, client);
}
return clients.get(ricId);