Merge "Updated function test env with new tests and features"
authorHenrik Andersson <henrik.b.andersson@est.tech>
Thu, 28 May 2020 14:01:18 +0000 (14:01 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 28 May 2020 14:01:18 +0000 (14:01 +0000)
63 files changed:
docs/policy-agent-api.rst
policy-agent/config/application.yaml
policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java
policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOnapA1Client.java
policy-agent/src/main/java/org/oransc/policyagent/clients/SdncOscA1Client.java
policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfigParser.java
policy-agent/src/main/java/org/oransc/policyagent/repository/Services.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java
policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java
policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java [new file with mode: 0644]
policy-agent/src/test/java/org/oransc/policyagent/clients/A1ClientFactoryTest.java
policy-agent/src/test/java/org/oransc/policyagent/clients/AsyncRestClientTest.java
policy-agent/src/test/java/org/oransc/policyagent/clients/OscA1ClientTest.java
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOnapA1ClientTest.java
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
policy-agent/src/test/java/org/oransc/policyagent/clients/StdA1ClientTest.java
policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigParserTest.java
policy-agent/src/test/java/org/oransc/policyagent/configuration/ApplicationConfigTest.java
policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerTest.java
policy-agent/src/test/java/org/oransc/policyagent/dmaap/DmaapMessageHandlerTest.java
policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/EnvironmentProcessorTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSupervisionTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java
sdnc-a1-controller/northbound/features/features-sdnc-a1-northbound/pom.xml
sdnc-a1-controller/northbound/features/installer/pom.xml
sdnc-a1-controller/northbound/features/installer/src/main/resources/scripts/install-feature.sh
sdnc-a1-controller/northbound/features/pom.xml
sdnc-a1-controller/northbound/features/sdnc-a1-northbound-all/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/features/features-nonrt-ric-api/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/features/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/features/sdnc-nonrt-ric-api/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/installer/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/model/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/provider/pom.xml
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/provider/NonrtRicApiProviderTest.java
sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/test/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/restadapter/RestAdapterImplTest.java
sdnc-a1-controller/northbound/pom.xml
sdnc-a1-controller/oam/installation/pom.xml
sdnc-a1-controller/oam/installation/sdnc-a1/pom.xml
sdnc-a1-controller/oam/installation/sdnc-a1/src/main/docker/standalone.Dockerfile
sdnc-a1-controller/oam/installation/src/main/properties/aaiclient.properties [deleted file]
sdnc-a1-controller/oam/installation/src/main/properties/blueprints-processor-adaptor.properties [deleted file]
sdnc-a1-controller/oam/installation/src/main/yaml/docker-compose.yml
sdnc-a1-controller/oam/platform-logic/installer/pom.xml
sdnc-a1-controller/oam/platform-logic/pom.xml
sdnc-a1-controller/oam/platform-logic/setup/pom.xml
sdnc-a1-controller/oam/platform-logic/src/main/scripts/updateDgNamespace.sh
sdnc-a1-controller/oam/platform-logic/src/main/scripts/updatePackages.sh
sdnc-a1-controller/oam/pom.xml
sdnc-a1-controller/pom.xml
test/auto-test/README.md
test/auto-test/Suite-interfaces.sh
test/common/README.md
test/cr/README.md
test/mrstub/Dockerfile
test/mrstub/README.md
test/mrstub/cert/generate_cert_and_key.sh [new file with mode: 0755]

index ce94b3d..eaa805d 100644 (file)
@@ -19,7 +19,7 @@ A1 Policy Management Service API
 A1 Policy Management Service - Introduction
 *******************************************
 
-The A1 Policy Management Service ("Policy Agent") is an SMO/NONRTRIC service above the NONRTRIC A1 Adaptor/Controller
+The A1 Policy Management Service ("Policy Agent") is an SMO/NONRTRIC service above the NONRTRIC A1 Adapter/Controller
 that provides:
 
 * Unified REST & DMAAP APIs for managing A1 Policies in all Near |nbh| RT |nbsp| RICs
@@ -29,9 +29,9 @@ that provides:
 * Synchronized view of policy types in all Near |nbh| RT |nbsp| RICs
 * Policy Query API (e.g. per Near |nbh| RT |nbsp| RIC, per "service", per policy type)
 * An initial interface for unified Near |nbh| RT |nbsp| RIC ID to Near |nbh| RT |nbsp| RIC address mapping.
-  (Note:  may also later act as adaptor to A&AI, CMDBs etc. to "find" Near |nbh| RT |nbsp| RICs - TBC)
+  (Note:  may also later act as adapter to A&AI, CMDBs etc. to "find" Near |nbh| RT |nbsp| RICs - TBC)
 * An Initial "O1 ManagedElement" mapping database & interface to find appropriate Near |nbh| RT |nbsp| RIC for RAN elements.
-  (Note: may also later act as adaptor to A&AI, RuntimeDB, other CMDBs etc. - TBC)
+  (Note: may also later act as adapter to A&AI, RuntimeDB, other CMDBs etc. - TBC)
 * Monitors all Near |nbh| RT |nbsp| RICs and recovers from inconsistencies (Note: e.g. Near |nbh| RT |nbsp| RIC restarts)
 * Support for different Southbound connectors on a per Near |nbh| RT |nbsp| RIC basis. (Note: e.g. different A1
   versions, different Near |nbh| RT |nbsp| RIC versions, different A1 adapters, different or proprietary A1
@@ -585,25 +585,32 @@ Policy Management
 Policies can be queried, created, updated, and deleted. A policy is always created in a specific
 Near |nbh| RT |nbsp| RIC.
 
+A policy is defined by its policy type schema.
+
 When a policy is created, the Policy Agent stores information about it in its internal repository. At regular intervals,
 it then checks with all Near |nbh| RT |nbsp| RICs that this repository is synchronized. If, for some reason, there is an
-inconsistency, the Policy Agent will start a synchronization job and try to reflect the status of the
-Near |nbh| RT |nbsp| RIC. If this fails, the Policy Agent will delete all policies for the specific
-Near |nbh| RT |nbsp| RIC in the internal repository and set its state to *UNKNOWN*. This means that no interaction with
-the Near |nbh| RT |nbsp| RIC is possible until the Policy Agent has been able to contact it again and re-synchronize its
-state in the repository.
-
-A policy is defined by its type schema.
-
-Once a service has created a policy, it is the service's responsibility to maintain its life cycle. Since policies are
-transient, they will not survive a restart of a Near |nbh| RT |nbsp| RIC. But this is handled by the Policy Agent. When
-a Near |nbh| RT |nbsp| RIC has been restarted, the Policy Agent will try to recreate the policies in the
-Near |nbh| RT |nbsp| RIC that are stored in its local repository. This means that the service always must delete any
-policy it has created. There are only two exceptions, see below:
-
-- The service has registered a "*Keep Alive Interval*", then its policies will be deleted if it fails to notify the
-  Policy Agent in due time.
-- The Policy Agent completely fails to synchronize with a Near |nbh| RT |nbsp| RIC.
+inconsistency, the Policy Agent will start a synchronization job and try to inconsistency, the Policy Agent will start a
+synchronization job and try to reset the Near |nbh| RT |nbsp| RIC to its last-known-good status. If this fails, the
+Policy Agent will clear all policies for the specific Near |nbh| RT |nbsp| RIC in the internal repository and set its
+state to *UNKNOWN*. This means that no interaction with the Near |nbh| RT |nbsp| RIC is possible until the Policy Agent
+has been able to contact it again and re-synchronize its state in the repository.
+
+Once a service has created a policy, it is the service's responsibility to maintain its life cycle. When a Near |nbh| RT
+|nbsp| RIC has been restarted, the Policy Agent will try to recreate policies in the Near |nbh| RT |nbsp| RIC according
+to the policies maintained in its local repository.
+This means that the service must delete any policies it has created.
+A policy may be created as a "transient policy", whereby if this policy "disappears" at any stage it will not be
+re-synchronized to the Near |nbh| RT |nbsp| RIC.
+For example, this is useful if the policy should not survive a restart of the Near |nbh| RT |nbsp| RIC.
+A non-transient policy will continue to be maintained in the Near |nbh| RT |nbsp| RIC until it is explicitly deleted
+(or the service that created it fails to update its Keep Alive status).
+
+There are some exceptions where policy instances are not re-synchronized after a Near |nbh| RT |nbsp| RIC restart or
+when some inconsistency is identified:
+
+- The service has registered a "*Keep Alive Interval*", but the service then fails to update its Keep Alive status.
+- The Policy Agent completely fails to synchronize with a Near |nbh| RT |nbsp| RIC, as described above.
+- Policies that are marked as transient policies.
 
 /policies
 ~~~~~~~~~
@@ -821,6 +828,11 @@ service: (*Required*)
 
 The name of the service creating the policy.
 
+transient: (*Optional*)
+
+If the policy is transient or not (boolean defaulted to false).
+A policy is transient if it will be forgotten when the service needs to reconnect to the Near |nbh| RT |nbsp| RIC.
+
 type: (*Optional*)
 
 The name of the policy type.
index 55a1d64..c0ddfb5 100644 (file)
@@ -9,7 +9,7 @@ management:
   endpoints:
     web:
       exposure:
-        include: "loggers,logfile,health,info,metrics,threaddump"
+        include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
 
 logging:
   level:
index 3df59bf..4ba58c7 100644 (file)
@@ -50,12 +50,14 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.reactive.ReactorClientHttpConnector;
 import org.springframework.lang.Nullable;
 import org.springframework.util.ResourceUtils;
+import org.springframework.web.reactive.function.client.ExchangeStrategies;
 import org.springframework.web.reactive.function.client.WebClient;
 import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
 import org.springframework.web.reactive.function.client.WebClientResponseException;
 
 import reactor.core.publisher.Mono;
 import reactor.netty.http.client.HttpClient;
+import reactor.netty.resources.ConnectionProvider;
 import reactor.netty.tcp.TcpClient;
 
 /**
@@ -177,9 +179,10 @@ public class AsyncRestClient {
     }
 
     private Mono<ResponseEntity<String>> retrieve(Object traceTag, RequestHeadersSpec<?> request) {
+        final Class<String> clazz = String.class;
         return request.retrieve() //
-            .toEntity(String.class) //
-            .doOnNext(entity -> logger.trace("{} Received: {}", traceTag, entity.getBody()))
+            .toEntity(clazz) //
+            .doOnNext(entity -> logger.trace("{} Received: {}", traceTag, entity.getBody())) //
             .doOnError(throwable -> onHttpError(traceTag, throwable));
     }
 
@@ -262,9 +265,11 @@ public class AsyncRestClient {
     }
 
     private WebClient createWebClient(String baseUrl, SslContext sslContext) {
-        TcpClient tcpClient = TcpClient.create() //
+        ConnectionProvider connectionProvider = ConnectionProvider.newConnection();
+        TcpClient tcpClient = TcpClient.create(connectionProvider) //
             .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
             .secure(c -> c.sslContext(sslContext)) //
+
             .doOnConnected(connection -> {
                 connection.addHandlerLast(new ReadTimeoutHandler(30));
                 connection.addHandlerLast(new WriteTimeoutHandler(30));
@@ -272,9 +277,14 @@ public class AsyncRestClient {
         HttpClient httpClient = HttpClient.from(tcpClient);
         ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
 
+        ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() //
+            .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
+            .build();
+
         return WebClient.builder() //
             .clientConnector(connector) //
             .baseUrl(baseUrl) //
+            .exchangeStrategies(exchangeStrategies) //
             .build();
     }
 
index 9e9e7ab..a10decd 100644 (file)
@@ -111,7 +111,7 @@ public class SdncOnapA1Client implements A1Client {
             .policyTypeId(policy.type().name()) //
             .policyInstanceId(policy.id()) //
             .policyInstance(policy.json()) //
-            .properties(new ArrayList<String>()) //
+            .properties(new ArrayList<>()) //
             .build();
 
         String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
index a5735f7..2763ab9 100644 (file)
@@ -80,10 +80,12 @@ public class SdncOscA1Client implements A1Client {
     /**
      * Constructor that creates the REST client to use.
      *
-     * @param protocolType the southbound protocol of the controller. Supported
-     *        protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
+     * @param protocolType the southbound protocol of the controller. Supported protocols are SDNC_OSC_STD_V1_1 and
+     *        SDNC_OSC_OSC_V1
      * @param ricConfig the configuration of the Ric to communicate with
      * @param controllerConfig the configuration of the SDNC controller to use
+     *
+     * @throws IllegalArgumentException when the protocolType is wrong.
      */
     public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig) {
         this(protocolType, ricConfig, controllerConfig,
@@ -94,14 +96,21 @@ public class SdncOscA1Client implements A1Client {
     /**
      * Constructor where the REST client to use is provided.
      *
-     * @param protocolType the southbound protocol of the controller. Supported
-     *        protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
+     * @param protocolType the southbound protocol of the controller. Supported protocols are SDNC_OSC_STD_V1_1 and
+     *        SDNC_OSC_OSC_V1
      * @param ricConfig the configuration of the Ric to communicate with
      * @param controllerConfig the configuration of the SDNC controller to use
      * @param restClient the REST client to use
+     *
+     * @throws IllegalArgumentException when the protocolType is wrong.
      */
     public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
         AsyncRestClient restClient) {
+        if (!(A1ProtocolType.SDNC_OSC_STD_V1_1.equals(protocolType)
+            || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType))) {
+            throw new IllegalArgumentException("Protocol type must be " + A1ProtocolType.SDNC_OSC_STD_V1_1 + " or "
+                + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType);
+        }
         this.restClient = restClient;
         this.ricConfig = ricConfig;
         this.protocolType = protocolType;
@@ -112,22 +121,16 @@ public class SdncOscA1Client implements A1Client {
     public Mono<List<String>> getPolicyTypeIdentities() {
         if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
             return Mono.just(Arrays.asList(""));
-        } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+        } else {
             OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
             final String ricUrl = uri.createPolicyTypesUri();
             return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
                 .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
                 .collectList();
-        } else {
-            return Mono.error(createIllegalProtocolException());
         }
 
     }
 
-    private Exception createIllegalProtocolException() {
-        return new NullPointerException("Bug, unhandeled protocoltype: " + this.protocolType);
-    }
-
     @Override
     public Mono<List<String>> getPolicyIdentities() {
         return getPolicyIds() //
@@ -138,13 +141,11 @@ public class SdncOscA1Client implements A1Client {
     public Mono<String> getPolicyTypeSchema(String policyTypeId) {
         if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
             return Mono.just("{}");
-        } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+        } else {
             OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
             final String ricUrl = uri.createGetSchemaUri(policyTypeId);
             return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
                 .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId));
-        } else {
-            return Mono.error(createIllegalProtocolException());
         }
     }
 
