aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java57
1 files changed, 18 insertions, 39 deletions
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();