@@ -167,13 +168,11 @@ public class SdncOscA1Client implements A1Client {
         if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
             return getPolicyIds() //
                 .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
-        } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+        } else {
             OscA1Client.UriBuilder uriBuilder = new OscA1Client.UriBuilder(ricConfig);
             return getPolicyTypeIdentities() //
                 .flatMapMany(Flux::fromIterable) //
                 .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC);
-        } else {
-            return Flux.error(createIllegalProtocolException());
         }
     }
 
@@ -205,10 +204,8 @@ public class SdncOscA1Client implements A1Client {
     private Mono<A1UriBuilder> getUriBuilder() {
         if (protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
             return Mono.just(new StdA1ClientVersion1.UriBuilder(ricConfig));
-        } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
-            return Mono.just(new OscA1Client.UriBuilder(ricConfig));
         } else {
-            return Mono.error(createIllegalProtocolException());
+            return Mono.just(new OscA1Client.UriBuilder(ricConfig));
         }
     }
 
@@ -230,14 +227,12 @@ public class SdncOscA1Client implements A1Client {
             final String ricUrl = uri.createGetPolicyIdsUri();
             return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
                 .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
-        } else if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+        } else {
             OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
             return getPolicyTypeIdentities() //
                 .flatMapMany(Flux::fromIterable)
                 .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
                 .flatMap(SdncJsonHelper::parseJsonArrayOfString);
-        } else {
-            return Flux.error(createIllegalProtocolException());
         }
     }
 
@@ -272,10 +267,10 @@ public class SdncOscA1Client implements A1Client {
         } else {
             logger.debug("Error response: {} {}", output.httpStatus(), body);
             byte[] responseBodyBytes = body.getBytes(StandardCharsets.UTF_8);
-            WebClientResponseException e = new WebClientResponseException(output.httpStatus(), "statusText", null,
-                responseBodyBytes, StandardCharsets.UTF_8, null);
+            WebClientResponseException responseException = new WebClientResponseException(output.httpStatus(),
+                "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null);
 
-            return Mono.error(e);
+            return Mono.error(responseException);
         }
     }
 
index 5495710..a76f964 100644 (file)
@@ -71,6 +71,10 @@ public class ApplicationConfigParser {
 
         JsonObject agentConfigJson = root.getAsJsonObject(CONFIG);
 
+        if (agentConfigJson == null) {
+            throw new ServiceException("Missing root configuration \"" + CONFIG + "\" in JSON: " + root);
+        }
+
         JsonObject json = agentConfigJson.getAsJsonObject("streams_publishes");
         if (json != null) {
             dmaapPublisherConfig = parseDmaapConfig(json);
index f829c7c..1fd08a8 100644 (file)
@@ -47,6 +47,7 @@ public class Services {
 
     public synchronized void put(Service service) {
         logger.debug("Put service: {}", service.getName());
+        service.keepAlive();
         registeredServices.put(service.getName(), service);
     }
 
index 89c8d63..b99a230 100644 (file)
@@ -52,7 +52,6 @@ import org.oransc.policyagent.configuration.ApplicationConfig;
 import org.oransc.policyagent.configuration.ApplicationConfig.RicConfigUpdate;
 import org.oransc.policyagent.configuration.ApplicationConfigParser;
 import org.oransc.policyagent.configuration.RicConfig;
-import org.oransc.policyagent.exceptions.ServiceException;
 import org.oransc.policyagent.repository.Policies;
 import org.oransc.policyagent.repository.PolicyTypes;
 import org.oransc.policyagent.repository.Ric;
@@ -69,8 +68,7 @@ import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 /**
- * Regularly refreshes the configuration from Consul or from a local
- * configuration file.
+ * Regularly refreshes the configuration from Consul or from a local configuration file.
  */
 @Component
 public class RefreshConfigTask {
@@ -158,8 +156,8 @@ public class RefreshConfigTask {
     }
 
     private Mono<JsonObject> getFromCbs(CbsClient cbsClient) {
-        final CbsRequest getConfigRequest = CbsRequests.getAll(RequestDiagnosticContext.create());
         try {
+            final CbsRequest getConfigRequest = CbsRequests.getAll(RequestDiagnosticContext.create());
             return cbsClient.get(getConfigRequest) //
                 .onErrorResume(this::ignoreErrorMono);
         } catch (Exception e) {
@@ -249,7 +247,7 @@ public class RefreshConfigTask {
             appParser.parse(rootObject);
             logger.debug("Local configuration file loaded: {}", filepath);
             return Flux.just(rootObject);
-        } catch (IOException | ServiceException e) {
+        } catch (Exception e) {
             logger.error("Local configuration file not loaded: {}, {}", filepath, e.getMessage());
             return Flux.empty();
         }
index 751c0ac..9c55532 100644 (file)
@@ -50,6 +50,7 @@ import reactor.core.publisher.Mono;
 @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
 public class ServiceSupervision {
     private static final Logger logger = LoggerFactory.getLogger(ServiceSupervision.class);
+    static final int CONCURRENCY_RIC = 1; // How may paralell requests that is sent
     private final Services services;
     private final Policies policies;
     private A1ClientFactory a1ClientFactory;
@@ -85,7 +86,7 @@ public class ServiceSupervision {
             .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) //
             .doOnNext(service -> services.remove(service.getName())) //
             .flatMap(this::getAllPoliciesForService) //
-            .flatMap(this::deletePolicy);
+            .flatMap(this::deletePolicy, CONCURRENCY_RIC);
     }
 
     @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
index a8fc6e1..cffd1c4 100644 (file)
@@ -90,7 +90,7 @@ import reactor.util.annotation.Nullable;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-public class ApplicationTest {
+class ApplicationTest {
     private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
 
     @Autowired
@@ -183,7 +183,7 @@ public class ApplicationTest {
     private int port;
 
     @BeforeEach
-    public void reset() {
+    void reset() {
         rics.clear();
         policies.clear();
         policyTypes.clear();
@@ -192,7 +192,7 @@ public class ApplicationTest {
     }
 
     @AfterEach
-    public void verifyNoRicLocks() {
+    void verifyNoRicLocks() {
         for (Ric ric : this.rics.getRics()) {
             ric.getLock().lockBlocking(LockType.EXCLUSIVE);
             ric.getLock().unlockBlocking();
@@ -202,7 +202,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetRics() throws Exception {
+    void testGetRics() throws Exception {
         addRic("ric1");
         this.addPolicyType("type1", "ric1");
         String url = "/rics?policyType=type1";
@@ -231,7 +231,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testSynchronization() throws Exception {
+    void testSynchronization() throws Exception {
         // Two polictypes will be put in the NearRT RICs
         PolicyTypes nearRtRicPolicyTypes = new PolicyTypes();
         nearRtRicPolicyTypes.put(createPolicyType("typeName"));
@@ -267,7 +267,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetRicForManagedElement_thenReturnCorrectRic() throws Exception {
+    void testGetRicForManagedElement_thenReturnCorrectRic() throws Exception {
         String ricName = "ric1";
         String managedElementId = "kista_1";
         addRic(ricName, managedElementId);
@@ -301,7 +301,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testPutPolicy() throws Exception {
+    void testPutPolicy() throws Exception {
         String serviceName = "service1";
         String ricName = "ric1";
         String policyTypeName = "type1";
@@ -358,7 +358,7 @@ public class ApplicationTest {
      *
      * @throws ServiceException
      */
-    public void testErrorFromRIC() throws ServiceException {
+    void testErrorFromRIC() throws ServiceException {
         putService("service1");
         addPolicyType("type1", "ric1");
 
@@ -392,7 +392,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testPutTypelessPolicy() throws Exception {
+    void testPutTypelessPolicy() throws Exception {
         putService("service1");
         addPolicyType("", "ric1");
         String url = putPolicyUrl("service1", "ric1", "", "id1");
@@ -407,7 +407,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testRefuseToUpdatePolicy() throws Exception {
+    void testRefuseToUpdatePolicy() throws Exception {
         // Test that only the json can be changed for a already created policy
         // In this case service is attempted to be changed
         this.addRic("ric1");
@@ -421,7 +421,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicy() throws Exception {
+    void testGetPolicy() throws Exception {
         String url = "/policy?id=id";
         Policy policy = addPolicy("id", "typeName", "service1", "ric1");
         {
@@ -435,7 +435,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testDeletePolicy() throws Exception {
+    void testDeletePolicy() throws Exception {
         addPolicy("id", "typeName", "service1", "ric1");
         assertThat(policies.size()).isEqualTo(1);
 
@@ -450,7 +450,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicySchemas() throws Exception {
+    void testGetPolicySchemas() throws Exception {
         addPolicyType("type1", "ric1");
         addPolicyType("type2", "ric2");
 
@@ -474,7 +474,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicySchema() throws Exception {
+    void testGetPolicySchema() throws Exception {
         addPolicyType("type1", "ric1");
         addPolicyType("type2", "ric2");
 
@@ -490,7 +490,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicyTypes() throws Exception {
+    void testGetPolicyTypes() throws Exception {
         addPolicyType("type1", "ric1");
         addPolicyType("type2", "ric2");
 
@@ -508,7 +508,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicies() throws Exception {
+    void testGetPolicies() throws Exception {
         addPolicy("id1", "type1", "service1");
 
         String url = "/policies";
@@ -524,7 +524,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPoliciesFilter() throws Exception {
+    void testGetPoliciesFilter() throws Exception {
         addPolicy("id1", "type1", "service1");
         addPolicy("id2", "type1", "service2");
         addPolicy("id3", "type2", "service1");
@@ -553,7 +553,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicyIdsFilter() throws Exception {
+    void testGetPolicyIdsFilter() throws Exception {
         addPolicy("id1", "type1", "service1", "ric1");
         addPolicy("id2", "type1", "service2", "ric1");
         addPolicy("id3", "type2", "service1", "ric1");
@@ -579,7 +579,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testPutAndGetService() throws Exception {
+    void testPutAndGetService() throws Exception {
         // PUT
         putService("name", 0, HttpStatus.CREATED);
         putService("name", 0, HttpStatus.OK);
@@ -625,7 +625,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testServiceSupervision() throws Exception {
+    void testServiceSupervision() throws Exception {
         putService("service1", 1, HttpStatus.CREATED);
         addPolicyType("type1", "ric1");
 
@@ -642,7 +642,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testGetPolicyStatus() throws Exception {
+    void testGetPolicyStatus() throws Exception {
         addPolicy("id", "typeName", "service1", "ric1");
         assertThat(policies.size()).isEqualTo(1);
 
@@ -707,7 +707,7 @@ public class ApplicationTest {
     }
 
     @Test
-    public void testConcurrency() throws Exception {
+    void testConcurrency() throws Exception {
         final Instant startTime = Instant.now();
         List<Thread> threads = new ArrayList<>();
         a1ClientFactory.setResponseDelay(Duration.ofMillis(1));
index 7f57ceb..d37a2be 100644 (file)
@@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
 
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-public class MockPolicyAgent {
+class MockPolicyAgent {
     private static final Logger logger = LoggerFactory.getLogger(MockPolicyAgent.class);
 
     @Autowired
@@ -199,9 +199,8 @@ public class MockPolicyAgent {
 
     @Test
     @SuppressWarnings("squid:S2699") // Tests should include assertions. This test is only for keeping the server
-                                     // alive,
-                                     // so it will only be confusing to add an assertion.
-    public void runMock() throws Exception {
+                                     // alive, so it will only be confusing to add an assertion.
+    void runMock() throws Exception {
         keepServerAlive();
     }
 
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java b/policy-agent/src/test/java/org/oransc/policyagent/aspect/LogAspectTest.java
new file mode 100644 (file)
index 0000000..7930e5c
--- /dev/null
@@ -0,0 +1,78 @@
+package org.oransc.policyagent.aspect;
+
+import static ch.qos.logback.classic.Level.TRACE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.junit.Rule;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.oransc.policyagent.utils.LoggingUtils;
+
+@ExtendWith(MockitoExtension.class)
+class LogAspectTest {
+    @Rule
+    MockitoRule mockitoRule = MockitoJUnit.rule();
+
+    @Mock
+    private ProceedingJoinPoint proceedingJoinPoint;
+
+    @Mock
+    private MethodSignature methodSignature;
+
+    private LogAspect sampleAspect = new LogAspect();
+
+    @Test
+    void testExecutetimeTime_shouldLogTime() throws Throwable {
+        when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
+        when(methodSignature.getDeclaringType()).thenReturn(this.getClass());
+
+        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(LogAspect.class, TRACE);
+
+        sampleAspect.executimeTime(proceedingJoinPoint);
+        // 'proceed()' is called exactly once
+        verify(proceedingJoinPoint, times(1)).proceed();
+        // 'proceed(Object[])' is never called
+        verify(proceedingJoinPoint, never()).proceed(null);
+
+        assertThat(logAppender.list.toString().contains("Execution time of")).isTrue();
+    }
+
+    @Test
+    void testEntryLog_shouldLogEntry() throws Throwable {
+        when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
+        String signature = "signature";
+        when(methodSignature.getName()).thenReturn(signature);
+
+        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(LogAspect.class, TRACE);
+
+        sampleAspect.entryLog(proceedingJoinPoint);
+
+        assertThat(logAppender.list.toString().contains("Entering method: " + signature)).isTrue();
+    }
+
+    @Test
+    void testExitLog_shouldLogExit() throws Throwable {
+        when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
+        String signature = "signature";
+        when(methodSignature.getName()).thenReturn(signature);
+
+        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(LogAspect.class, TRACE);
+
+        sampleAspect.exitLog(proceedingJoinPoint);
+
+        assertThat(logAppender.list.toString().contains("Exiting method: " + signature)).isTrue();
+    }
+}
index d696770..74cebb0 100644 (file)
@@ -46,7 +46,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class A1ClientFactoryTest {
+class A1ClientFactoryTest {
     private static final String RIC_NAME = "Name";
     private static final String EXCEPTION_MESSAGE = "Error";
 
@@ -78,14 +78,14 @@ public class A1ClientFactoryTest {
     }
 
     @BeforeEach
-    public void createFactoryUnderTest() {
+    void createFactoryUnderTest() {
         factoryUnderTest = spy(new A1ClientFactory(applicationConfigMock));
         this.ric = new Ric(ricConfig(""));
 
     }
 
     @Test
-    public void getProtocolVersion_ok() throws ServiceException {
+    void getProtocolVersion_ok() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1);
         whenGetProtocolVersionReturn(clientMock2, A1ProtocolType.STD_V1_1);
         doReturn(clientMock1, clientMock2).when(factoryUnderTest).createClient(any(), any());
@@ -97,7 +97,7 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void getProtocolVersion_ok_Last() throws ServiceException {
+    void getProtocolVersion_ok_Last() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3);
         whenGetProtocolVersionReturn(clientMock4, A1ProtocolType.STD_V1_1);
         doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
@@ -109,7 +109,7 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void getProtocolVersion_error() throws ServiceException {
+    void getProtocolVersion_error() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3, clientMock4);
         doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
 
@@ -126,13 +126,13 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void create_check_types() throws ServiceException {
+    void create_check_types() throws ServiceException {
         assertTrue(createClient(A1ProtocolType.STD_V1_1) instanceof StdA1ClientVersion1);
         assertTrue(createClient(A1ProtocolType.OSC_V1) instanceof OscA1Client);
     }
 
     @Test
-    public void create_check_types_controllers() throws ServiceException {
+    void create_check_types_controllers() throws ServiceException {
         this.ric = new Ric(ricConfig("anythingButEmpty"));
         whenGetGetControllerConfigReturn();
         assertTrue(createClient(A1ProtocolType.SDNC_ONAP) instanceof SdncOnapA1Client);
index 884b36f..f3b9482 100644 (file)
@@ -39,7 +39,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 import reactor.util.Loggers;
 
-public class AsyncRestClientTest {
+class AsyncRestClientTest {
     private static final String BASE_URL = "BaseUrl";
     private static final String REQUEST_URL = "/test";
     private static final String USERNAME = "username";
@@ -53,7 +53,7 @@ public class AsyncRestClientTest {
     private static AsyncRestClient clientUnderTest;
 
     @BeforeAll
-    public static void init() {
+    static void init() {
         // skip a lot of unnecessary logs from MockWebServer
         InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE);
         Loggers.useJdkLoggers();
@@ -62,12 +62,12 @@ public class AsyncRestClientTest {
     }
 
     @AfterAll
-    public static void tearDown() throws IOException {
+    static void tearDown() throws IOException {
         mockWebServer.shutdown();
     }
 
     @Test
-    public void testGetNoError() {
+    void testGetNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -77,7 +77,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testGetError() {
+    void testGetError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL);
@@ -86,7 +86,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPutNoError() {
+    void testPutNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -96,7 +96,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPutError() {
+    void testPutError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON);
@@ -105,7 +105,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testDeleteNoError() {
+    void testDeleteNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE));
 
         Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
@@ -113,7 +113,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testDeleteError() {
+    void testDeleteError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
@@ -122,7 +122,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPostNoError() {
+    void testPostNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -132,7 +132,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPostError() {
+    void testPostError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON);
@@ -141,7 +141,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPostWithAuthHeaderNoError() {
+    void testPostWithAuthHeaderNoError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
             .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
             .setBody(TEST_JSON));
@@ -151,7 +151,7 @@ public class AsyncRestClientTest {
     }
 
     @Test
-    public void testPostWithAuthHeaderError() {
+    void testPostWithAuthHeaderError() {
         mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
 
         Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD);
index b66340b..d23276d 100644 (file)
@@ -43,7 +43,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class OscA1ClientTest {
+class OscA1ClientTest {
 
     private static final String RIC_URL = "RicUrl";
 
@@ -65,7 +65,7 @@ public class OscA1ClientTest {
     AsyncRestClient asyncRestClientMock;
 
     @BeforeEach
-    public void init() {
+    void init() {
         RicConfig ricConfig = ImmutableRicConfig.builder() //
             .name("name") //
             .baseUrl("RicBaseUrl") //
@@ -77,7 +77,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyTypeIdentities() {
+    void testGetPolicyTypeIdentities() {
         List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
         Mono<String> policyTypeIdsResp = Mono.just(policyTypeIds.toString());
         when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp);
@@ -88,7 +88,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyIdentities() {
+    void testGetPolicyIdentities() {
         Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
         Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
         Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString());
@@ -104,7 +104,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testGetValidPolicyType() {
+    void testGetValidPolicyType() {
         String policyType = "{\"create_schema\": " + POLICY_TYPE_SCHEMA_VALID + "}";
         Mono<String> policyTypeResp = Mono.just(policyType);
 
@@ -117,7 +117,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testGetInValidPolicyTypeJson() {
+    void testGetInValidPolicyTypeJson() {
         String policyType = "{\"create_schema\": " + POLICY_TYPE_SCHEMA_INVALID + "}";
         Mono<String> policyTypeResp = Mono.just(policyType);
 
@@ -129,7 +129,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyTypeWithoutCreateSchema() {
+    void testGetPolicyTypeWithoutCreateSchema() {
         Mono<String> policyTypeResp = Mono.just(POLICY_TYPE_SCHEMA_VALID);
 
         when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeResp);
@@ -140,7 +140,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testPutPolicy() {
+    void testPutPolicy() {
         when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty());
 
         clientUnderTest
@@ -150,7 +150,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testDeletePolicy() {
+    void testDeletePolicy() {
         when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty());
 
         Mono<String> returnedMono = clientUnderTest
@@ -160,7 +160,7 @@ public class OscA1ClientTest {
     }
 
     @Test
-    public void testDeleteAllPolicies() {
+    void testDeleteAllPolicies() {
         Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
         Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
         Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString());
index c7f9073..6b4ebd6 100644 (file)
@@ -43,7 +43,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class SdncOnapA1ClientTest {
+class SdncOnapA1ClientTest {
     private static final String CONTROLLER_USERNAME = "username";
     private static final String CONTROLLER_PASSWORD = "password";
     private static final String RIC_1_URL = "RicUrl";
@@ -66,7 +66,7 @@ public class SdncOnapA1ClientTest {
     AsyncRestClient asyncRestClientMock;
 
     @BeforeEach
-    public void init() {
+    void init() {
         asyncRestClientMock = mock(AsyncRestClient.class);
         ControllerConfig controllerCfg = ImmutableControllerConfig.builder() //
             .name("name") //
@@ -80,7 +80,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyTypeIdentities() {
+    void testGetPolicyTypeIdentities() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .build();
@@ -98,7 +98,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyIdentities() {
+    void testGetPolicyIdentities() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .build();
@@ -136,7 +136,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testGetValidPolicyType() {
+    void testGetValidPolicyType() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .policyTypeId(POLICY_TYPE_1_ID) //
@@ -154,7 +154,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testGetInvalidPolicyType() {
+    void testGetInvalidPolicyType() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .policyTypeId(POLICY_TYPE_1_ID) //
@@ -172,7 +172,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testPutPolicy() {
+    void testPutPolicy() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .policyTypeId(POLICY_TYPE_1_ID) //
@@ -192,7 +192,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testDeletePolicy() {
+    void testDeletePolicy() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .policyTypeId(POLICY_TYPE_1_ID) //
@@ -210,7 +210,7 @@ public class SdncOnapA1ClientTest {
     }
 
     @Test
-    public void testDeleteAllPolicies() {
+    void testDeleteAllPolicies() {
         SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
             .nearRtRicId(RIC_1_URL) //
             .build();
index fecbccb..d63974e 100644 (file)
@@ -20,9 +20,9 @@
 
 package org.oransc.policyagent.clients;
 
+import static org.junit.Assert.fail;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -40,22 +40,25 @@ import java.util.Optional;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.stubbing.OngoingStubbing;
 import org.oransc.policyagent.clients.A1Client.A1ProtocolType;
+import org.oransc.policyagent.clients.ImmutableAdapterOutput.Builder;
 import org.oransc.policyagent.clients.SdncOscA1Client.AdapterOutput;
 import org.oransc.policyagent.clients.SdncOscA1Client.AdapterRequest;
 import org.oransc.policyagent.configuration.ControllerConfig;
 import org.oransc.policyagent.configuration.ImmutableControllerConfig;
 import org.oransc.policyagent.repository.Policy;
 import org.oransc.policyagent.repository.Ric;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.reactive.function.client.WebClientResponseException;
 
 import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class SdncOscA1ClientTest {
+class SdncOscA1ClientTest {
     private static final String CONTROLLER_USERNAME = "username";
     private static final String CONTROLLER_PASSWORD = "password";
     private static final String RIC_1_URL = "RicUrl";
@@ -70,6 +73,7 @@ public class SdncOscA1ClientTest {
 
     SdncOscA1Client clientUnderTest;
 
+    @Mock
     AsyncRestClient asyncRestClientMock;
 
     private ControllerConfig controllerConfig() {
@@ -82,8 +86,7 @@ public class SdncOscA1ClientTest {
     }
 
     @BeforeEach
-    public void init() {
-        asyncRestClientMock = mock(AsyncRestClient.class);
+    void init() {
         Ric ric = A1ClientHelper.createRic(RIC_1_URL);
 
         clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), controllerConfig(),
@@ -91,22 +94,33 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyTypeIdentities_STD() {
+    void createClientWithWrongProtocol_thenErrorIsThrown() {
+        try {
+            new SdncOscA1Client(A1ProtocolType.STD_V1_1, null, null, null);
+            fail("Should have thrown exception.");
+        } catch (IllegalArgumentException e) {
+            return;
+        }
+    }
+
+    @Test
+    void getPolicyTypeIdentities_STD() {
         List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
         assertEquals(1, policyTypeIds.size(), "should hardcoded to one");
         assertEquals("", policyTypeIds.get(0), "should hardcoded to empty");
     }
 
     @Test
-    public void testGetPolicyTypeIdentities_OSC() {
+    void getPolicyTypeIdentities_OSC() {
         clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
             A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
             controllerConfig(), asyncRestClientMock);
 
-        String response = createResponse(Arrays.asList(POLICY_TYPE_1_ID));
+        String response = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID));
         whenAsyncPostThenReturn(Mono.just(response));
 
         List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
+
         assertEquals(1, policyTypeIds.size(), "");
         assertEquals(POLICY_TYPE_1_ID, policyTypeIds.get(0), "");
 
@@ -119,25 +133,26 @@ public class SdncOscA1ClientTest {
             CONTROLLER_PASSWORD);
     }
 
-    private String loadFile(String fileName) throws IOException {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        URL url = loader.getResource(fileName);
-        File file = new File(url.getFile());
-        return new String(Files.readAllBytes(file.toPath()));
+    @Test
+    void getTypeSchema_STD() {
+        String policyType = clientUnderTest.getPolicyTypeSchema("").block();
+
+        assertEquals("{}", policyType, "");
     }
 
     @Test
-    public void testGetTypeSchema_OSC() throws IOException {
+    void getTypeSchema_OSC() throws IOException {
         clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
             A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
             controllerConfig(), asyncRestClientMock);
 
         String ricResponse = loadFile("test_osc_get_schema_response.json");
         JsonElement elem = gson().fromJson(ricResponse, JsonElement.class);
-        String responseFromController = createResponse(elem);
+        String responseFromController = createOkResponseWithBody(elem);
         whenAsyncPostThenReturn(Mono.just(responseFromController));
 
         String response = clientUnderTest.getPolicyTypeSchema("policyTypeId").block();
+
         JsonElement respJson = gson().fromJson(response, JsonElement.class);
         assertEquals("policyTypeId", respJson.getAsJsonObject().get("title").getAsString(),
             "title should be updated to contain policyType ID");
@@ -154,29 +169,14 @@ public class SdncOscA1ClientTest {
         assertEquals("1", result.get(1), "");
     }
 
-    private String policiesUrl() {
-        return RIC_1_URL + "/A1-P/v1/policies";
-    }
-
-    private Gson gson() {
-        return SdncOscA1Client.gson;
-    }
-
-    private String createResponse(Object body) {
-        AdapterOutput output = ImmutableAdapterOutput.builder() //
-            .body(gson().toJson(body)) //
-            .httpStatus(200) //
-            .build();
-        return SdncJsonHelper.createOutputJsonString(output);
-    }
-
     @Test
-    public void testGetPolicyIdentities() {
+    void getPolicyIdentities_STD() {
 
-        String policyIdsResp = createResponse(Arrays.asList(POLICY_1_ID, POLICY_2_ID));
+        String policyIdsResp = createOkResponseWithBody(Arrays.asList(POLICY_1_ID, POLICY_2_ID));
         whenAsyncPostThenReturn(Mono.just(policyIdsResp));
 
         List<String> returned = clientUnderTest.getPolicyIdentities().block();
+
         assertEquals(2, returned.size(), "");
 
         ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
@@ -189,18 +189,35 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testGetValidPolicyType() {
-        String policyType = clientUnderTest.getPolicyTypeSchema("").block();
-        assertEquals("{}", policyType, "");
+    void getPolicyIdentities_OSC() {
+        clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
+            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));
+        whenAsyncPostThenReturn(Mono.just(policytypeIdsResp)).thenReturn(Mono.just(policyIdsResp));
+
+        List<String> returned = clientUnderTest.getPolicyIdentities().block();
+
+        assertEquals(2, returned.size(), "");
+
+        ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
+            .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);
     }
 
     @Test
-    public void testPutPolicyValidResponse() {
+    void putPolicyValidResponse() {
         whenPostReturnOkResponse();
 
         String returned = clientUnderTest
             .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() //
@@ -213,11 +230,11 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testPutPolicyRejected() {
+    void putPolicyRejected() {
         final String policyJson = "{}";
         AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() //
             .body("NOK") //
-            .httpStatus(400) // ERROR
+            .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR
             .build();
 
         String resp = SdncJsonHelper.createOutputJsonString(adapterOutput);
@@ -243,12 +260,13 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testDeletePolicy() {
+    void deletePolicy() {
         whenPostReturnOkResponse();
 
         String returned = clientUnderTest
             .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() //
@@ -261,7 +279,7 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testGetStatus() {
+    void getStatus() {
         whenPostReturnOkResponse();
 
         Policy policy = A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID);
@@ -281,34 +299,72 @@ public class SdncOscA1ClientTest {
     }
 
     @Test
-    public void testGetVersion() {
+    void getVersion_STD() {
         whenPostReturnOkResponse();
+
         A1ProtocolType returnedVersion = clientUnderTest.getProtocolVersion().block();
-        assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion, "");
+
+        assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion);
 
         whenPostReturnOkResponseNoBody();
+
         returnedVersion = clientUnderTest.getProtocolVersion().block();
-        assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion, "");
+
+        assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion);
     }
 
-    private void whenPostReturnOkResponse() {
-        AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() //
-            .body("OK") //
-            .httpStatus(200) //
-            .build();
+    @Test
+    void getVersion_OSC() {
+        clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
+            A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
+            controllerConfig(), asyncRestClientMock);
 
-        String resp = SdncJsonHelper.createOutputJsonString(adapterOutput);
-        whenAsyncPostThenReturn(Mono.just(resp));
+        whenAsyncPostThenReturn(Mono.error(new Exception("Error"))).thenReturn(Mono.just(createOkResponseString(true)));
+
+        A1ProtocolType returnedVersion = clientUnderTest.getProtocolVersion().block();
+
+        assertEquals(A1ProtocolType.SDNC_OSC_OSC_V1, returnedVersion);
+    }
+
+    private String policiesUrl() {
+        return RIC_1_URL + "/A1-P/v1/policies";
+    }
+
+    private Gson gson() {
+        return SdncOscA1Client.gson;
+    }
+
+    private String loadFile(String fileName) throws IOException {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        URL url = loader.getResource(fileName);
+        File file = new File(url.getFile());
+        return new String(Files.readAllBytes(file.toPath()));
+    }
+
+    private void whenPostReturnOkResponse() {
+        whenAsyncPostThenReturn(Mono.just(createOkResponseString(true)));
     }
 
     private void whenPostReturnOkResponseNoBody() {
-        AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() //
-            .httpStatus(200) //
-            .body(Optional.empty()) //
+        whenAsyncPostThenReturn(Mono.just(createOkResponseString(false)));
+    }
+
+    private String createOkResponseWithBody(Object body) {
+        AdapterOutput output = ImmutableAdapterOutput.builder() //
+            .body(gson().toJson(body)) //
+            .httpStatus(HttpStatus.OK.value()) //
             .build();
+        return SdncJsonHelper.createOutputJsonString(output);
+    }
 
-        String resp = SdncJsonHelper.createOutputJsonString(adapterOutput);
-        whenAsyncPostThenReturn(Mono.just(resp));
+    private String createOkResponseString(boolean withBody) {
+        Builder responseBuilder = ImmutableAdapterOutput.builder().httpStatus(HttpStatus.OK.value());
+        if (withBody) {
+            responseBuilder.body(HttpStatus.OK.name());
+        } else {
+            responseBuilder.body(Optional.empty());
+        }
+        return SdncJsonHelper.createOutputJsonString(responseBuilder.build());
     }
 
     private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
index 15fe05a..beb2ca9 100644 (file)
@@ -42,7 +42,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class StdA1ClientTest {
+class StdA1ClientTest {
     private static final String RIC_URL = "RicUrl";
     private static final String POLICY_TYPE_1_NAME = "type1";
     private static final String POLICY_1_ID = "policy1";
@@ -59,7 +59,7 @@ public class StdA1ClientTest {
     RicConfig ricConfigMock;
 
     @BeforeEach
-    public void init() {
+    void init() {
         clientUnderTest = new StdA1ClientVersion1(asyncRestClientMock, ricConfigMock);
     }
 
@@ -72,14 +72,14 @@ public class StdA1ClientTest {
     }
 
     @Test
-    public void testGetPolicyTypeIdentities() {
+    void testGetPolicyTypeIdentities() {
         List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
         assertEquals(1, policyTypeIds.size(), "should hardcoded to one");
         assertEquals("", policyTypeIds.get(0), "should hardcoded to empty");
     }
 
     @Test
-    public void testGetPolicyIdentities() {
+    void testGetPolicyIdentities() {
         doReturn(RIC_URL).when(ricConfigMock).baseUrl();
         Mono<String> policyIds = Mono.just(Arrays.asList(POLICY_1_ID, POLICY_2_ID).toString());
         when(asyncRestClientMock.get(anyString())).thenReturn(policyIds);
@@ -91,13 +91,13 @@ public class StdA1ClientTest {
     }
 
     @Test
-    public void testGetValidPolicyType() {
+    void testGetValidPolicyType() {
         String policyType = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_NAME).block();
         assertEquals("{}", policyType, "");
     }
 
     @Test
-    public void testPutPolicyValidResponse() {
+    void testPutPolicyValidResponse() {
         doReturn(RIC_URL).when(ricConfigMock).baseUrl();
         when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.just(POLICY_JSON));
 
@@ -109,7 +109,7 @@ public class StdA1ClientTest {
     }
 
     @Test
-    public void testDeletePolicy() {
+    void testDeletePolicy() {
         doReturn(RIC_URL).when(ricConfigMock).baseUrl();
         final String url = policiesBaseUrl() + POLICY_1_ID;
         when(asyncRestClientMock.delete(url)).thenReturn(Mono.empty());
@@ -121,7 +121,7 @@ public class StdA1ClientTest {
     }
 
     @Test
-    public void testDeleteAllPolicies() {
+    void testDeleteAllPolicies() {
         doReturn(RIC_URL).when(ricConfigMock).baseUrl();
         Mono<String> policyIds = Mono.just(Arrays.asList(POLICY_1_ID, POLICY_2_ID).toString());
         when(asyncRestClientMock.get(policiesUrl())).thenReturn(policyIds);
index 79eb07a..6b106c9 100644 (file)
@@ -47,12 +47,12 @@ import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
 import org.oransc.policyagent.exceptions.ServiceException;
 import org.springframework.http.MediaType;
 
-public class ApplicationConfigParserTest {
+class ApplicationConfigParserTest {
 
     ApplicationConfigParser parserUnderTest = new ApplicationConfigParser();
 
     @Test
-    public void whenCorrectConfig() throws Exception {
+    void whenCorrectConfig() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
 
         ApplicationConfigParser.ConfigParserResult result = parserUnderTest.parse(jsonRootObject);
@@ -111,7 +111,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenDmaapConfigHasSeveralStreamsPublishing() throws Exception {
+    void whenDmaapConfigHasSeveralStreamsPublishing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         JsonObject json = jsonRootObject.getAsJsonObject("config").getAsJsonObject("streams_publishes");
         JsonObject fake_info_object = new JsonObject();
@@ -131,6 +131,7 @@ public class ApplicationConfigParserTest {
         private JsonObject dmaap_publisher;
         private JsonObject fake_info_object;
 
+        @Override
         public String toString() {
             return String.format("[dmaap_publisher=%s, fake_info_object=%s]", dmaap_publisher.toString(),
                 fake_info_object.toString());
@@ -138,7 +139,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenDmaapConfigHasSeveralStreamsSubscribing() throws Exception {
+    void whenDmaapConfigHasSeveralStreamsSubscribing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         JsonObject json = jsonRootObject.getAsJsonObject("config").getAsJsonObject("streams_subscribes");
         JsonObject fake_info_object = new JsonObject();
@@ -158,6 +159,7 @@ public class ApplicationConfigParserTest {
         private JsonObject dmaap_subscriber;
         private JsonObject fake_info_object;
 
+        @Override
         public String toString() {
             return String.format("[dmaap_subscriber=%s, fake_info_object=%s]", dmaap_subscriber.toString(),
                 fake_info_object.toString());
@@ -165,7 +167,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenMalformedUrlStreamsSubscribing() throws Exception {
+    void whenMalformedUrlStreamsSubscribing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         final String wrongTopicUrl = "WrongTopicUrl";
         JsonObject json = getDmaapInfo(jsonRootObject, "streams_subscribes", "dmaap_subscriber");
@@ -181,7 +183,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenMalformedUrlStreamsPublishing() throws Exception {
+    void whenMalformedUrlStreamsPublishing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         final String wrongTopicUrl = "WrongTopicUrl";
         JsonObject json = getDmaapInfo(jsonRootObject, "streams_publishes", "dmaap_publisher");
@@ -197,7 +199,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenWrongMemberNameInObject() throws Exception {
+    void whenWrongMemberNameInObject() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         JsonObject json = jsonRootObject.getAsJsonObject("config");
         json.remove("ric");
@@ -209,7 +211,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenWrongUrlPathStreamsSubscribing() throws Exception {
+    void whenWrongUrlPathStreamsSubscribing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         final String wrongTopicUrlString =
             "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent/wrong-topic-url";
@@ -225,7 +227,7 @@ public class ApplicationConfigParserTest {
     }
 
     @Test
-    public void whenWrongUrlPathStreamsPublishing() throws Exception {
+    void whenWrongUrlPathStreamsPublishing() throws Exception {
         JsonObject jsonRootObject = getJsonRootObject();
         final String wrongTopicUrlString =
             "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-WRITE/wrong-topic-url";
@@ -240,7 +242,7 @@ public class ApplicationConfigParserTest {
             "Wrong error message when the streams publishes' URL has incorrect syntax");
     }
 
-    public JsonObject getDmaapInfo(JsonObject jsonRootObject, String streamsPublishesOrSubscribes,
+    JsonObject getDmaapInfo(JsonObject jsonRootObject, String streamsPublishesOrSubscribes,
         String dmaapPublisherOrSubscriber) throws Exception {
         return jsonRootObject.getAsJsonObject("config").getAsJsonObject(streamsPublishesOrSubscribes)
             .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info");
index 96abd1c..6a6f447 100644 (file)
@@ -38,7 +38,7 @@ import org.oransc.policyagent.configuration.ApplicationConfigParser.ConfigParser
 import org.oransc.policyagent.exceptions.ServiceException;
 
 @ExtendWith(MockitoExtension.class)
-public class ApplicationConfigTest {
+class ApplicationConfigTest {
 
     private static final ImmutableRicConfig RIC_CONFIG_1 = ImmutableRicConfig.builder() //
         .name("ric1") //
@@ -57,7 +57,7 @@ public class ApplicationConfigTest {
     }
 
     @Test
-    public void gettingNotAddedRicShouldThrowException() {
+    void gettingNotAddedRicShouldThrowException() {
         ApplicationConfig appConfigUnderTest = new ApplicationConfig();
 
         appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1));
@@ -70,7 +70,7 @@ public class ApplicationConfigTest {
     }
 
     @Test
-    public void addRicShouldNotifyAllObserversOfRicAdded() throws Exception {
+    void addRicShouldNotifyAllObserversOfRicAdded() throws Exception {
         ApplicationConfig appConfigUnderTest = new ApplicationConfig();
 
         RicConfigUpdate update = appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)).blockFirst();
@@ -87,7 +87,7 @@ public class ApplicationConfigTest {
     }
 
     @Test
-    public void changedRicShouldNotifyAllObserversOfRicChanged() throws Exception {
+    void changedRicShouldNotifyAllObserversOfRicChanged() throws Exception {
         ApplicationConfig appConfigUnderTest = new ApplicationConfig();
 
         appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1));
@@ -107,7 +107,7 @@ public class ApplicationConfigTest {
     }
 
     @Test
-    public void removedRicShouldNotifyAllObserversOfRicRemoved() {
+    void removedRicShouldNotifyAllObserversOfRicRemoved() {
         ApplicationConfig appConfigUnderTest = new ApplicationConfig();
 
         ImmutableRicConfig ricConfig2 = ImmutableRicConfig.builder() //
index 7b338cc..5c11830 100644 (file)
@@ -54,7 +54,7 @@ import org.oransc.policyagent.utils.LoggingUtils;
 import org.springframework.http.HttpStatus;
 
 @ExtendWith(MockitoExtension.class)
-public class DmaapMessageConsumerTest {
+class DmaapMessageConsumerTest {
     @Mock
     private ApplicationConfig applicationConfigMock;
     @Mock
@@ -65,12 +65,12 @@ public class DmaapMessageConsumerTest {
     private DmaapMessageConsumer messageConsumerUnderTest;
 
     @AfterEach
-    public void resetLogging() {
+    void resetLogging() {
         LoggingUtils.getLogListAppender(DmaapMessageConsumer.class);
     }
 
     @Test
-    public void dmaapNotConfigured_thenSleepAndRetryUntilConfig() throws Exception {
+    void dmaapNotConfigured_thenSleepAndRetryUntilConfig() throws Exception {
         messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
 
         doNothing().when(messageConsumerUnderTest).sleep(any(Duration.class));
@@ -86,7 +86,7 @@ public class DmaapMessageConsumerTest {
     }
 
     @Test
-    public void dmaapConfigurationRemoved_thenStopPollingDmaapSleepAndRetry() throws Exception {
+    void dmaapConfigurationRemoved_thenStopPollingDmaapSleepAndRetry() throws Exception {
         messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
 
         doNothing().when(messageConsumerUnderTest).sleep(any(Duration.class));
@@ -102,7 +102,7 @@ public class DmaapMessageConsumerTest {
     }
 
     @Test
-    public void dmaapConfiguredAndNoMessages_thenPollOnce() throws Exception {
+    void dmaapConfiguredAndNoMessages_thenPollOnce() throws Exception {
         setUpMrConfig();
 
         messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
@@ -123,7 +123,7 @@ public class DmaapMessageConsumerTest {
     }
 
     @Test
-    public void dmaapConfiguredAndErrorGettingMessages_thenLogWarningAndSleep() throws Exception {
+    void dmaapConfiguredAndErrorGettingMessages_thenLogWarningAndSleep() throws Exception {
         setUpMrConfig();
 
         messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
@@ -153,7 +153,7 @@ public class DmaapMessageConsumerTest {
     }
 
     @Test
-    public void dmaapConfiguredAndOneMessage_thenPollOnceAndProcessMessage() throws Exception {
+    void dmaapConfiguredAndOneMessage_thenPollOnceAndProcessMessage() throws Exception {
         setUpMrConfig();
         messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
 
index 6b3457b..f1ae7fb 100644 (file)
@@ -22,6 +22,7 @@ package org.oransc.policyagent.dmaap;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -61,7 +62,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
 import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
-public class DmaapMessageHandlerTest {
+class DmaapMessageHandlerTest {
     private static final Logger logger = LoggerFactory.getLogger(DmaapMessageHandlerTest.class);
     private static final String URL = "url";
 
@@ -112,22 +113,22 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void testMessageParsing() {
+    void testMessageParsing() {
         String message = dmaapInputMessage(Operation.DELETE);
         logger.info(message);
         DmaapRequestMessage parsedMessage = gson.fromJson(message, ImmutableDmaapRequestMessage.class);
-        assertTrue(parsedMessage != null);
+        assertNotNull(parsedMessage);
         assertFalse(parsedMessage.payload().isPresent());
 
         message = dmaapInputMessage(Operation.PUT);
         logger.info(message);
         parsedMessage = gson.fromJson(message, ImmutableDmaapRequestMessage.class);
-        assertTrue(parsedMessage != null);
+        assertNotNull(parsedMessage);
         assertTrue(parsedMessage.payload().isPresent());
     }
 
     @Test
-    public void unparseableMessage_thenWarning() {
+    void unparseableMessage_thenWarning() {
         final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(DmaapMessageHandler.class);
 
         testedObject.handleDmaapMsg("bad message");
@@ -137,7 +138,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void successfulDelete() throws IOException {
+    void successfulDelete() throws IOException {
         doReturn(okResponse()).when(agentClient).deleteForEntity(anyString());
         doReturn(1).when(dmaapClient).send(anyString());
         doReturn(new MRPublisherResponse()).when(dmaapClient).sendBatchWithResponse();
@@ -159,7 +160,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void successfulGet() throws IOException {
+    void successfulGet() throws IOException {
         doReturn(okResponse()).when(agentClient).getForEntity(anyString());
         doReturn(1).when(dmaapClient).send(anyString());
         doReturn(new MRPublisherResponse()).when(dmaapClient).sendBatchWithResponse();
@@ -179,7 +180,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void successfulPut() throws IOException {
+    void successfulPut() throws IOException {
         doReturn(okResponse()).when(agentClient).putForEntity(anyString(), anyString());
         doReturn(1).when(dmaapClient).send(anyString());
         doReturn(new MRPublisherResponse()).when(dmaapClient).sendBatchWithResponse();
@@ -199,7 +200,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void successfulPost() throws IOException {
+    void successfulPost() throws IOException {
         doReturn(okResponse()).when(agentClient).postForEntity(anyString(), anyString());
         doReturn(1).when(dmaapClient).send(anyString());
         doReturn(new MRPublisherResponse()).when(dmaapClient).sendBatchWithResponse();
@@ -219,7 +220,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void exceptionWhenCallingPolicyAgent_thenNotFoundResponse() throws IOException {
+    void exceptionWhenCallingPolicyAgent_thenNotFoundResponse() throws IOException {
         WebClientResponseException except = new WebClientResponseException(400, "Refused", null, null, null, null);
         doReturn(Mono.error(except)).when(agentClient).putForEntity(anyString(), any());
         doReturn(1).when(dmaapClient).send(anyString());
@@ -243,7 +244,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void unsupportedOperationInMessage_thenNotFoundResponseWithNotImplementedOperation() throws Exception {
+    void unsupportedOperationInMessage_thenNotFoundResponseWithNotImplementedOperation() throws Exception {
         String message = dmaapInputMessage(Operation.PUT).toString();
         String badOperation = "BAD";
         message = message.replace(Operation.PUT.toString(), badOperation);
@@ -261,7 +262,7 @@ public class DmaapMessageHandlerTest {
     }
 
     @Test
-    public void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
+    void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
         String message = dmaapInputMessage(Operation.PUT).toString();
         message = message.replace(",\"payload\":{\"name\":\"name\",\"schema\":\"schema\"}", "");
 
index 5c1cc14..fd75978 100644 (file)
@@ -34,7 +34,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class LockTest {
+class LockTest {
 
     @SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests.
     private void sleep() {
@@ -54,7 +54,7 @@ public class LockTest {
     }
 
     @Test
-    public void testLock() throws IOException, ServiceException {
+    void testLock() throws IOException, ServiceException {
         Lock lock = new Lock();
         lock.lockBlocking(LockType.SHARED);
         lock.unlockBlocking();
@@ -69,7 +69,7 @@ public class LockTest {
     }
 
     @Test
-    public void testReactiveLock() {
+    void testReactiveLock() {
         Lock lock = new Lock();
 
         Mono<Lock> seq = lock.lock(LockType.EXCLUSIVE) //
index c22629b..5d8c74c 100644 (file)
@@ -35,7 +35,7 @@ import org.oransc.policyagent.exceptions.EnvironmentLoaderException;
 import org.oransc.policyagent.utils.LoggingUtils;
 import reactor.test.StepVerifier;
 
-public class EnvironmentProcessorTest {
+class EnvironmentProcessorTest {
     private static final String CONSUL_HOST = "CONSUL_HOST";
     private static final String CONSUL_HOST_VALUE = "consulHost";
 
@@ -46,7 +46,7 @@ public class EnvironmentProcessorTest {
     private static final String HOSTNAME_VALUE = "hostname";
 
     @Test
-    public void allPropertiesAvailableWithHostname_thenAllPropertiesAreReturnedWithGivenConsulPort() {
+    void allPropertiesAvailableWithHostname_thenAllPropertiesAreReturnedWithGivenConsulPort() {
         Properties systemEnvironment = new Properties();
         String consulPort = "8080";
         systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
@@ -66,7 +66,7 @@ public class EnvironmentProcessorTest {
     }
 
     @Test
-    public void consulHostMissing_thenExceptionReturned() {
+    void consulHostMissing_thenExceptionReturned() {
         Properties systemEnvironment = new Properties();
 
         StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
@@ -76,7 +76,7 @@ public class EnvironmentProcessorTest {
     }
 
     @Test
-    public void withAllPropertiesExceptConsulPort_thenAllPropertiesAreReturnedWithDefaultConsulPortAndWarning() {
+    void withAllPropertiesExceptConsulPort_thenAllPropertiesAreReturnedWithDefaultConsulPortAndWarning() {
         Properties systemEnvironment = new Properties();
         systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
         systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE);
@@ -101,7 +101,7 @@ public class EnvironmentProcessorTest {
     }
 
     @Test
-    public void configBindingServiceMissing_thenExceptionReturned() {
+    void configBindingServiceMissing_thenExceptionReturned() {
         Properties systemEnvironment = new Properties();
         systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
 
@@ -112,7 +112,7 @@ public class EnvironmentProcessorTest {
     }
 
     @Test
-    public void allPropertiesAvailableWithServiceName_thenAllPropertiesAreReturned() {
+    void allPropertiesAvailableWithServiceName_thenAllPropertiesAreReturned() {
         Properties systemEnvironment = new Properties();
         String consulPort = "8080";
         systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
@@ -132,7 +132,7 @@ public class EnvironmentProcessorTest {
     }
 
     @Test
-    public void serviceNameAndHostnameMissing_thenExceptionIsReturned() {
+    void serviceNameAndHostnameMissing_thenExceptionIsReturned() {
         Properties systemEnvironment = new Properties();
         systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
         systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE);
index 6edd4e3..c7b913b 100644 (file)
@@ -85,7 +85,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class RefreshConfigTaskTest {
+class RefreshConfigTaskTest {
 
     private static final boolean CONFIG_FILE_EXISTS = true;
     private static final boolean CONFIG_FILE_DOES_NOT_EXIST = false;
@@ -99,7 +99,7 @@ public class RefreshConfigTaskTest {
     CbsClient cbsClient;
 
     private static final String RIC_1_NAME = "ric1";
-    public static final ImmutableRicConfig CORRECT_RIC_CONIFG = ImmutableRicConfig.builder() //
+    private static final ImmutableRicConfig CORRECT_RIC_CONIFG = ImmutableRicConfig.builder() //
         .name(RIC_1_NAME) //
         .baseUrl("http://localhost:8080/") //
         .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
@@ -130,7 +130,7 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void startWithStubbedRefresh_thenTerminationLogged() {
+    void startWithStubbedRefresh_thenTerminationLogged() {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
         doReturn(Flux.empty()).when(refreshTaskUnderTest).createRefreshTask();
 
@@ -142,7 +142,7 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
+    void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
         doReturn(Flux.error(new Exception("Error"))).when(refreshTaskUnderTest).createRefreshTask();
 
@@ -156,7 +156,7 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void stop_thenTaskIsDisposed() throws Exception {
+    void stop_thenTaskIsDisposed() throws Exception {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
         refreshTaskUnderTest.systemEnvironment = new Properties();
 
@@ -167,14 +167,15 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void whenTheConfigurationFits_thenConfiguredRicsArePutInRepository() throws Exception {
+    void whenTheConfigurationFits_thenConfiguredRicsArePutInRepository() throws Exception {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_EXISTS);
         refreshTaskUnderTest.systemEnvironment = new Properties();
         // When
         doReturn(getCorrectJson()).when(refreshTaskUnderTest).createInputStream(any());
         doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
 
-        StepVerifier.create(refreshTaskUnderTest.createRefreshTask()) //
+        StepVerifier //
+            .create(refreshTaskUnderTest.createRefreshTask()) //
             .expectSubscription() //
             .expectNext(Type.ADDED) //
             .expectNext(Type.ADDED) //
@@ -193,7 +194,7 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void whenFileExistsButJsonIsIncorrect_thenNoRicsArePutInRepository() throws Exception {
+    void whenFileExistsButJsonIsIncorrect_thenNoRicsArePutInRepositoryAndErrorIsLogged() throws Exception {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_EXISTS);
         refreshTaskUnderTest.systemEnvironment = new Properties();
 
@@ -201,7 +202,10 @@ public class RefreshConfigTaskTest {
         doReturn(getIncorrectJson()).when(refreshTaskUnderTest).createInputStream(any());
         doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
 
-        StepVerifier.create(refreshTaskUnderTest.createRefreshTask()) //
+        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
+
+        StepVerifier //
+            .create(refreshTaskUnderTest.createRefreshTask()) //
             .expectSubscription() //
             .expectNoEvent(Duration.ofMillis(100)) //
             .thenCancel() //
@@ -210,10 +214,12 @@ public class RefreshConfigTaskTest {
         // Then
         verify(refreshTaskUnderTest).loadConfigurationFromFile();
         assertThat(appConfig.getRicConfigs().size()).isEqualTo(0);
+
+        assertThat(logAppender.list.toString().contains("Local configuration file not loaded: fileName, ")).isTrue();
     }
 
     @Test
-    public void whenPeriodicConfigRefreshNoConsul_thenErrorIsLogged() {
+    void whenPeriodicConfigRefreshNoConsul_thenErrorIsLogged() {
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST);
         refreshTaskUnderTest.systemEnvironment = new Properties();
 
@@ -224,10 +230,9 @@ public class RefreshConfigTaskTest {
         when(cbsClient.get(any())).thenReturn(Mono.error(new IOException()));
 
         final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, WARN);
-        Flux<Type> task = refreshTaskUnderTest.createRefreshTask();
 
         StepVerifier //
-            .create(task) //
+            .create(refreshTaskUnderTest.createRefreshTask()) //
             .expectSubscription() //
             .expectNoEvent(Duration.ofMillis(1000)) //
             .thenCancel() //
@@ -239,7 +244,7 @@ public class RefreshConfigTaskTest {
     }
 
     @Test
-    public void whenPeriodicConfigRefreshSuccess_thenNewConfigIsCreatedAndRepositoryUpdated() throws Exception {
+    void whenPeriodicConfigRefreshSuccess_thenNewConfigIsCreatedAndRepositoryUpdated() throws Exception {
         Rics rics = new Rics();
         Policies policies = new Policies();
         refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
@@ -259,16 +264,14 @@ public class RefreshConfigTaskTest {
         doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
         doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
 
-        JsonObject configAsJson = getJsonRootObject();
+        JsonObject configAsJson = getJsonRootObject(true);
         String newBaseUrl = "newBaseUrl";
         modifyTheRicConfiguration(configAsJson, newBaseUrl);
         when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
         doNothing().when(refreshTaskUnderTest).runRicSynchronization(any(Ric.class));
 
-        Flux<Type> task = refreshTaskUnderTest.createRefreshTask();
-
         StepVerifier //
-            .create(task) //
+            .create(refreshTaskUnderTest.createRefreshTask()) //
             .expectSubscription() //
             .expectNext(Type.CHANGED) //
             .expectNext(Type.ADDED) //
@@ -288,6 +291,35 @@ public class RefreshConfigTaskTest {
         assertThat(policies.size()).isEqualTo(0);
     }
 
+    @Test
+    void whenPeriodicConfigRefreshInvalidJson_thenErrorIsLogged() throws Exception {
+        Rics rics = new Rics();
+        Policies policies = new Policies();
+        refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, rics, policies, false);
+        refreshTaskUnderTest.systemEnvironment = new Properties();
+
+        appConfig.setConfiguration(configParserResult());
+
+        EnvProperties props = properties();
+        doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
+        doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
+
+        JsonObject configAsJson = getJsonRootObject(false);
+        when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
+
+        final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
+
+        StepVerifier //
+            .create(refreshTaskUnderTest.createRefreshTask()) //
+            .expectSubscription() //
+            .expectNoEvent(Duration.ofMillis(1000)) //
+            .thenCancel() //
+            .verify();
+
+        assertThat(logAppender.list.toString()
+            .contains("Could not parse configuration org.oransc.policyagent.exceptions.ServiceException: ")).isTrue();
+    }
+
     private RicConfig getRicConfig(String name) {
         RicConfig ricConfig = ImmutableRicConfig.builder() //
             .name(name) //
@@ -330,8 +362,9 @@ public class RefreshConfigTaskTest {
                 .addProperty("baseUrl", newBaseUrl);
     }
 
-    private JsonObject getJsonRootObject() throws JsonIOException, JsonSyntaxException, IOException {
-        JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(getCorrectJson())).getAsJsonObject();
+    private JsonObject getJsonRootObject(boolean valid) throws JsonIOException, JsonSyntaxException, IOException {
+        JsonObject rootObject = JsonParser
+            .parseReader(new InputStreamReader(valid ? getCorrectJson() : getIncorrectJson())).getAsJsonObject();
         return rootObject;
     }
 
@@ -342,9 +375,7 @@ public class RefreshConfigTaskTest {
     }
 
     private static InputStream getIncorrectJson() {
-        String string = "{" + //
-            "    \"config\": {" + //
-            "        \"ric\": {"; //
+        String string = "{}"; //
         return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
     }
 }
index a42142b..5ac4cb0 100644 (file)
@@ -56,7 +56,7 @@ import org.oransc.policyagent.repository.Rics;
 import reactor.core.publisher.Mono;
 
 @ExtendWith(MockitoExtension.class)
-public class RicSupervisionTest {
+class RicSupervisionTest {
     private static final String POLICY_TYPE_1_NAME = "type1";
     private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
         .name(POLICY_TYPE_1_NAME) //
@@ -105,7 +105,7 @@ public class RicSupervisionTest {
     private Rics rics = new Rics();
 
     @BeforeEach
-    public void init() {
+    void init() {
         types.clear();
         policies.clear();
         rics.clear();
@@ -114,7 +114,7 @@ public class RicSupervisionTest {
     }
 
     @AfterEach
-    public void verifyNoRicLocks() {
+    void verifyNoRicLocks() {
         for (Ric ric : this.rics.getRics()) {
             ric.getLock().lockBlocking(LockType.EXCLUSIVE);
             ric.getLock().unlockBlocking();
@@ -123,7 +123,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndNoChangedPoliciesOrPolicyTypes_thenNoSynchronization() {
+    void whenRicIdleAndNoChangedPoliciesOrPolicyTypes_thenNoSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
@@ -145,7 +145,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicUndefined_thenSynchronization() {
+    void whenRicUndefined_thenSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.UNAVAILABLE);
         rics.put(RIC_1);
@@ -163,7 +163,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicSynchronizing_thenNoSynchronization() {
+    void whenRicSynchronizing_thenNoSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.SYNCHRONIZING);
         rics.put(RIC_1);
@@ -177,7 +177,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndErrorGettingPolicyIdentities_thenNoSynchronization() {
+    void whenRicIdleAndErrorGettingPolicyIdentities_thenNoSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
@@ -194,7 +194,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndNotSameAmountOfPolicies_thenSynchronization() {
+    void whenRicIdleAndNotSameAmountOfPolicies_thenSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         rics.put(RIC_1);
@@ -217,7 +217,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndSameAmountOfPoliciesButNotSamePolicies_thenSynchronization() {
+    void whenRicIdleAndSameAmountOfPoliciesButNotSamePolicies_thenSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         rics.put(RIC_1);
@@ -240,7 +240,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndErrorGettingPolicyTypes_thenNoSynchronization() {
+    void whenRicIdleAndErrorGettingPolicyTypes_thenNoSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
@@ -257,7 +257,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndNotSameAmountOfPolicyTypes_thenSynchronization() {
+    void whenRicIdleAndNotSameAmountOfPolicyTypes_thenSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         RIC_1.setState(RicState.AVAILABLE);
         RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
@@ -281,7 +281,7 @@ public class RicSupervisionTest {
     }
 
     @Test
-    public void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
+    void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
         doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
         PolicyType policyType2 = ImmutablePolicyType.builder() //
             .name("policyType2") //
index c8ebe27..224803d 100644 (file)
@@ -65,7 +65,7 @@ import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 @ExtendWith(MockitoExtension.class)
-public class RicSynchronizationTaskTest {
+class RicSynchronizationTaskTest {
     private static final String POLICY_TYPE_1_NAME = "type1";
     private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
         .name(POLICY_TYPE_1_NAME) //
@@ -80,9 +80,9 @@ public class RicSynchronizationTaskTest {
         .controllerName("controllerName") //
         .build());
 
-    private static Policy createPolicy(boolean isTransient) {
+    private static Policy createPolicy(String policyId, boolean isTransient) {
         return ImmutablePolicy.builder() //
-            .id("policyId1") //
+            .id(policyId) //
             .json("") //
             .ownerServiceName("service") //
             .ric(RIC_1) //
@@ -92,7 +92,7 @@ public class RicSynchronizationTaskTest {
             .build();
     }
 
-    private static final Policy POLICY_1 = createPolicy(false);
+    private static final Policy POLICY_1 = createPolicy("policyId1", false);
 
     private static final String SERVICE_1_NAME = "service1";
     private static final String SERVICE_1_CALLBACK_URL = "callbackUrl";
@@ -109,7 +109,7 @@ public class RicSynchronizationTaskTest {
     private Services services;
 
     @BeforeEach
-    public void init() {
+    void init() {
         policyTypes = new PolicyTypes();
         policies = new Policies();
         services = new Services();
@@ -118,7 +118,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricAlreadySynchronizing_thenNoSynchronization() {
+    void ricAlreadySynchronizing_thenNoSynchronization() {
         RIC_1.setState(RicState.SYNCHRONIZING);
         RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
 
@@ -139,7 +139,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdlePolicyTypeInRepo_thenSynchronizationWithReuseOfTypeFromRepoAndCorrectServiceNotified() {
+    void ricIdlePolicyTypeInRepo_thenSynchronizationWithReuseOfTypeFromRepoAndCorrectServiceNotified() {
         RIC_1.setState(RicState.AVAILABLE);
 
         policyTypes.put(POLICY_TYPE_1);
@@ -175,7 +175,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdlePolicyTypeNotInRepo_thenSynchronizationWithTypeFromRic() throws Exception {
+    void ricIdlePolicyTypeNotInRepo_thenSynchronizationWithTypeFromRic() throws Exception {
         RIC_1.setState(RicState.AVAILABLE);
 
         setUpCreationOfA1Client();
@@ -198,10 +198,10 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdleAndHavePolicies_thenSynchronizationWithRecreationOfPolicies() {
+    void ricIdleAndHavePolicies_thenSynchronizationWithRecreationOfPolicies() {
         RIC_1.setState(RicState.AVAILABLE);
 
-        Policy transientPolicy = createPolicy(true);
+        Policy transientPolicy = createPolicy("transientPolicyId", true);
 
         policies.put(transientPolicy);
         policies.put(POLICY_1);
@@ -227,7 +227,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdleAndErrorDeletingPoliciesFirstTime_thenSynchronizationWithDeletionOfPolicies() {
+    void ricIdleAndErrorDeletingPoliciesFirstTime_thenSynchronizationWithDeletionOfPolicies() {
         RIC_1.setState(RicState.AVAILABLE);
 
         policies.put(POLICY_1);
@@ -253,7 +253,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdleAndErrorDeletingPoliciesAllTheTime_thenSynchronizationWithFailedRecovery() {
+    void ricIdleAndErrorDeletingPoliciesAllTheTime_thenSynchronizationWithFailedRecovery() {
         RIC_1.setState(RicState.AVAILABLE);
 
         policies.put(POLICY_1);
@@ -284,7 +284,7 @@ public class RicSynchronizationTaskTest {
     }
 
     @Test
-    public void ricIdlePolicyTypeInRepo_thenSynchronizationWithErrorOnServiceNotificationErrorLogged() {
+    void ricIdlePolicyTypeInRepo_thenSynchronizationWithErrorOnServiceNotificationErrorLogged() {
         RIC_1.setState(RicState.AVAILABLE);
 
         policyTypes.put(POLICY_TYPE_1);
index 90a3581..495b2a5 100644 (file)
@@ -56,7 +56,7 @@ import org.oransc.policyagent.utils.LoggingUtils;
 import reactor.core.publisher.Mono;
 
 @ExtendWith(MockitoExtension.class)
-public class ServiceSupervisionTest {
+class ServiceSupervisionTest {
 
     private static final String SERVICE_NAME = "Service name";
     private static final String RIC_NAME = "name";
@@ -92,7 +92,7 @@ public class ServiceSupervisionTest {
         .build();
 
     @Test
-    public void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
+    void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         setUpCreationOfA1Client();
@@ -113,7 +113,7 @@ public class ServiceSupervisionTest {
     }
 
     @Test
-    public void serviceExpiredButDeleteInRicFails_policyAndServiceAreDeletedInRepoAndErrorLoggedForRic() {
+    void serviceExpiredButDeleteInRicFails_policyAndServiceAreDeletedInRepoAndErrorLoggedForRic() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         setUpCreationOfA1Client();
@@ -140,7 +140,7 @@ public class ServiceSupervisionTest {
     }
 
     @Test
-    public void serviceNotExpired_shouldNotBeChecked() {
+    void serviceNotExpired_shouldNotBeChecked() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         ServiceSupervision serviceSupervisionUnderTest =
@@ -156,7 +156,7 @@ public class ServiceSupervisionTest {
     }
 
     @Test
-    public void serviceWithoutKeepAliveInterval_shouldNotBeChecked() {
+    void serviceWithoutKeepAliveInterval_shouldNotBeChecked() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0));
 
         ServiceSupervision serviceSupervisionUnderTest =
index e16ed98..c637817 100644 (file)
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--<![CDATA[
+========================LICENSE_START=================================
+O-RAN-SC
+%%
+Modifications Copyright (C) 2020 Nordix Foundation
+%%
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+========================LICENSE_END===================================
+]]>-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
@@ -19,7 +38,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
     <artifactId>features-sdnc-a1-northbound</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>feature</packaging>
 
     <name>sdnc-a1-northbound :: features :: ${project.artifactId}</name>
index c8a35b0..2366499 100755 (executable)
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--<![CDATA[
+========================LICENSE_START=================================
+O-RAN-SC
+%%
+Modifications Copyright (C) 2020 Nordix Foundation
+%%
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+========================LICENSE_END===================================
+]]>-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
 
@@ -11,7 +30,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>sdnc-a1-northbound-features-installer</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-northbound :: features :: ${project.artifactId}</name>
index e16e79a..0af54c2 100644 (file)
@@ -1,5 +1,22 @@
 #!/bin/bash
 
+#  ============LICENSE_START===============================================
+#  Modifications Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
 ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
 INSTALLERDIR=$(dirname $0)
index b68d283..96dfb7b 100755 (executable)
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--<![CDATA[
+========================LICENSE_START=================================
+O-RAN-SC
+%%
+Modifications Copyright (C) 2020 Nordix Foundation
+%%
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+========================LICENSE_END===================================
+]]>-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
 
@@ -11,7 +30,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>sdnc-northbound-feature-aggregator</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-northbound :: features</name>
index 265f576..3490585 100644 (file)
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--<![CDATA[
+========================LICENSE_START=================================
+O-RAN-SC
+%%
+Modifications Copyright (C) 2020 Nordix Foundation
+%%
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+========================LICENSE_END===================================
+]]>-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
 
@@ -19,7 +38,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>sdnc-a1-northbound-all</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>feature</packaging>
 
        <name>sdnc-a1-northbound :: features :: ${project.artifactId}</name>
index 6935b62..74867cc 100644 (file)
@@ -30,7 +30,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>features-nonrt-ric-api</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>feature</packaging>
 
        <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index 59a108f..6547d33 100644 (file)
@@ -30,7 +30,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
     <artifactId>nonrt-ric-api-features</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index 4da7a69..4f4d223 100644 (file)
@@ -30,7 +30,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
     <artifactId>sdnc-nonrt-ric-api</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>feature</packaging>
 
     <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index e17a79b..aaa3517 100755 (executable)
@@ -30,7 +30,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>nonrt-ric-api-installer</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index 1a686a3..df2a5b0 100644 (file)
@@ -38,7 +38,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
     <artifactId>nonrt-ric-api-model</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index d0bacb0..fbac7a5 100644 (file)
@@ -32,7 +32,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>nonrt-ric-api</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-northbound :: nonrt-ric-api</name>
index e37d656..4b4e081 100644 (file)
@@ -40,7 +40,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
     <artifactId>nonrt-ric-api-provider</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>sdnc-a1-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
index b33b771..472250b 100644 (file)
 
 package org.o_ran_sc.nonrtric.sdnc_a1.northbound.provider;
 
+import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.when;
 import java.util.concurrent.ExecutionException;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -63,6 +63,9 @@ import org.springframework.web.client.RestClientResponseException;
 public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
 
   protected static final Logger LOG = LoggerFactory.getLogger(NonrtRicApiProviderTest.class);
+
+  private static final Integer HTTP_OK_AS_INTEGER = HttpStatus.OK.value();
+
   protected NonrtRicApiProvider nonrtRicApiProvider;
   protected DataBroker dataBroker;
   @Mock
@@ -88,8 +91,8 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     ResponseEntity<Object> getResponse = new ResponseEntity<>(returnedBody, HttpStatus.OK);
     when(restAdapter.get(eq(nearRtRicUrl.getValue()), eq(String.class))).thenReturn(getResponse);
     GetA1PolicyOutput result = nonrtRicApiProvider.getA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(HttpStatus.OK.value() == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(HTTP_OK_AS_INTEGER, result.getHttpStatus());
   }
 
   @Test
@@ -101,8 +104,8 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     ResponseEntity<Object> getResponse = new ResponseEntity<>(returnedBody, HttpStatus.OK);
     when(restAdapter.get(eq(nearRtRicUrl.getValue()), eq(String.class))).thenReturn(getResponse);
     GetA1PolicyTypeOutput result = nonrtRicApiProvider.getA1PolicyType(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(HttpStatus.OK.value() == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(HTTP_OK_AS_INTEGER, result.getHttpStatus());
   }
 
   @Test
@@ -114,8 +117,8 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     ResponseEntity<Object> getResponse = new ResponseEntity<>(returnedBody, HttpStatus.OK);
     when(restAdapter.get(eq(nearRtRicUrl.getValue()), eq(String.class))).thenReturn(getResponse);
     GetA1PolicyStatusOutput result = nonrtRicApiProvider.getA1PolicyStatus(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(HttpStatus.OK.value() == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(HTTP_OK_AS_INTEGER, result.getHttpStatus());
   }
 
   @Test
@@ -124,12 +127,12 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setNearRtRicUrl(nearRtRicUrl);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
     String returnedBody = "GET failed";
-    int returnedStatusCode = 404;
+    Integer notFoundStatusCode = HttpStatus.NOT_FOUND.value();
     when(restAdapter.get(eq(nearRtRicUrl.getValue()), eq(String.class)))
-    .thenThrow(new RestClientResponseException(null, returnedStatusCode, null, null, returnedBody.getBytes(), null));
+    .thenThrow(new RestClientResponseException(null, notFoundStatusCode, null, null, returnedBody.getBytes(), null));
     GetA1PolicyOutput result = nonrtRicApiProvider.getA1(inputBuilder.build());
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(returnedStatusCode == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(notFoundStatusCode, result.getHttpStatus());
   }
 
   @Test
@@ -140,11 +143,12 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setBody(testPolicy);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
     String returnedBody = "returned body";
+    Integer createdStatusCode = HttpStatus.CREATED.value();
     ResponseEntity<String> putResponse = new ResponseEntity<>(returnedBody, HttpStatus.CREATED);
     when(restAdapter.put(eq(nearRtRicUrl.getValue()), eq(testPolicy), eq(String.class))).thenReturn(putResponse);
     PutA1PolicyOutput result = nonrtRicApiProvider.putA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(HttpStatus.CREATED.value() == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(createdStatusCode, result.getHttpStatus());
   }
 
   @Test
@@ -155,12 +159,12 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setBody(testPolicy);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
     String returnedBody = "PUT failed";
-    int returnedStatusCode = 400;
+    Integer badRequestStatusCode = HttpStatus.BAD_REQUEST.value();
     when(restAdapter.put(eq(nearRtRicUrl.getValue()), eq(testPolicy), eq(String.class)))
-    .thenThrow(new RestClientResponseException(null, returnedStatusCode, null, null, returnedBody.getBytes(), null));
+    .thenThrow(new RestClientResponseException(null, badRequestStatusCode, null, null, returnedBody.getBytes(), null));
     PutA1PolicyOutput result = nonrtRicApiProvider.putA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(returnedStatusCode == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(badRequestStatusCode, result.getHttpStatus());
   }
 
   @Test
@@ -173,10 +177,10 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     ResponseEntity<Object> getResponseOk = new ResponseEntity<>(returnedBody, HttpStatus.OK);
     when(restAdapter.delete(nearRtRicUrl.getValue())).thenReturn(getResponseNoContent).thenReturn(getResponseOk);
     DeleteA1PolicyOutput resultNoContent = nonrtRicApiProvider.deleteA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertTrue(HttpStatus.NO_CONTENT.value() == resultNoContent.getHttpStatus());
+    assertEquals(Integer.valueOf(HttpStatus.NO_CONTENT.value()), resultNoContent.getHttpStatus());
     DeleteA1PolicyOutput resultOk = nonrtRicApiProvider.deleteA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, resultOk.getBody());
-    Assert.assertTrue(HttpStatus.OK.value() == resultOk.getHttpStatus());
+    assertEquals(returnedBody, resultOk.getBody());
+    assertEquals(HTTP_OK_AS_INTEGER, resultOk.getHttpStatus());
   }
 
   @Test
@@ -185,12 +189,12 @@ public class NonrtRicApiProviderTest extends AbstractConcurrentDataBrokerTest {
     inputBuilder.setNearRtRicUrl(nearRtRicUrl);
     Whitebox.setInternalState(nonrtRicApiProvider, "restAdapter", restAdapter);
     String returnedBody = "DELETE failed";
-    int returnedStatusCode = 404;
+    Integer notFoundStatusCode = HttpStatus.NOT_FOUND.value();
     when(restAdapter.delete(nearRtRicUrl.getValue()))
-    .thenThrow(new RestClientResponseException(null, returnedStatusCode, null, null, returnedBody.getBytes(), null));
+    .thenThrow(new RestClientResponseException(null, notFoundStatusCode, null, null, returnedBody.getBytes(), null));
     DeleteA1PolicyOutput result = nonrtRicApiProvider.deleteA1Policy(inputBuilder.build()).get().getResult();
-    Assert.assertEquals(returnedBody, result.getBody());
-    Assert.assertTrue(returnedStatusCode == result.getHttpStatus());
+    assertEquals(returnedBody, result.getBody());
+    assertEquals(notFoundStatusCode, result.getHttpStatus());
   }
 
 }
index 8e1d806..182d9f7 100644 (file)
 
 package org.o_ran_sc.nonrtric.sdnc_a1.northbound.restadapter;
 
+import static org.junit.Assert.assertEquals;
 import java.io.IOException;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.RestClientException;
-import okhttp3.mockwebserver.MockResponse;
-import okhttp3.mockwebserver.MockWebServer;
-import okhttp3.mockwebserver.RecordedRequest;
 
 public class RestAdapterImplTest {
     private static MockWebServer mockWebServer;
@@ -40,8 +40,8 @@ public class RestAdapterImplTest {
     private static final String INVALID_PROTOCOL = "ftp";
     private static final String REQUEST_URL = "/test";
     private static final String TEST_BODY = "test";
-    private static final int SUCCESS_CODE = 200;
-    private static final int ERROR_CODE = 500;
+    private static final Integer SUCCESS_CODE = 200;
+    private static final Integer ERROR_CODE = 500;
 
     @Before
     public void init() throws IOException {
@@ -59,10 +59,10 @@ public class RestAdapterImplTest {
     public void testInvalidUrlOrProtocol() throws InterruptedException {
         ResponseEntity<String> response = adapterUnderTest.get("://localhost:" + mockWebServer.getPort() + REQUEST_URL,
                 String.class);
-        Assert.assertTrue(HttpStatus.BAD_REQUEST.value() == response.getStatusCodeValue());
+        assertEquals(HttpStatus.BAD_REQUEST.value(), response.getStatusCodeValue());
         response = adapterUnderTest.get(INVALID_PROTOCOL + "://localhost:" + mockWebServer.getPort() + REQUEST_URL,
                 String.class);
-        Assert.assertTrue(HttpStatus.BAD_REQUEST.value() == response.getStatusCodeValue());
+        assertEquals(HttpStatus.BAD_REQUEST.value(), response.getStatusCodeValue());
     }
 
     @Test
@@ -71,10 +71,10 @@ public class RestAdapterImplTest {
         ResponseEntity<String> response = adapterUnderTest.get(VALID_PROTOCOL + "://localhost:"
                 + mockWebServer.getPort() + REQUEST_URL, String.class);
         RecordedRequest recordedRequest = mockWebServer.takeRequest();
-        Assert.assertEquals(TEST_BODY, response.getBody());
-        Assert.assertTrue(SUCCESS_CODE == response.getStatusCodeValue());
-        Assert.assertEquals("GET", recordedRequest.getMethod());
-        Assert.assertEquals(REQUEST_URL, recordedRequest.getPath());
+        assertEquals(TEST_BODY, response.getBody());
+        assertEquals(SUCCESS_CODE.intValue(), response.getStatusCodeValue());
+        assertEquals("GET", recordedRequest.getMethod());
+        assertEquals(REQUEST_URL, recordedRequest.getPath());
     }
 
     @Test(expected = RestClientException.class)
@@ -89,11 +89,11 @@ public class RestAdapterImplTest {
         ResponseEntity<String> response = adapterUnderTest.put(VALID_PROTOCOL + "://localhost:"
                 + mockWebServer.getPort() + REQUEST_URL, TEST_BODY, String.class);
         RecordedRequest recordedRequest = mockWebServer.takeRequest();
-        Assert.assertEquals(TEST_BODY, response.getBody());
-        Assert.assertTrue(SUCCESS_CODE == response.getStatusCodeValue());
-        Assert.assertEquals("PUT", recordedRequest.getMethod());
-        Assert.assertEquals(REQUEST_URL, recordedRequest.getPath());
-        Assert.assertEquals(TEST_BODY, recordedRequest.getBody().readUtf8());
+        assertEquals(TEST_BODY, response.getBody());
+        assertEquals(SUCCESS_CODE.intValue(), response.getStatusCodeValue());
+        assertEquals("PUT", recordedRequest.getMethod());
+        assertEquals(REQUEST_URL, recordedRequest.getPath());
+        assertEquals(TEST_BODY, recordedRequest.getBody().readUtf8());
     }
 
     @Test(expected = RestClientException.class)
@@ -109,9 +109,9 @@ public class RestAdapterImplTest {
         ResponseEntity<String> response = adapterUnderTest.delete(VALID_PROTOCOL + "://localhost:"
                 + mockWebServer.getPort() + REQUEST_URL);
         RecordedRequest recordedRequest = mockWebServer.takeRequest();
-        Assert.assertTrue(SUCCESS_CODE == response.getStatusCodeValue());
-        Assert.assertEquals("DELETE", recordedRequest.getMethod());
-        Assert.assertEquals(REQUEST_URL, recordedRequest.getPath());
+        assertEquals(SUCCESS_CODE.intValue(), response.getStatusCodeValue());
+        assertEquals("DELETE", recordedRequest.getMethod());
+        assertEquals(REQUEST_URL, recordedRequest.getPath());
     }
 
     @Test(expected = RestClientException.class)
index e6727c3..fed4727 100644 (file)
@@ -38,7 +38,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.northbound</groupId>
        <artifactId>sdnc-a1-northbound</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <properties>
index 1a2cc09..7ebda23 100644 (file)
@@ -30,7 +30,7 @@
     <packaging>pom</packaging>
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
     <artifactId>installation</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
 
     <name>sdnc-a1-oam :: installation</name>
     <description>Installs SDN-C on local file system</description>
index 27c89f7..9e1731a 100644 (file)
     <packaging>pom</packaging>
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
     <artifactId>installation-sdnc-a1</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
 
     <name>sdnc-a1-oam :: installation :: ${project.artifactId}</name>
     <description>Creates SDN Controller Docker container</description>
 
     <properties>
-        <standalone.image.name>o-ran-sc/nonrtric-a1-controller</standalone.image.name>
-       <standalone.image.version>1.7.4-SNAPSHOT</standalone.image.version>
-        <sdnc.project.version>${project.version}</sdnc.project.version>
-        <sdnc.build.timestamp>${maven.build.timestamp}</sdnc.build.timestamp>
-        <sdnc.northbound.version>1.7.3-SNAPSHOT</sdnc.northbound.version>
-        <ccsdk.docker.version>0.7.0</ccsdk.docker.version>
-        <docker.push.phase>deploy</docker.push.phase>
+     <standalone.image.name>o-ran-sc/nonrtric-a1-controller</standalone.image.name>
+     <standalone.image.version>1.7.5-SNAPSHOT</standalone.image.version>
+     <sdnc.project.version>${project.version}</sdnc.project.version>
+     <sdnc.build.timestamp>${maven.build.timestamp}</sdnc.build.timestamp>
+     <sdnc.northbound.version>1.7.5-SNAPSHOT</sdnc.northbound.version>
+     <ccsdk.docker.version>0.7.0</ccsdk.docker.version>
+     <docker.push.phase>deploy</docker.push.phase>
     </properties>
 
     <dependencies>
index 80262ff..03977f8 100755 (executable)
@@ -1,3 +1,20 @@
+#  ============LICENSE_START===============================================
+#  Modifications Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
 # Prepare stage for multistage image build
 ## START OF STAGE0 ##
 FROM nexus3.onap.org:10001/onap/ccsdk-odlsli-alpine-image:${ccsdk.docker.version} AS stage0
diff --git a/sdnc-a1-controller/oam/installation/src/main/properties/aaiclient.properties b/sdnc-a1-controller/oam/installation/src/main/properties/aaiclient.properties
deleted file mode 100755 (executable)
index 6568383..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
-#                                              reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-#
-# Configuration file for A&AI Client
-#
-
-#
-# Certificate keystore and truststore
-#
-org.onap.ccsdk.sli.adaptors.aai.ssl.trust=/opt/onap/sdnc/data/stores/truststoreONAPall.jks
-org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=changeit
-org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=true
-
-org.onap.ccsdk.sli.adaptors.aai.client.name=sdnc@sdnc.onap.org
-org.onap.ccsdk.sli.adaptors.aai.client.psswd=demo123456!
-
-org.onap.ccsdk.sli.adaptors.aai.application=openECOMP
-#
-# Configuration file for A&AI Client
-#
-org.onap.ccsdk.sli.adaptors.aai.uri=https://aai.api.simpledemo.openecomp.org:8443
-connection.timeout=60000
-read.timeout=60000
-
-# query
-org.onap.ccsdk.sli.adaptors.aai.path.query=/aai/v13/search/sdn-zone-query
-org.onap.ccsdk.sli.adaptors.aai.query.nodes=/aai/v13/search/nodes-query?search-node-type={node-type}&filter={entity-identifier}:EQUALS:{entity-name}
-org.onap.ccsdk.sli.adaptors.aai.query.generic=/aai/v13/search/generic-query?key={identifier}:{value}&start-node-type={start-node-type}&include=complex&depth=3
-
-# named query
-org.onap.ccsdk.sli.adaptors.aai.query.named=/aai/search/named-query
-
-#update
-org.onap.ccsdk.sli.adaptors.aai.update=/aai/v13/actions/update
-
-# UBB Notify
-org.onap.ccsdk.sli.adaptors.aai.path.notify=/aai/v13/actions/notify
-org.onap.ccsdk.sli.adaptors.aai.notify.selflink.fqdn=<%= @ubbUri %>/restconf/config/L3SDN-API:services/layer3-service-list/{service-instance-id}
-org.onap.ccsdk.sli.adaptors.aai.notify.selflink.avpn=<%= @ubbUri %>/restconf/config/L3AVPN-EVC-API:services/service-list/{service-instance-id}/service-data/avpn-logicalchannel-information
-
-# P-Interfaces
-org.onap.ccsdk.sli.adaptors.aai.path.pserver.pinterfaces=/aai/v13/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces
-org.onap.ccsdk.sli.adaptors.aai.path.pserver.pinterface=/aai/v13/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces/p-interface/{interface-name}
-
-# VNF IMAGES
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.images=/aai/v13/service-design-and-creation/vnf-images
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image=/aai/v13/service-design-and-creation/vnf-images/vnf-image/{att-uuid}
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image.query=/aai/v13/service-design-and-creation/vnf-images/vnf-image?application={application_model}&application-vendor={application_vendor}
-
-# service instance
-org.onap.ccsdk.sli.adaptors.aai.path.svcinst.query=/aai/v13/search/generic-query?key=service-instance.service-instance-id:{svc-instance-id}&start-node-type=service-instance&include=service-instance
-org.onap.ccsdk.sli.adaptors.aai.path.service.instance=/aai/v13/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}
-
-# VNF IMAGES QUERY
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image.query=/aai/v13/service-design-and-creation/vnf-images/vnf-image?application={application_model}&application-vendor={application_vendor}
-
-#
-# Formatting
-#
-org.onap.ccsdk.sli.adaptors.aai.param.format=filter=%s:%s
-org.onap.ccsdk.sli.adaptors.aai.param.vnf_type=vnf-type
-org.onap.ccsdk.sli.adaptors.aai.param.physical.location.id=physical-location-id
-org.onap.ccsdk.sli.adaptors.aai.param.service.type=service-type
diff --git a/sdnc-a1-controller/oam/installation/src/main/properties/blueprints-processor-adaptor.properties b/sdnc-a1-controller/oam/installation/src/main/properties/blueprints-processor-adaptor.properties
deleted file mode 100644 (file)
index a3dcf67..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-###
-# Copyright � 2017-2018 AT&T Intellectual Property.
-# Modifications Copyright � 2018 IBM.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###
-#
-# Configuration file for SDNC Controller Module
-#
-
-org.onap.ccsdk.features.blueprints.adaptors.envtype=solo
-
-# Config Generator Microservices
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.url=http://controller-blueprints:8080/api/v1/
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.user=ccsdkapps
-org.onap.ccsdk.features.blueprints.adaptors.modelservice.passwd=ccsdkapps
-
-# Generic RESTCONF Adaptor
-org.onap.ccsdk.features.blueprints.adaptors.restconf.type=generic
-org.onap.ccsdk.features.blueprints.adaptors.restconf.enable=true
-org.onap.ccsdk.features.blueprints.adaptors.restconf.user=admin
-org.onap.ccsdk.features.blueprints.adaptors.restconf.passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.ccsdk.features.blueprints.adaptors.restconf.url=http://sdnc:8282/restconf/
index 7051351..c7244f7 100644 (file)
@@ -38,7 +38,7 @@ services:
         max-file: "5"
 
   a1-controller:
-    image: o-ran-sc/nonrtric-a1-controller:1.7.4-SNAPSHOT
+    image: o-ran-sc/nonrtric-a1-controller:1.7.5-SNAPSHOT
     depends_on :
       - db
     container_name: a1-controller-container
index 99df343..fb55685 100644 (file)
@@ -30,7 +30,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
        <artifactId>platform-logic-installer</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-oam :: platform-logic :: ${project.artifactId}</name>
index 8589699..f796613 100644 (file)
@@ -30,7 +30,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
     <artifactId>platform-logic</artifactId>
-    <version>1.7.3-SNAPSHOT</version>
+    <version>1.7.5-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>sdnc-a1-oam :: platform-logic</name>
index 8c5f5cd..6f6cc71 100644 (file)
@@ -30,7 +30,7 @@
 
     <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
        <artifactId>platform-logic-setup</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
     <name>sdnc-a1-oam :: platform-logic :: ${project.artifactId}</name>
index dde8891..9e716c8 100755 (executable)
@@ -1,5 +1,22 @@
 #! /bin/bash
 
+#  ============LICENSE_START===============================================
+#  Modifications Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
 updateFile() {
 sed  -i .orig -e '
 s/openecomp.org/onap.org/g
index 2fd0e36..9bc70ed 100755 (executable)
@@ -1,5 +1,22 @@
 #! /bin/bash
 
+#  ============LICENSE_START===============================================
+#  Modifications Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
 updateFile() {
 sed  -i .orig -e '
 s/\(plugin=.\)org.openecomp.sdnc.\(prop\)/\org.onap.ccsdk.sli.plugins.\2/g
index 14c7ce6..eb8a720 100755 (executable)
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1.oam</groupId>
        <artifactId>sdnc-a1-oam</artifactId>
-       <version>1.7.3-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1-oam</name>
        <description>The SDN-C OAM component contains the components needed to operate, administer and maintain the SDN-C platform.</description>
-       <url>https://wiki.onap.org</url>
-       <organization>
-               <name>AT&amp;T</name>
-       </organization>
 
        <modules>
                <module>platform-logic</module>
index 96ca1a5..daca84c 100644 (file)
@@ -25,7 +25,7 @@
 
        <groupId>org.o-ran-sc.nonrtric.sdnc-a1</groupId>
        <artifactId>sdnc-a1</artifactId>
-       <version>1.7.4-SNAPSHOT</version>
+       <version>1.7.5-SNAPSHOT</version>
        <packaging>pom</packaging>
 
        <name>sdnc-a1</name>
index 6f96355..8c8ffd0 100644 (file)
@@ -81,4 +81,19 @@ store_logs          END
 -----------------------------------------------------------
 
 The ../common/testcase_common.sh contains all functions needed for the test case file. See the README.md file in
-the ../common dir for a description of all available functions.
\ No newline at end of file
+the ../common dir for a description of all available functions.
+
+## License
+
+Copyright (C) 2020 Nordix Foundation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
index d57133d..1723555 100755 (executable)
@@ -1,5 +1,22 @@
 #!/bin/bash
 
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
 TS_ONELINE_DESCR="Test suite - interface testing. Agent REST, DMAAP and SNDC controller resconf"
 
 . ../common/testsuite_common.sh
index 6defc8d..dd1ddf3 100644 (file)
@@ -30,3 +30,18 @@ Store all Policy Agent app and simulators log to the test case log dir. All logs
 separate logs stored at different steps in the test script.
 If logs need to be stored in several locations, use different prefix to easily identify the location
 when the logs where taken.
+
+## License
+
+Copyright (C) 2020 Nordix Foundation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
index 74205f4..31dae4c 100644 (file)
@@ -41,4 +41,19 @@ The script ```crstub-build-start.sh``` do the above two steps in one go. This st
 
 ### Basic test ###
 
-Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```cr-build-start.sh``` to start the callback-receiver in a container first.
\ No newline at end of file
+Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```cr-build-start.sh``` to start the callback-receiver in a container first.
+
+## License
+
+Copyright (C) 2020 Nordix Foundation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
index 9a15bc3..07101ad 100644 (file)
@@ -18,6 +18,7 @@
 FROM python:3.8-slim-buster
 
 COPY app/ /usr/src/app/
+COPY cert/ /usr/src/app/cert/
 
 WORKDIR /usr/src/app/
 
index f6d0dde..e8e8edf 100644 (file)
@@ -65,7 +65,24 @@ There are a number of counters that can be read to monitor the message processin
 ```docker run -it -p 3905:3905 mrstub```
 
 >Start the image on http and https<br>
+By default, this image has default certificates under /usr/src/app/cert
+file "cert.crt" is the certificate file
+file "key.crt" is the key file
+file "generate_cert_and_key.sh" is a shell script to generate certificate and key
+file "pass" stores the password when you run the shell script
+
+Start the a1-interface container without specifing external certificates:
+```docker run -it -p 3905:3905 -p 3906:3906 mrstub```
+
+It will listen to http 3905 port and https 3906 port(using default certificates) at the same time.
+
+This certificates/key can be overriden by mounting a volume when using "docker run" or "docker-compose"
+In 'docker run', use field:
+--volume "$PWD/certificate:/usr/src/app/cert" a1test
 ```docker run -it -p 3905:3905 -p 3906:3906 -v "/PATH_TO_CERT/cert:/usr/src/app/cert" mrstub```
+In 'docker-compose.yml', use field:
+volumes:
+      - ./certificate:/usr/src/app/cert:ro
 
 The script ```mrstub-build-start.sh``` do the build and docker run in one go. This starts the stub container in stand-alone mode for basic test.<br>If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams).
 ```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
@@ -73,4 +90,19 @@ The script ```mrstub-build-start.sh``` do the build and docker run in one go. Th
 
 ### Basic test ###
 
-Basic test is made with the script ```basic_test.sh nonsecure|secure``` which tests all the available urls with a subset of the possible operations. Choose nonsecure for http and secure for https. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
\ No newline at end of file
+Basic test is made with the script ```basic_test.sh nonsecure|secure``` which tests all the available urls with a subset of the possible operations. Choose nonsecure for http and secure for https. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
+
+## License
+
+Copyright (C) 2020 Nordix Foundation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/test/mrstub/cert/generate_cert_and_key.sh b/test/mrstub/cert/generate_cert_and_key.sh
new file mode 100755 (executable)
index 0000000..0f79bbf
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#  ============LICENSE_START===============================================
+#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  ========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END=================================================
+#
+
+# This will generate a self-signed certificate with password 'test'
+openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999