diff options
81 files changed, 2134 insertions, 2194 deletions
@@ -1,7 +1,7 @@ --- project: 'ccsdk-oran' project_creation_date: '2018-07-04' -lifecycle_state: 'Incubation' +lifecycle_state: 'Mature' project_category: '' project_lead: &onap_releng_ptl name: 'Dan Timoney' diff --git a/a1-adapter/a1-adapter-api/feature/pom.xml b/a1-adapter/a1-adapter-api/feature/pom.xml index cc4c681e..9c7c4a63 100644 --- a/a1-adapter/a1-adapter-api/feature/pom.xml +++ b/a1-adapter/a1-adapter-api/feature/pom.xml @@ -19,6 +19,7 @@ ~ ============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> @@ -37,12 +38,10 @@ <name>ccsdk-oran :: ${project.artifactId}</name> <dependencies> - <dependency> <groupId>${project.groupId}</groupId> <artifactId>a1-adapter-provider</artifactId> <version>${project.version}</version> </dependency> - </dependencies> </project>
\ No newline at end of file diff --git a/a1-adapter/a1-adapter-api/installer/pom.xml b/a1-adapter/a1-adapter-api/installer/pom.xml index 2e55f7d1..d7d944bf 100644 --- a/a1-adapter/a1-adapter-api/installer/pom.xml +++ b/a1-adapter/a1-adapter-api/installer/pom.xml @@ -19,6 +19,7 @@ ~ ============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> @@ -42,7 +43,6 @@ </properties> <dependencies> - <dependency> <groupId>org.onap.ccsdk.oran</groupId> <artifactId>${application.name}-feature</artifactId> @@ -56,13 +56,11 @@ </exclusion> </exclusions> </dependency> - <dependency> <groupId>${project.groupId}</groupId> <artifactId>a1-adapter-provider</artifactId> <version>${project.version}</version> </dependency> - </dependencies> <build> diff --git a/a1-adapter/a1-adapter-api/model/pom.xml b/a1-adapter/a1-adapter-api/model/pom.xml index 7aa386e5..34ad93d8 100644 --- a/a1-adapter/a1-adapter-api/model/pom.xml +++ b/a1-adapter/a1-adapter-api/model/pom.xml @@ -19,60 +19,66 @@ ~ ============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> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>binding-parent</artifactId> - <version>2.0.1-SNAPSHOT</version> - <relativePath /> - </parent> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>a1-adapter-model</artifactId> - <version>1.0.0-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>ccsdk-oran :: ${project.artifactId}</name> - <dependencies> - <dependency> - <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> - <artifactId>rfc6991</artifactId> - </dependency> - </dependencies> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>org.codehaus.mojo</groupId> - <artifactId>properties-maven-plugin</artifactId> - <versionRange>[1.0.0,)</versionRange> - <goals> - <goal>set-system-properties</goal> - </goals> - </pluginExecutionFilter> - <action> - <execute /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <source>8</source> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>binding-parent</artifactId> + <version>2.0.1-SNAPSHOT</version> + <relativePath/> + </parent> + + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>a1-adapter-model</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>bundle</packaging> + + <name>ccsdk-oran :: ${project.artifactId}</name> + + <dependencies> + <dependency> + <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> + <artifactId>rfc6991</artifactId> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <versionRange>[1.0.0,)</versionRange> + <goals> + <goal>set-system-properties</goal> + </goals> + </pluginExecutionFilter> + <action> + <execute/> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <source>8</source> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> </project>
\ No newline at end of file diff --git a/a1-adapter/a1-adapter-api/pom.xml b/a1-adapter/a1-adapter-api/pom.xml index c1176eb2..3ec20c35 100644 --- a/a1-adapter/a1-adapter-api/pom.xml +++ b/a1-adapter/a1-adapter-api/pom.xml @@ -19,36 +19,42 @@ ~ ============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> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent-lite</artifactId> - <version>2.0.1-SNAPSHOT</version> - <relativePath /> - </parent> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>a1-adapter-api</artifactId> - <version>1.0.0-SNAPSHOT</version> - <packaging>pom</packaging> - <name>ccsdk-oran :: ${project.artifactId}</name> - <properties> - <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version> - </properties> - <modules> - <module>model</module> - <module>provider</module> - <module>feature</module> - <module>installer</module> - </modules> - <build> - <plugins> - <!-- support sonar in multi-module project --> - <plugin> - <groupId>org.sonarsource.scanner.maven</groupId> - <artifactId>sonar-maven-plugin</artifactId> - <version>${sonar-maven-plugin.version}</version> - </plugin> - </plugins> - </build> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent-lite</artifactId> + <version>2.0.1-SNAPSHOT</version> + <relativePath/> + </parent> + + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>a1-adapter-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <name>ccsdk-oran :: ${project.artifactId}</name> + + <properties> + <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version> + </properties> + + <modules> + <module>model</module> + <module>provider</module> + <module>feature</module> + <module>installer</module> + </modules> + + <build> + <plugins> + <!-- support sonar in multi-module project --> + <plugin> + <groupId>org.sonarsource.scanner.maven</groupId> + <artifactId>sonar-maven-plugin</artifactId> + <version>${sonar-maven-plugin.version}</version> + </plugin> + </plugins> + </build> </project>
\ No newline at end of file diff --git a/a1-adapter/a1-adapter-api/provider/pom.xml b/a1-adapter/a1-adapter-api/provider/pom.xml index 15af2820..f1cb7401 100644 --- a/a1-adapter/a1-adapter-api/provider/pom.xml +++ b/a1-adapter/a1-adapter-api/provider/pom.xml @@ -36,14 +36,9 @@ <packaging>bundle</packaging> <name>ccsdk-oran :: ${project.artifactId}</name> + <properties> - <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version> - <!-- Override the snapshot version from parent pom --> - <ccsdk.features.version>1.0.0</ccsdk.features.version> - <ccsdk.sli.core.version>1.0.0</ccsdk.sli.core.version> - <ccsdk.sli.adaptors.version>1.0.0</ccsdk.sli.adaptors.version> - <ccsdk.sli.northbound.version>1.0.0</ccsdk.sli.northbound.version> - <ccsdk.sli.plugins.version>1.0.0</ccsdk.sli.plugins.version> + <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version> </properties> <dependencyManagement> @@ -55,7 +50,6 @@ <type>pom</type> <scope>import</scope> </dependency> - <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> <artifactId>sli-core-artifacts</artifactId> @@ -63,9 +57,9 @@ <type>pom</type> <scope>import</scope> </dependency> - </dependencies> </dependencyManagement> + <dependencies> <dependency> <groupId>org.onap.ccsdk.oran</groupId> @@ -113,7 +107,6 @@ <artifactId>utils-provider</artifactId> <!-- <version>${sdnctl.sli.version}</version> --> </dependency> - </dependencies> <build> @@ -144,12 +137,12 @@ </configuration> </plugin> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <source>8</source> - </configuration> - </plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <source>8</source> + </configuration> + </plugin> </plugins> </pluginManagement> </build> diff --git a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClient.java b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClient.java index f1b2eaee..2cf63b3c 100644 --- a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClient.java +++ b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClient.java @@ -34,6 +34,9 @@ import org.slf4j.LoggerFactory; public class A1AdapterClient { + private static final String PARAMETERS_PASSED_TO_SLI = "Parameters passed to SLI"; + private static final String PARAMETERS_RETURNED_BY_SLI = "Parameters returned by SLI"; + private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class); private SvcLogicService svcLogicService = null; @@ -51,23 +54,11 @@ public class A1AdapterClient { Properties localProp; localProp = MdsalHelper.toProperties(parms, serviceData); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_PASSED_TO_SLI, localProp); } Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_RETURNED_BY_SLI, localProp); } if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return respProps; @@ -81,23 +72,11 @@ public class A1AdapterClient { Properties localProp; localProp = MdsalHelper.toProperties(parms, serviceData); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_PASSED_TO_SLI, localProp); } Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_RETURNED_BY_SLI, localProp); } if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return respProps; @@ -111,23 +90,11 @@ public class A1AdapterClient { Properties localProp; localProp = MdsalHelper.toProperties(parms, serviceData); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_PASSED_TO_SLI, localProp); } Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_RETURNED_BY_SLI, localProp); } if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return respProps; @@ -141,23 +108,11 @@ public class A1AdapterClient { Properties localProp; localProp = MdsalHelper.toProperties(parms, serviceData); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_PASSED_TO_SLI, localProp); } Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_RETURNED_BY_SLI, localProp); } if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return respProps; @@ -171,23 +126,11 @@ public class A1AdapterClient { Properties localProp; localProp = MdsalHelper.toProperties(parms, serviceData); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters passed to SLI"); - - for (Object key : localProp.keySet()) { - String parmName = (String) key; - String parmValue = localProp.getProperty(parmName); - - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_PASSED_TO_SLI, localProp); } Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp); if (LOG.isDebugEnabled()) { - LOG.debug("Parameters returned by SLI"); - for (Object key : respProps.keySet()) { - String parmName = (String) key; - String parmValue = respProps.getProperty(parmName); - LOG.debug(parmName + " = " + parmValue); - } + logParameters(PARAMETERS_RETURNED_BY_SLI, localProp); } if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return respProps; @@ -195,4 +138,15 @@ public class A1AdapterClient { MdsalHelper.toBuilder(respProps, serviceData); return respProps; } + + private void logParameters(String message, Properties localProp) { + LOG.debug(message); + + for (Object key : localProp.keySet()) { + String parmName = (String) key; + String parmValue = localProp.getProperty(parmName); + + LOG.debug("{}={}", parmName, parmValue); + } + } } diff --git a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java index 369f583b..e1c151a3 100644 --- a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java +++ b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java @@ -65,6 +65,17 @@ import org.slf4j.LoggerFactory; @SuppressWarnings("squid:S1874") // "@Deprecated" code should not be used public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { + private static final String A1_ADAPTER_API = "A1-ADAPTER-API"; + private static final String RESPONSE_BODY = "responseBody"; + private static final String RESPONSE_CODE = "response-code"; + private static final String SYNC = "sync"; + + private static final String ADDING_INPUT_DATA_MESSAGE = "Adding INPUT data for {} input: {}"; + private static final String A1_ADAPTER_CLIENT_GRAPH_MESSAGE = "A1AdapterClient has a Directed Graph for '{}'"; + private static final String SERVICE_EXCEPTION_MESSAGE = "Caught exception executing service logic for {}, {}"; + private static final String NO_SERVICE_LOGIC_ACTIVE_MESSAGE = "No service logic active for A1Adapter: '{}'"; + private static final String LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE = "Caught exception looking for service logic, {}"; + private static final Logger log = LoggerFactory.getLogger(A1AdapterProvider.class); private static final String APPLICATION_NAME = "a1Adapter-api"; @@ -113,35 +124,28 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { Properties parms = new Properties(); DeleteA1PolicyOutputBuilder deleteResponse = new DeleteA1PolicyOutputBuilder(); // add input to parms - log.info("Adding INPUT data for " + svcOperation + " input: " + input); + log.info(ADDING_INPUT_DATA_MESSAGE, svcOperation, input); DeleteA1PolicyInputBuilder inputBuilder = new DeleteA1PolicyInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); - log.info("Printing SLI parameters to be passed"); - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - log.info("The SLI parameter in " + key + " is: " + value); - } + logSliParameters(parms); // Call SLI sync method try { - if (a1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) { - log.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'"); + if (a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC)) { + log.info(A1_ADAPTER_CLIENT_GRAPH_MESSAGE, svcOperation); try { - Properties responseParms = a1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", deleteResponse, parms); - log.info("responseBody::"+responseParms.getProperty("responseBody")); - log.info("responseCode::"+responseParms.getProperty("response-code")); - log.info("responseMessage::"+responseParms.getProperty("response-message")); - deleteResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty("response-code"))); + Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, deleteResponse, parms); + logResponse(responseParms); + deleteResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); } catch (Exception e) { - log.error("Caught exception executing service logic for " + svcOperation, e); + log.error(SERVICE_EXCEPTION_MESSAGE, svcOperation, e.getMessage()); deleteResponse.setHttpStatus(500); } } else { - log.error("No service logic active for A1Adapter: '" + svcOperation + "'"); + log.error(NO_SERVICE_LOGIC_ACTIVE_MESSAGE, svcOperation); deleteResponse.setHttpStatus(503); } } catch (Exception e) { - log.error("Caught exception looking for service logic", e); + log.error(LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE, e.getMessage()); deleteResponse.setHttpStatus(500); } RpcResult<DeleteA1PolicyOutput> rpcResult = @@ -157,36 +161,29 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { Properties parms = new Properties(); GetA1PolicyOutputBuilder policyResponse = new GetA1PolicyOutputBuilder(); // add input to parms - log.info("Adding INPUT data for " + svcOperation + " input: " + input); + log.info(ADDING_INPUT_DATA_MESSAGE, svcOperation, input); GetA1PolicyInputBuilder inputBuilder = new GetA1PolicyInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); - log.info("Printing SLI parameters to be passed"); - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - log.info("The SLI parameter in " + key + " is: " + value); - } + logSliParameters(parms); // Call SLI sync method try { - if (a1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) { - log.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'"); + if (a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC)) { + log.info(A1_ADAPTER_CLIENT_GRAPH_MESSAGE, svcOperation); try { - Properties responseParms = a1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", policyResponse, parms); - log.info("responseBody::"+responseParms.getProperty("responseBody")); - policyResponse.setBody(responseParms.getProperty("responseBody")); - log.info("responseCode::"+responseParms.getProperty("response-code")); - log.info("responseMessage::"+responseParms.getProperty("response-message")); - policyResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty("response-code"))); + Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, policyResponse, parms); + logResponse(responseParms); + policyResponse.setBody(responseParms.getProperty(RESPONSE_BODY)); + policyResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); } catch (Exception e) { - log.error("Caught exception executing service logic for " + svcOperation, e); + log.error(SERVICE_EXCEPTION_MESSAGE, svcOperation, e.getMessage()); policyResponse.setHttpStatus(500); } } else { - log.error("No service logic active for A1Adapter: '" + svcOperation + "'"); + log.error(NO_SERVICE_LOGIC_ACTIVE_MESSAGE, svcOperation); policyResponse.setHttpStatus(503); } } catch (Exception e) { - log.error("Caught exception looking for service logic", e); + log.error(LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE, e.getMessage()); policyResponse.setHttpStatus(500); } RpcResult<GetA1PolicyOutput> rpcResult = @@ -202,36 +199,29 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { Properties parms = new Properties(); GetA1PolicyStatusOutputBuilder policyStatusResponse = new GetA1PolicyStatusOutputBuilder(); // add input to parms - log.info("Adding INPUT data for " + svcOperation + " input: " + input); + log.info(ADDING_INPUT_DATA_MESSAGE, svcOperation, input); GetA1PolicyStatusInputBuilder inputBuilder = new GetA1PolicyStatusInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); - log.info("Printing SLI parameters to be passed"); - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - log.info("The SLI parameter in " + key + " is: " + value); - } + logSliParameters(parms); // Call SLI sync method try { - if (a1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) { - log.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'"); + if (a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC)) { + log.info(A1_ADAPTER_CLIENT_GRAPH_MESSAGE, svcOperation); try { - Properties responseParms = a1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", policyStatusResponse, parms); - log.info("responseBody::"+responseParms.getProperty("responseBody")); - policyStatusResponse.setBody(responseParms.getProperty("responseBody")); - log.info("responseCode::"+responseParms.getProperty("response-code")); - log.info("responseMessage::"+responseParms.getProperty("response-message")); - policyStatusResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty("response-code"))); + Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, policyStatusResponse, parms); + logResponse(responseParms); + policyStatusResponse.setBody(responseParms.getProperty(RESPONSE_BODY)); + policyStatusResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); } catch (Exception e) { - log.error("Caught exception executing service logic for " + svcOperation, e); + log.error(SERVICE_EXCEPTION_MESSAGE, svcOperation, e.getMessage()); policyStatusResponse.setHttpStatus(500); } } else { - log.error("No service logic active for A1Adapter: '" + svcOperation + "'"); + log.error(NO_SERVICE_LOGIC_ACTIVE_MESSAGE, svcOperation); policyStatusResponse.setHttpStatus(503); } } catch (Exception e) { - log.error("Caught exception looking for service logic", e); + log.error(LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE, e.getMessage()); policyStatusResponse.setHttpStatus(500); } RpcResult<GetA1PolicyStatusOutput> rpcResult = @@ -247,36 +237,29 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { Properties parms = new Properties(); GetA1PolicyTypeOutputBuilder policyTypeResponse = new GetA1PolicyTypeOutputBuilder(); // add input to parms - log.info("Adding INPUT data for " + svcOperation + " input: " + input); + log.info(ADDING_INPUT_DATA_MESSAGE, svcOperation, input); GetA1PolicyTypeInputBuilder inputBuilder = new GetA1PolicyTypeInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); - log.info("Printing SLI parameters to be passed"); - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - log.info("The SLI parameter in " + key + " is: " + value); - } + logSliParameters(parms); // Call SLI sync method try { - if (a1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) { - log.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'"); + if (a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC)) { + log.info(A1_ADAPTER_CLIENT_GRAPH_MESSAGE, svcOperation); try { - Properties responseParms = a1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", policyTypeResponse, parms); - log.info("responseBody::"+responseParms.getProperty("responseBody")); - policyTypeResponse.setBody(responseParms.getProperty("responseBody")); - log.info("responseCode::"+responseParms.getProperty("response-code")); - log.info("responseMessage::"+responseParms.getProperty("response-message")); - policyTypeResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty("response-code"))); + Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, policyTypeResponse, parms); + logResponse(responseParms); + policyTypeResponse.setBody(responseParms.getProperty(RESPONSE_BODY)); + policyTypeResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); } catch (Exception e) { - log.error("Caught exception executing service logic for " + svcOperation, e); + log.error(SERVICE_EXCEPTION_MESSAGE, svcOperation, e.getMessage()); policyTypeResponse.setHttpStatus(500); } } else { - log.error("No service logic active for A1Adapter: '" + svcOperation + "'"); + log.error(NO_SERVICE_LOGIC_ACTIVE_MESSAGE, svcOperation); policyTypeResponse.setHttpStatus(503); } } catch (Exception e) { - log.error("Caught exception looking for service logic", e); + log.error(LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE, e.getMessage()); policyTypeResponse.setHttpStatus(500); } RpcResult<GetA1PolicyTypeOutput> rpcResult = @@ -292,36 +275,29 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { Properties parms = new Properties(); PutA1PolicyOutputBuilder policyResponse = new PutA1PolicyOutputBuilder(); // add input to parms - log.info("Adding INPUT data for " + svcOperation + " input: " + input); + log.info(ADDING_INPUT_DATA_MESSAGE, svcOperation, input); PutA1PolicyInputBuilder inputBuilder = new PutA1PolicyInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); - log.info("Printing SLI parameters to be passed"); - // iterate properties file to get key-value pairs - for (String key : parms.stringPropertyNames()) { - String value = parms.getProperty(key); - log.info("The SLI parameter in " + key + " is: " + value); - } + logSliParameters(parms); // Call SLI sync method try { - if (a1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) { - log.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'"); + if (a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC)) { + log.info(A1_ADAPTER_CLIENT_GRAPH_MESSAGE, svcOperation); try { - Properties responseParms = a1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", policyResponse, parms); - log.info("responseBody::"+responseParms.getProperty("responseBody")); - policyResponse.setBody(responseParms.getProperty("responseBody")); - log.info("responseCode::"+responseParms.getProperty("response-code")); - log.info("responseMessage::"+responseParms.getProperty("response-message")); - policyResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty("response-code"))); + Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, policyResponse, parms); + logResponse(responseParms); + policyResponse.setBody(responseParms.getProperty(RESPONSE_BODY)); + policyResponse.setHttpStatus(Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); } catch (Exception e) { - log.error("Caught exception executing service logic for " + svcOperation, e); + log.error(SERVICE_EXCEPTION_MESSAGE, svcOperation, e.getMessage()); policyResponse.setHttpStatus(500); } } else { - log.error("No service logic active for A1Adapter: '" + svcOperation + "'"); + log.error(NO_SERVICE_LOGIC_ACTIVE_MESSAGE, svcOperation); policyResponse.setHttpStatus(503); } } catch (Exception e) { - log.error("Caught exception looking for service logic", e); + log.error(LOOKUP_SERVICE_LOGIC_EXCEPTION_MESSAGE, e.getMessage()); policyResponse.setHttpStatus(500); } RpcResult<PutA1PolicyOutput> rpcResult = @@ -330,4 +306,18 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { return Futures.immediateFuture(rpcResult); } + private void logSliParameters(Properties parms) { + log.info("Printing SLI parameters to be passed"); + // iterate properties file to get key-value pairs + for (String key : parms.stringPropertyNames()) { + String value = parms.getProperty(key); + log.info("The SLI parameter in {} is: {}", key, value); + } + } + + private void logResponse(Properties responseParms) { + log.info("responseBody::{}", responseParms.getProperty(RESPONSE_BODY)); + log.info("responseCode::{}", responseParms.getProperty(RESPONSE_CODE)); + log.info("responseMessage::{}", responseParms.getProperty("response-message")); + } } diff --git a/a1-adapter/features/a1-adapter-northbound/pom.xml b/a1-adapter/features/a1-adapter-northbound/pom.xml index 57d82cc2..a0ee8260 100644 --- a/a1-adapter/features/a1-adapter-northbound/pom.xml +++ b/a1-adapter/features/a1-adapter-northbound/pom.xml @@ -19,27 +19,30 @@ ~ ============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> - <parent> + <modelVersion>4.0.0</modelVersion> + <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> <version>2.0.1-SNAPSHOT</version> <relativePath/> - </parent> + </parent> <groupId>org.onap.ccsdk.oran</groupId> <artifactId>a1-adapter-northbound</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>feature</packaging> + <name>ccsdk-oran :: ${project.artifactId}</name> + <dependencies> - <dependency> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>a1-adapter-feature</artifactId> + <dependency> + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>a1-adapter-feature</artifactId> <version>${project.version}</version> <type>xml</type> <classifier>features</classifier> - </dependency> - </dependencies> + </dependency> + </dependencies> </project>
\ No newline at end of file diff --git a/a1-adapter/features/installer/pom.xml b/a1-adapter/features/installer/pom.xml index f83849ee..230a5f91 100644 --- a/a1-adapter/features/installer/pom.xml +++ b/a1-adapter/features/installer/pom.xml @@ -19,47 +19,48 @@ ~ ============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> + <modelVersion>4.0.0</modelVersion> - <parent> + <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> <version>2.0.1-SNAPSHOT</version> <relativePath/> </parent> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>a1-adapter-northbound-installer</artifactId> - <version>1.0.0-SNAPSHOT</version> - <packaging>pom</packaging> + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>a1-adapter-northbound-installer</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> - <name>ccsdk-oran :: ${project.artifactId}</name> + <name>ccsdk-oran :: ${project.artifactId}</name> - <properties> - <application.name>a1-adapter-northbound</application.name> - <features.boot>${application.name}</features.boot> - <features.repositories>mvn:org.onap.ccsdk.oran/${features.boot}/${project.version}/xml/features</features.repositories> - <include.transitive.dependencies>false</include.transitive.dependencies> - </properties> + <properties> + <application.name>a1-adapter-northbound</application.name> + <features.boot>${application.name}</features.boot> + <features.repositories>mvn:org.onap.ccsdk.oran/${features.boot}/${project.version}/xml/features</features.repositories> + <include.transitive.dependencies>false</include.transitive.dependencies> + </properties> - <dependencies> - <dependency> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>${application.name}</artifactId> - <version>${project.version}</version> - <type>xml</type> - <classifier>features</classifier> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>${application.name}</artifactId> + <version>${project.version}</version> + <type>xml</type> + <classifier>features</classifier> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> - <build> + <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/a1-adapter/features/pom.xml b/a1-adapter/features/pom.xml index 5efa09c7..18efc2b9 100644 --- a/a1-adapter/features/pom.xml +++ b/a1-adapter/features/pom.xml @@ -19,24 +19,25 @@ ~ ============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> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>odlparent-lite</artifactId> - <version>2.0.1-SNAPSHOT</version> - <relativePath/> - </parent> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent-lite</artifactId> + <version>2.0.1-SNAPSHOT</version> + <relativePath/> + </parent> - <groupId>org.onap.ccsdk.oran</groupId> - <artifactId>ccsdk-a1-adapter-feature-aggregator</artifactId> - <version>1.0.0-SNAPSHOT</version> - <packaging>pom</packaging> + <groupId>org.onap.ccsdk.oran</groupId> + <artifactId>ccsdk-a1-adapter-feature-aggregator</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> - <name>ccsdk-oran :: ${project.artifactId}</name> + <name>ccsdk-oran :: ${project.artifactId}</name> - <modules> + <modules> <module>a1-adapter-northbound</module> <module>installer</module> </modules> diff --git a/a1-adapter/pom.xml b/a1-adapter/pom.xml index c3ecfe9d..83532721 100644 --- a/a1-adapter/pom.xml +++ b/a1-adapter/pom.xml @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- ~ ============LICENSE_START======================================================= ~ ONAP : ccsdk oran @@ -18,17 +19,26 @@ ~ ============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> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent-lite</artifactId> + <version>2.0.1-SNAPSHOT</version> + <relativePath/> + </parent> + <groupId>org.onap.ccsdk.oran</groupId> <artifactId>ccsdk-a1-adapter</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <name>ccsdk-oran :: ${project.artifactId}</name> + <modules> - <module>a1-adapter-api</module> - <module>features</module> - </modules> + <module>a1-adapter-api</module> + <module>features</module> + </modules> </project>
\ No newline at end of file diff --git a/a1-policy-management/api/api.yaml b/a1-policy-management/api/api.yaml index b41d4fc0..ac10f4b6 100644 --- a/a1-policy-management/api/api.yaml +++ b/a1-policy-management/api/api.yaml @@ -76,7 +76,7 @@ paths: parameters: - name: id in: query - description: The ID of the policy instance. + description: The identity of the policy instance. required: true allowEmptyValue: false schema: @@ -110,7 +110,7 @@ paths: parameters: - name: id in: query - description: The ID of the policy instance. + description: The identity of the policy instance. required: true allowEmptyValue: false schema: @@ -184,7 +184,7 @@ paths: parameters: - name: id in: query - description: The ID of the policy instance. + description: The identity of the policy instance. required: true allowEmptyValue: false schema: @@ -268,7 +268,7 @@ paths: parameters: - name: id in: query - description: The ID of the policy type to get the definition for. + description: The identity of the policy type to get the definition for. required: true allowEmptyValue: false schema: @@ -386,7 +386,7 @@ paths: parameters: - name: id in: query - description: The ID of the policy. + description: The identity of the policy. required: true allowEmptyValue: false schema: @@ -461,7 +461,7 @@ paths: parameters: - name: managedElementId in: query - description: The ID of the Managed Element + description: The identity of the Managed Element required: true allowEmptyValue: false schema: diff --git a/a1-policy-management/api/api_generated.yaml b/a1-policy-management/api/api_generated.yaml index 06bbf334..fd7b3129 100644 --- a/a1-policy-management/api/api_generated.yaml +++ b/a1-policy-management/api/api_generated.yaml @@ -1,27 +1,22 @@ swagger: '2.0' info: - description: | - The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices. - It provides support for: - -Supervision of clients (R-APPs) to eliminate stray policies in case of failure - -Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs - -Consistency monitoring of NearRT-RIC capabilities (policy types)-Policy configuration. - This includes:-One REST API towards all NearRT-RICs in the network - -Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP), - all policies of a type etc. - -Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices. + description: |- + The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. + It provides support for:<ul><li>A1 Policy creation and modification.</li><li>Maintaining a view of supported Near-RT RIC policy types </li><li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> <li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li></ul> version: 1.1.0 title: A1 Policy management service contact: name: Ericsson Software Technology email: nonrtric@est.tech + x-api-id: 60f9a0e7-343f-43bf-9194-d8d65688d465 + x-audience: external-partner host: 'localhost:8081' basePath: / tags: - name: A1 Policy Management Version 1.0 description: Policy Controller - name: A1 Policy Management Version 2.0 (in progress) - description: Policy Controller + description: Policy management paths: /policies: get: @@ -34,7 +29,7 @@ paths: parameters: - name: ric in: query - description: The name of the NearRT-RIC to get policies for. + description: The name of the Near-RT RIC to get policies for. required: false type: string allowEmptyValue: false @@ -62,7 +57,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC or type not found + description: Near-RT RIC or type not found schema: type: string deprecated: false @@ -117,7 +112,7 @@ paths: type: object - name: ric in: query - description: The name of the NearRT-RIC where the policy will be created. + description: The name of the Near-RT RIC where the policy will be created. required: true type: string allowEmptyValue: false @@ -129,7 +124,7 @@ paths: allowEmptyValue: false - name: transient in: query - description: 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 NearRT-RIC. + description: 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-RT RIC. required: false type: boolean default: false @@ -151,11 +146,11 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC or policy type is not found + description: Near-RT RIC or policy type is not found schema: type: string '423': - description: NearRT-RIC is not operational + description: Near-RT RIC is not operational schema: type: string deprecated: false @@ -187,7 +182,7 @@ paths: schema: type: string '423': - description: NearRT-RIC is not operational + description: Near-RT RIC is not operational schema: type: string deprecated: false @@ -195,14 +190,14 @@ paths: get: tags: - A1 Policy Management Version 1.0 - summary: 'Query policies, only IDs returned' + summary: 'Query policies, only policy identities returned' operationId: getPolicyIdsUsingGET_1 produces: - '*/*' parameters: - name: ric in: query - description: The name of the NearRT-RIC to get policies for. + description: The name of the Near-RT RIC to get policies for. required: false type: string allowEmptyValue: false @@ -220,7 +215,7 @@ paths: allowEmptyValue: false responses: '200': - description: Policy ids + description: Policy identitiess schema: type: array items: @@ -230,7 +225,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC or type not found + description: Near-RT RIC or type not found schema: type: string deprecated: false @@ -274,7 +269,7 @@ paths: parameters: - name: ric in: query - description: The name of the NearRT-RIC to get the definitions for. + description: The name of the Near-RT RIC to get the definitions for. required: false type: string allowEmptyValue: false @@ -290,7 +285,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: type: string deprecated: false @@ -334,7 +329,7 @@ paths: parameters: - name: ric in: query - description: The name of the NearRT-RIC to get types for. + description: The name of the Near-RT RIC to get types for. required: false type: string allowEmptyValue: false @@ -350,7 +345,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: type: string deprecated: false @@ -371,7 +366,7 @@ paths: allowEmptyValue: false responses: '200': - description: NearRT-RIC is found + description: Near-RT RIC is found schema: type: string '401': @@ -379,7 +374,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: type: string deprecated: false @@ -387,7 +382,7 @@ paths: get: tags: - A1 Policy Management Version 1.0 - summary: Query NearRT-RIC information + summary: Query Near-RT RIC information operationId: getRicsUsingGET produces: - '*/*' @@ -569,8 +564,8 @@ paths: get: tags: - A1 Policy Management Version 2.0 (in progress) - summary: Query policies - description: 'If several query parameters are defined, the policies matching all conditions are returned' + summary: Query for existing A1 policies + description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.' operationId: getPoliciesUsingGET produces: - application/json @@ -583,7 +578,7 @@ paths: allowEmptyValue: false - name: ric_id in: query - description: The identity of the NearRT-RIC to get policies for. + description: The identity of the Near-RT RIC to get policies for. required: false type: string allowEmptyValue: false @@ -603,7 +598,7 @@ paths: '403': description: Forbidden '404': - description: 'NearRT-RIC, policy type or service not found' + description: 'Near-RT RIC, policy type or service not found' schema: $ref: '#/definitions/error_information' deprecated: false @@ -666,7 +661,7 @@ paths: allowEmptyValue: false - name: ric_id in: query - description: The identity of the NearRT-RIC where the policy will be created. + description: The identity of the Near-RT RIC where the policy will be created. required: true type: string allowEmptyValue: false @@ -678,7 +673,7 @@ paths: allowEmptyValue: false - name: transient in: query - description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will not be recreated in the NearRT-RIC when it has been lost (for instance due to a restart) + description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC when it has been lost (for instance due to a restart) required: false type: boolean default: false @@ -694,11 +689,11 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC or policy type is not found + description: Near-RT RIC or policy type is not found schema: $ref: '#/definitions/error_information' '423': - description: NearRT-RIC is not operational + description: Near-RT RIC is not operational schema: $ref: '#/definitions/error_information' deprecated: false @@ -730,7 +725,7 @@ paths: schema: $ref: '#/definitions/error_information' '423': - description: NearRT-RIC is not operational + description: Near-RT RIC is not operational schema: $ref: '#/definitions/error_information' deprecated: false @@ -738,7 +733,8 @@ paths: get: tags: - A1 Policy Management Version 2.0 (in progress) - summary: 'Query policies, only IDs returned' + summary: 'Query policies, only policy identities are returned' + description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.' operationId: getPolicyIdsUsingGET produces: - application/json @@ -751,7 +747,7 @@ paths: allowEmptyValue: false - name: ric_id in: query - description: The identity of the NearRT-RIC to get policies for. + description: The identity of the Near-RT RIC to get policies for. required: false type: string allowEmptyValue: false @@ -763,7 +759,7 @@ paths: allowEmptyValue: false responses: '200': - description: Policy ids + description: Policy identities schema: $ref: '#/definitions/policy_id_list_v2' '401': @@ -771,7 +767,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC or type not found + description: Near-RT RIC or type not found schema: $ref: '#/definitions/error_information' deprecated: false @@ -792,7 +788,7 @@ paths: allowEmptyValue: false - name: ric_id in: query - description: The identity of the NearRT-RIC to get the definitions for. + description: The identity of the Near-RT RIC to get the definitions for. required: false type: string allowEmptyValue: false @@ -806,7 +802,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: $ref: '#/definitions/error_information' deprecated: false @@ -850,7 +846,7 @@ paths: parameters: - name: ric_id in: query - description: The identity of the NearRT-RIC to get types for. + description: The identity of the Near-RT RIC to get types for. required: false type: string allowEmptyValue: false @@ -864,7 +860,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: $ref: '#/definitions/error_information' deprecated: false @@ -872,26 +868,27 @@ paths: get: tags: - A1 Policy Management Version 2.0 (in progress) - summary: Returns info for the NearRT-RIC with the given identity or managing one Mananged Element + summary: Returns info for a Near-RT RIC + description: Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU). operationId: getRicUsingGET_1 produces: - application/json parameters: - name: managed_element_id in: query - description: 'The identity of a Managed Element. If given, the NearRT-RIC managing the ME is returned.' + description: 'The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.' required: false type: string allowEmptyValue: false - name: ric_id in: query - description: The identity of a NearRT-RIC to get information for. + description: The identity of a Near-RT RIC to get information for. required: false type: string allowEmptyValue: false responses: '200': - description: NearRT-RIC is found + description: Near-RT RIC is found schema: $ref: '#/definitions/ric_info_v2' '401': @@ -899,7 +896,7 @@ paths: '403': description: Forbidden '404': - description: NearRT-RIC is not found + description: Near-RT RIC is not found schema: $ref: '#/definitions/error_information' deprecated: false @@ -907,14 +904,15 @@ paths: get: tags: - A1 Policy Management Version 2.0 (in progress) - summary: Query NearRT-RIC information + summary: Query Near-RT RIC information + description: The call returns all Near-RT RICs that supports a given policy type identity operationId: getRicsUsingGET_1 produces: - application/json parameters: - name: policytype_id in: query - description: 'The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned' + description: 'The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned' required: false type: string allowEmptyValue: false @@ -937,6 +935,7 @@ paths: tags: - A1 Policy Management Version 2.0 (in progress) summary: Returns service information + description: Either information about a registered service with given identity or all registered services are returned. operationId: getServicesUsingGET produces: - application/json @@ -965,6 +964,7 @@ paths: tags: - A1 Policy Management Version 2.0 (in progress) summary: Register a service + description: 'Registering a service is needed to:<ul><li>Get callbacks.</li><li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li></ul>' operationId: putServiceUsingPUT consumes: - application/json @@ -1000,14 +1000,14 @@ paths: delete: tags: - A1 Policy Management Version 2.0 (in progress) - summary: Delete a service + summary: Unregister a service operationId: deleteServiceUsingDELETE produces: - '*/*' parameters: - name: service_id in: query - description: The name of the service + description: The idenitity of the service required: true type: string allowEmptyValue: false @@ -1015,7 +1015,7 @@ paths: '200': description: Not used '204': - description: Service deleted + description: Service unregistered schema: type: object '401': @@ -1104,7 +1104,7 @@ definitions: json_object: type: object title: json_object - description: A JSON object. The schema is defined by the Policy Type + description: A JSON object defining the configuration of the policy. The schema is defined by the Policy Type. policy_id_list_v2: type: object properties: @@ -1139,7 +1139,7 @@ definitions: description: 'timestamp, last modification time' ric: type: string - description: identity of the target NearRT-RIC + description: identity of the target Near-RT RIC service: type: string description: the name of the service owning the policy @@ -1164,7 +1164,7 @@ definitions: description: name of the policy type ric_id: type: string - description: identity of the target NearRT-RIC + description: identity of the target Near-RT RIC service_id: type: string description: the name of the service owning the policy @@ -1175,7 +1175,7 @@ definitions: properties: policy_schemas: type: array - description: Policy type json schemas + description: 'Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema' items: type: object title: policy_schema_list_v2 @@ -1195,11 +1195,11 @@ definitions: properties: rics: type: array - description: List of NearRT-RIC information + description: List of Near-RT RIC information items: $ref: '#/definitions/ric_info_v2' title: ric_info_list_v2 - description: List of NearRT-RIC information + description: List of Near-RT RIC information ric_info_v1: type: object properties: @@ -1215,7 +1215,7 @@ definitions: type: string ricName: type: string - description: identity of the NearRT-RIC + description: identity of the Near-RT RIC state: type: string description: state info @@ -1235,22 +1235,22 @@ definitions: type: string ric_id: type: string - description: identity of the NearRT-RIC + description: identity of the Near-RT RIC state: type: string description: |- - State for the NearRT-RIC, values: - UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent + State for the Near-RT RIC, values: + UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent AVAILABLE: The normal state. Policies can be configured. + - SYNCHRONIZING: The Policy Management Service is synchronizing the view of the NearRT-RIC. Policies cannot be configured. - CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured. + SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. + CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured. enum: - UNAVAILABLE - AVAILABLE - SYNCHRONIZING - CONSISTENCY_CHECK title: ric_info_v2 - description: Information for a NearRT-RIC + description: Information for a Near-RT RIC service_list_v2: type: object properties: diff --git a/a1-policy-management/eclipse-formatter.xml b/a1-policy-management/eclipse-formatter.xml index 8ac322ac..b2e86eb5 100644 --- a/a1-policy-management/eclipse-formatter.xml +++ b/a1-policy-management/eclipse-formatter.xml @@ -19,296 +19,344 @@ * ========================LICENSE_END=================================== --> <profiles version="13"> -<profile kind="CodeFormatterProfile" name="java-formatter" version="12"> -<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> -<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/> -<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/> -<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> -<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> -<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/> -<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="48"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/> -<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> -<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> -<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> -<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> -<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> -<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> -</profile> -</profiles> + <profile kind="CodeFormatterProfile" name="ONAP_GoogleStyle" version="13"> + <setting id="org.eclipse.jdt.core.compiler.source" value="1.8" /> + <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" /> + <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8" /> + <setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled" /> + <setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error" /> + <setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error" /> + <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent" value="1585|-1|1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable.count_dependent" value="1585|-1|1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method.count_dependent" value="1585|-1|1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package.count_dependent" value="1585|-1|1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="1040" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter.count_dependent" value="1040|-1|1040" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type.count_dependent" value="1585|-1|1585" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression.count_dependent" value="16|4|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent" value="16|5|48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_field_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_for_statement" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent" value="16|-1|16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class" value="20" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration.count_dependent" value="16|5|80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation.count_dependent" value="16|4|48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration.count_dependent" value="16|4|49" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration.count_dependent" value="16|4|48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration.count_dependent" value="16|4|48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration.count_dependent" value="16|4|48" /> + <setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1" /> + <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line" /> + <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120" /> + <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2" /> + <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2" /> + <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off" /> + <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on" /> + <setting id="org.eclipse.jdt.core.formatter.force_if_else_statement_brace" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comment_prefix" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert" /> + <setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120" /> + <setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0" /> + <setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="3" /> + <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space" /> + <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4" /> + <setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/> + <setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/> + <setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_comment_inline_tags" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation" value="false" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true" /> + <setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="false" /> + </profile> +</profiles>
\ No newline at end of file diff --git a/a1-policy-management/pom.xml b/a1-policy-management/pom.xml index 11129374..f9c9b873 100644 --- a/a1-policy-management/pom.xml +++ b/a1-policy-management/pom.xml @@ -19,6 +19,7 @@ ~ ============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> @@ -26,7 +27,7 @@ <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1-SNAPSHOT</version> - <relativePath /> + <relativePath/> </parent> <groupId>org.onap.ccsdk.oran</groupId> @@ -35,19 +36,6 @@ <name>ccsdk-oran :: ${project.artifactId}</name> - <issueManagement> - <system>JIRA</system> - <url>https://jira.onap.org/</url> - </issueManagement> - - <repositories> - <repository> - <id>onap-releases</id> - <name>onap-releases</name> - <url>https://nexus.onap.org/content/repositories/releases/</url> - </repository> - </repositories> - <properties> <java.version.source>11</java.version.source> <java.version.target>11</java.version.target> @@ -67,6 +55,7 @@ <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version> <exec.skip>true</exec.skip> </properties> + <dependencies> <dependency> <groupId>org.springframework.boot</groupId> @@ -172,7 +161,7 @@ <artifactId>springfox-swagger-ui</artifactId> <version>${springfox.version}</version> </dependency> - <!-- TEST --> + <!-- TEST --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> @@ -209,17 +198,19 @@ <scope>test</scope> </dependency> </dependencies> + <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> - <plugin> + <plugin> <groupId>net.revelc.code.formatter</groupId> <artifactId>formatter-maven-plugin</artifactId> <version>${formatter-maven-plugin.version}</version> <configuration> + <lineEnding>LF</lineEnding> <configFile>${project.basedir}/eclipse-formatter.xml</configFile> </configuration> <!-- https://code.revelc.net/formatter-maven-plugin/ use mvn formatter:format @@ -230,8 +221,9 @@ <artifactId>spotless-maven-plugin</artifactId> <version>${spotless-maven-plugin.version}</version> <configuration> + <lineEndings>UNIX</lineEndings> <java> - <removeUnusedImports /> + <removeUnusedImports/> <importOrder> <order>com,java,javax,org</order> </importOrder> diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java index 4b684288..89058a1c 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java @@ -22,6 +22,9 @@ package org.onap.ccsdk.oran.a1policymanagementservice; import com.google.common.base.Predicates; +import java.util.ArrayList; +import java.util.List; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -32,6 +35,8 @@ import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; +import springfox.documentation.service.StringVendorExtension; +import springfox.documentation.service.VendorExtension; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @@ -48,16 +53,16 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; public class SwaggerConfig extends WebMvcConfigurationSupport { static final String API_TITLE = "A1 Policy management service"; - static final String DESCRIPTION = - "The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices. \n" - + "It provides support for: \n" - + "-Supervision of clients (R-APPs) to eliminate stray policies in case of failure \n" - + "-Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs \n" - + "-Consistency monitoring of NearRT-RIC capabilities (policy types)" + "-Policy configuration. \n" - + "This includes:" + "-One REST API towards all NearRT-RICs in the network \n" - + "-Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP), \n" - + "all policies of a type etc. \n" - + "-Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices.\n"; + static final String DESCRIPTION = // + "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" // + + "It provides support for:" // + + "<ul>" // + + "<li>A1 Policy creation and modification.</li>" // + + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" // + + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " // + + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" // + + "</ul>"// + ; static final String VERSION = "1.1.0"; @SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter. static final String RESOURCES_PATH = "classpath:/META-INF/resources/"; @@ -73,24 +78,35 @@ public class SwaggerConfig extends WebMvcConfigurationSupport { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) // - .apiInfo(apiInfo()) // - .select() // - .apis(RequestHandlerSelectors.any()) // - .paths(PathSelectors.any()) // - .paths(Predicates.not(PathSelectors.regex("/error"))) // - // this endpoint is not implemented, but was visible for Swagger - .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) // - // this endpoint is implemented by spring framework, exclude for now - .build(); + .apiInfo(apiInfo()) // + .select() // + .apis(RequestHandlerSelectors.any()) // + .paths(PathSelectors.any()) // + .paths(Predicates.not(PathSelectors.regex("/error"))) // + // this endpoint is not implemented, but was visible for Swagger + .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) // + // this endpoint is implemented by spring framework, exclude for now + .build(); } private static ApiInfo apiInfo() { return new ApiInfoBuilder() // - .title(API_TITLE) // - .description(DESCRIPTION) // - .version(VERSION) // - .contact(contact()) // - .build(); + .title(API_TITLE) // + .description(DESCRIPTION) // + .version(VERSION) // + .contact(contact()) // + .extensions(vendorExtentions()) // + .build(); + } + + @SuppressWarnings("rawtypes") // VendorExtension is a raw type. References to generic type VendorExtension<T> + // should be parameterizedJava(16777788) + private static List<VendorExtension> vendorExtentions() { + final String URN = "60f9a0e7-343f-43bf-9194-d8d65688d465"; + List<VendorExtension> extentions = new ArrayList<>(); + extentions.add(new StringVendorExtension("x-api-id", URN)); + extentions.add(new StringVendorExtension("x-audience", "external-partner")); + return extentions; } private static Contact contact() { @@ -100,10 +116,10 @@ public class SwaggerConfig extends WebMvcConfigurationSupport { @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(SWAGGER_UI) // - .addResourceLocations(RESOURCES_PATH); + .addResourceLocations(RESOURCES_PATH); registry.addResourceHandler(WEBJARS) // - .addResourceLocations(WEBJARS_PATH); + .addResourceLocations(WEBJARS_PATH); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java index 2b493575..cfb01d0b 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java @@ -60,13 +60,13 @@ public class A1ClientFactory { * means that after the first successful creation it won't have to try which * protocol to use, but can create the client directly. * - * @param ric The NearRT-RIC to get a client for. + * @param ric The Near-RT RIC to get a client for. * @return a client with the correct protocol, or a ServiceException if none of - * the protocols are supported by the NearRT-RIC. + * the protocols are supported by the Near-RT RIC. */ public Mono<A1Client> createA1Client(Ric ric) { return getProtocolVersion(ric) // - .flatMap(version -> createA1ClientMono(ric, version)); + .flatMap(version -> createA1ClientMono(ric, version)); } A1Client createClient(Ric ric, A1ProtocolType version) throws ServiceException { @@ -78,7 +78,7 @@ public class A1ClientFactory { return new OscA1Client(ric.getConfig(), this.appConfig.getWebClientConfig()); } else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1) { return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric), - this.appConfig.getWebClientConfig()); + this.appConfig.getWebClientConfig()); } else if (version == A1ProtocolType.SDNC_ONAP) { return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric), this.appConfig.getWebClientConfig()); } else { @@ -91,7 +91,7 @@ public class A1ClientFactory { String controllerName = ric.getConfig().controllerName(); if (controllerName.isEmpty()) { ric.setProtocolVersion(A1ProtocolType.UNKNOWN); - throw new ServiceException("No controller configured for NearRT-RIC: " + ric.id()); + throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id()); } try { return this.appConfig.getControllerConfig(controllerName); @@ -105,7 +105,7 @@ public class A1ClientFactory { if (!ric.getConfig().controllerName().isEmpty()) { ric.setProtocolVersion(A1ProtocolType.UNKNOWN); throw new ServiceException( - "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version); + "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version); } } @@ -120,15 +120,15 @@ public class A1ClientFactory { private Mono<A1Client.A1ProtocolType> getProtocolVersion(Ric ric) { if (ric.getProtocolVersion() == A1ProtocolType.UNKNOWN) { return fetchVersion(ric, A1ProtocolType.STD_V1_1) // - .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) // - .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) // - .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) // - .doOnNext(ric::setProtocolVersion) - .doOnNext( - version -> logger.debug("Established protocol version:{} for NearRT-RIC: {}", version, ric.id())) // - .doOnError(notUsed -> logger.warn("Could not get protocol version from NearRT-RIC: {}", ric.id())) // - .onErrorResume( - notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id()))); + .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) // + .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) // + .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) // + .doOnNext(ric::setProtocolVersion) + .doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version, + ric.id())) // + .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) // + .onErrorResume( + notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id()))); } else { return Mono.just(ric.getProtocolVersion()); } @@ -136,6 +136,6 @@ public class A1ClientFactory { private Mono<A1ProtocolType> fetchVersion(Ric ric, A1ProtocolType protocolType) { return createA1ClientMono(ric, protocolType) // - .flatMap(A1Client::getProtocolVersion); + .flatMap(A1Client::getProtocolVersion); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java index c3de6b2c..c1cea8b5 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java @@ -90,18 +90,18 @@ public class AsyncRestClient { logger.trace("{} POST body: {}", traceTag, body); Mono<String> bodyProducer = body != null ? Mono.just(body) : Mono.empty(); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.post() // - .uri(uri) // - .contentType(MediaType.APPLICATION_JSON) // - .body(bodyProducer, String.class); - return retrieve(traceTag, request); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.post() // + .uri(uri) // + .contentType(MediaType.APPLICATION_JSON) // + .body(bodyProducer, String.class); + return retrieve(traceTag, request); + }); } public Mono<String> post(String uri, @Nullable String body) { return postForEntity(uri, body) // - .flatMap(this::toBody); + .flatMap(this::toBody); } public Mono<String> postWithAuthHeader(String uri, String body, String username, String password) { @@ -109,15 +109,15 @@ public class AsyncRestClient { logger.debug("{} POST (auth) uri = '{}{}''", traceTag, baseUrl, uri); logger.trace("{} POST body: {}", traceTag, body); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.post() // - .uri(uri) // - .headers(headers -> headers.setBasicAuth(username, password)) // - .contentType(MediaType.APPLICATION_JSON) // - .bodyValue(body); - return retrieve(traceTag, request) // - .flatMap(this::toBody); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.post() // + .uri(uri) // + .headers(headers -> headers.setBasicAuth(username, password)) // + .contentType(MediaType.APPLICATION_JSON) // + .bodyValue(body); + return retrieve(traceTag, request) // + .flatMap(this::toBody); + }); } public Mono<ResponseEntity<String>> putForEntity(String uri, String body) { @@ -125,13 +125,13 @@ public class AsyncRestClient { logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri); logger.trace("{} PUT body: {}", traceTag, body); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.put() // - .uri(uri) // - .contentType(MediaType.APPLICATION_JSON) // - .bodyValue(body); - return retrieve(traceTag, request); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.put() // + .uri(uri) // + .contentType(MediaType.APPLICATION_JSON) // + .bodyValue(body); + return retrieve(traceTag, request); + }); } public Mono<ResponseEntity<String>> putForEntity(String uri) { @@ -139,54 +139,54 @@ public class AsyncRestClient { logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri); logger.trace("{} PUT body: <empty>", traceTag); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.put() // - .uri(uri); - return retrieve(traceTag, request); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.put() // + .uri(uri); + return retrieve(traceTag, request); + }); } public Mono<String> put(String uri, String body) { return putForEntity(uri, body) // - .flatMap(this::toBody); + .flatMap(this::toBody); } public Mono<ResponseEntity<String>> getForEntity(String uri) { Object traceTag = createTraceTag(); logger.debug("{} GET uri = '{}{}''", traceTag, baseUrl, uri); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.get().uri(uri); - return retrieve(traceTag, request); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.get().uri(uri); + return retrieve(traceTag, request); + }); } public Mono<String> get(String uri) { return getForEntity(uri) // - .flatMap(this::toBody); + .flatMap(this::toBody); } public Mono<ResponseEntity<String>> deleteForEntity(String uri) { Object traceTag = createTraceTag(); logger.debug("{} DELETE uri = '{}{}''", traceTag, baseUrl, uri); return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec<?> request = client.delete().uri(uri); - return retrieve(traceTag, request); - }); + .flatMap(client -> { + RequestHeadersSpec<?> request = client.delete().uri(uri); + return retrieve(traceTag, request); + }); } public Mono<String> delete(String uri) { return deleteForEntity(uri) // - .flatMap(this::toBody); + .flatMap(this::toBody); } private Mono<ResponseEntity<String>> retrieve(Object traceTag, RequestHeadersSpec<?> request) { final Class<String> clazz = String.class; return request.retrieve() // - .toEntity(clazz) // - .doOnNext(entity -> logReceivedData(traceTag, entity)) // - .doOnError(throwable -> onHttpError(traceTag, throwable)); + .toEntity(clazz) // + .doOnNext(entity -> logReceivedData(traceTag, entity)) // + .doOnError(throwable -> onHttpError(traceTag, throwable)); } private void logReceivedData(Object traceTag, ResponseEntity<String> entity) { @@ -201,7 +201,7 @@ public class AsyncRestClient { if (t instanceof WebClientResponseException) { WebClientResponseException exception = (WebClientResponseException) t; logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(), - exception.getResponseBodyAsString()); + exception.getResponseBodyAsString()); } else { logger.debug("{} HTTP error", traceTag, t); } @@ -234,7 +234,7 @@ public class AsyncRestClient { } private static synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass) - throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { + throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { if (clientTrustStore == null) { KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType()); store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray()); @@ -244,66 +244,66 @@ public class AsyncRestClient { } private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass, - KeyManagerFactory keyManager) - throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { + KeyManagerFactory keyManager) + throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass); List<Certificate> certificateList = Collections.list(trustStore.aliases()).stream() // - .filter(alias -> isCertificateEntry(trustStore, alias)) // - .map(alias -> getCertificate(trustStore, alias)) // - .collect(Collectors.toList()); + .filter(alias -> isCertificateEntry(trustStore, alias)) // + .map(alias -> getCertificate(trustStore, alias)) // + .collect(Collectors.toList()); final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]); return SslContextBuilder.forClient() // - .keyManager(keyManager) // - .trustManager(certificates) // - .build(); + .keyManager(keyManager) // + .trustManager(certificates) // + .build(); } private SslContext createSslContext(KeyManagerFactory keyManager) - throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException { + throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException { if (this.clientConfig.isTrustStoreUsed()) { return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(), - this.clientConfig.trustStorePassword(), keyManager); + this.clientConfig.trustStorePassword(), keyManager); } else { // Trust anyone return SslContextBuilder.forClient() // - .keyManager(keyManager) // - .trustManager(InsecureTrustManagerFactory.INSTANCE) // - .build(); + .keyManager(keyManager) // + .trustManager(InsecureTrustManagerFactory.INSTANCE) // + .build(); } } private TcpClient createTcpClientSecure(SslContext sslContext) { return TcpClient.create(ConnectionProvider.newConnection()) // - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // - .secure(c -> c.sslContext(sslContext)) // - .doOnConnected(connection -> { - connection.addHandlerLast(new ReadTimeoutHandler(30)); - connection.addHandlerLast(new WriteTimeoutHandler(30)); - }); + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // + .secure(c -> c.sslContext(sslContext)) // + .doOnConnected(connection -> { + connection.addHandlerLast(new ReadTimeoutHandler(30)); + connection.addHandlerLast(new WriteTimeoutHandler(30)); + }); } private TcpClient createTcpClientInsecure() { return TcpClient.create(ConnectionProvider.newConnection()) // - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // - .doOnConnected(connection -> { - connection.addHandlerLast(new ReadTimeoutHandler(30)); - connection.addHandlerLast(new WriteTimeoutHandler(30)); - }); + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // + .doOnConnected(connection -> { + connection.addHandlerLast(new ReadTimeoutHandler(30)); + connection.addHandlerLast(new WriteTimeoutHandler(30)); + }); } private WebClient createWebClient(String baseUrl, TcpClient tcpClient) { HttpClient httpClient = HttpClient.from(tcpClient); ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient); ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() // - .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) // - .build(); + .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) // + .build(); return WebClient.builder() // - .clientConnector(connector) // - .baseUrl(baseUrl) // - .exchangeStrategies(exchangeStrategies) // - .build(); + .clientConnector(connector) // + .baseUrl(baseUrl) // + .exchangeStrategies(exchangeStrategies) // + .build(); } private Mono<WebClient> getWebClient() { @@ -311,7 +311,7 @@ public class AsyncRestClient { try { if (this.sslEnabled) { final KeyManagerFactory keyManager = - KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType()); final String keyStoreFile = this.clientConfig.keyStore(); final String keyStorePassword = this.clientConfig.keyStorePassword(); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java index bdbb916b..fed218e8 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java @@ -144,21 +144,21 @@ public class OscA1Client implements A1Client { @Override public Mono<List<String>> getPolicyTypeIdentities() { return getPolicyTypeIds() // - .collectList(); + .collectList(); } @Override public Mono<List<String>> getPolicyIdentities() { return getPolicyTypeIds() // - .flatMap(this::getPolicyIdentitiesByType) // - .collectList(); + .flatMap(this::getPolicyIdentitiesByType) // + .collectList(); } @Override public Mono<String> getPolicyTypeSchema(String policyTypeId) { String schemaUri = uri.createGetSchemaUri(policyTypeId); return restClient.get(schemaUri) // - .flatMap(response -> extractCreateSchema(response, policyTypeId)); + .flatMap(response -> extractCreateSchema(response, policyTypeId)); } @Override @@ -175,13 +175,13 @@ public class OscA1Client implements A1Client { @Override public Mono<A1ProtocolType> getProtocolVersion() { return restClient.get(uri.createHealtcheckUri()) // - .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1)); + .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1)); } @Override public Flux<String> deleteAllPolicies() { return getPolicyTypeIds() // - .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC); + .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC); } @Override @@ -193,12 +193,12 @@ public class OscA1Client implements A1Client { private Flux<String> getPolicyTypeIds() { return restClient.get(uri.createPolicyTypesUri()) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Flux<String> getPolicyIdentitiesByType(String typeId) { return restClient.get(uri.createGetPolicyIdsUri(typeId)) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Mono<String> deletePolicyById(String typeId, String policyId) { @@ -208,6 +208,6 @@ public class OscA1Client implements A1Client { private Flux<String> deletePoliciesForType(String typeId) { return getPolicyIdentitiesByType(typeId) // - .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC); + .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java index fdbbd533..ada35fd6 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java @@ -45,13 +45,12 @@ import reactor.core.publisher.Mono; @SuppressWarnings("java:S1192") // Same text in several traces class SdncJsonHelper { private static Gson gson = new GsonBuilder() // - .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) // - .create(); + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) // + .create(); private static final String OUTPUT = "output"; private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private SdncJsonHelper() { - } + private SdncJsonHelper() {} public static Flux<String> parseJsonArrayOfString(String inputString) { try { @@ -97,13 +96,13 @@ class SdncJsonHelper { public static Mono<String> getValueFromResponse(String response, String key) { return getOutput(response) // - .flatMap(responseParams -> { - if (!responseParams.has(key)) { - return Mono.just(""); - } - String value = responseParams.get(key).toString(); - return Mono.just(value); - }); + .flatMap(responseParams -> { + if (!responseParams.has(key)) { + return Mono.just(""); + } + String value = responseParams.get(key).toString(); + return Mono.just(value); + }); } public static Mono<String> extractPolicySchema(String inputString) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java index 0591e668..2c564c3f 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java @@ -66,9 +66,9 @@ public class SdncOnapA1Client implements A1Client { public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, WebClientConfig clientConfig) { this(ricConfig, controllerConfig, - new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig)); + new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig)); logger.debug("SdncOnapA1Client for ric: {}, a1ControllerBaseUrl: {}", ricConfig.ricId(), - controllerConfig.baseUrl()); + controllerConfig.baseUrl()); } public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, AsyncRestClient restClient) { @@ -80,47 +80,47 @@ public class SdncOnapA1Client implements A1Client { @Override public Mono<List<String>> getPolicyTypeIdentities() { return getPolicyTypeIds() // - .collectList(); + .collectList(); } @Override public Mono<List<String>> getPolicyIdentities() { return getPolicyTypeIds() // - .flatMap(this::getPolicyIdentitiesByType) // - .collectList(); + .flatMap(this::getPolicyIdentitiesByType) // + .collectList(); } @Override public Mono<String> getPolicyTypeSchema(String policyTypeId) { SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(ricConfig.baseUrl()) // - .policyTypeId(policyTypeId) // - .build(); + .nearRtRicId(ricConfig.baseUrl()) // + .policyTypeId(policyTypeId) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST getPolicyType inputJsonString = {}", inputJsonString); return restClient - .postWithAuthHeader(URL_PREFIX + "getPolicyType", inputJsonString, controllerConfig.userName(), - controllerConfig.password()) // - .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type")) // - .flatMap(SdncJsonHelper::extractPolicySchema); + .postWithAuthHeader(URL_PREFIX + "getPolicyType", inputJsonString, controllerConfig.userName(), + controllerConfig.password()) // + .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type")) // + .flatMap(SdncJsonHelper::extractPolicySchema); } @Override public Mono<String> putPolicy(Policy policy) { SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(ricConfig.baseUrl()) // - .policyTypeId(policy.type().id()) // - .policyInstanceId(policy.id()) // - .policyInstance(policy.json()) // - .properties(new ArrayList<>()) // - .build(); + .nearRtRicId(ricConfig.baseUrl()) // + .policyTypeId(policy.type().id()) // + .policyInstanceId(policy.id()) // + .policyInstance(policy.json()) // + .properties(new ArrayList<>()) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST putPolicy inputJsonString = {}", inputJsonString); return restClient.postWithAuthHeader(URL_PREFIX + "createPolicyInstance", inputJsonString, - controllerConfig.userName(), controllerConfig.password()); + controllerConfig.userName(), controllerConfig.password()); } @Override @@ -131,13 +131,13 @@ public class SdncOnapA1Client implements A1Client { @Override public Flux<String> deleteAllPolicies() { return getPolicyTypeIds() // - .flatMap(this::deletePoliciesForType); // + .flatMap(this::deletePoliciesForType); // } @Override public Mono<A1ProtocolType> getProtocolVersion() { return getPolicyTypeIdentities() // - .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP)); + .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP)); } @Override @@ -147,48 +147,48 @@ public class SdncOnapA1Client implements A1Client { private Flux<String> getPolicyTypeIds() { SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(ricConfig.baseUrl()) // - .build(); + .nearRtRicId(ricConfig.baseUrl()) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST getPolicyTypeIdentities inputJsonString = {}", inputJsonString); return restClient - .postWithAuthHeader(URL_PREFIX + "getPolicyTypes", inputJsonString, controllerConfig.userName(), - controllerConfig.password()) // - .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type-id-list")) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .postWithAuthHeader(URL_PREFIX + "getPolicyTypes", inputJsonString, controllerConfig.userName(), + controllerConfig.password()) // + .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type-id-list")) // + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Flux<String> getPolicyIdentitiesByType(String policyTypeId) { SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(ricConfig.baseUrl()) // - .policyTypeId(policyTypeId) // - .build(); + .nearRtRicId(ricConfig.baseUrl()) // + .policyTypeId(policyTypeId) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST getPolicyIdentities inputJsonString = {}", inputJsonString); return restClient - .postWithAuthHeader(URL_PREFIX + "getPolicyInstances", inputJsonString, controllerConfig.userName(), - controllerConfig.password()) // - .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-instance-id-list")) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .postWithAuthHeader(URL_PREFIX + "getPolicyInstances", inputJsonString, controllerConfig.userName(), + controllerConfig.password()) // + .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-instance-id-list")) // + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Flux<String> deletePoliciesForType(String typeId) { return getPolicyIdentitiesByType(typeId) // - .flatMap(policyId -> deletePolicyByTypeId(typeId, policyId)); // + .flatMap(policyId -> deletePolicyByTypeId(typeId, policyId)); // } private Mono<String> deletePolicyByTypeId(String policyTypeId, String policyId) { SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(ricConfig.baseUrl()) // - .policyTypeId(policyTypeId) // - .policyInstanceId(policyId) // - .build(); + .nearRtRicId(ricConfig.baseUrl()) // + .policyTypeId(policyTypeId) // + .policyInstanceId(policyId) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST deletePolicy inputJsonString = {}", inputJsonString); return restClient.postWithAuthHeader(URL_PREFIX + "deletePolicyInstance", inputJsonString, - controllerConfig.userName(), controllerConfig.password()); + controllerConfig.userName(), controllerConfig.password()); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java index dffb9dd8..3647f225 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java @@ -68,8 +68,8 @@ public class SdncOscA1Client implements A1Client { } static com.google.gson.Gson gson = new GsonBuilder() // - .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) // - .create(); // + .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) // + .create(); // private static final String GET_POLICY_RPC = "getA1Policy"; private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -83,16 +83,16 @@ public class SdncOscA1Client implements A1Client { * * @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 NearRT-RIC to communicate + * @param ricConfig the configuration of the Near-RT 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, - WebClientConfig clientConfig) { + WebClientConfig clientConfig) { this(protocolType, ricConfig, controllerConfig, - new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig)); + new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig)); logger.debug("SdncOscA1Client for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig); } @@ -101,7 +101,7 @@ public class SdncOscA1Client implements A1Client { * * @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 NearRT-RIC to communicate + * @param ricConfig the configuration of the Near-RT RIC to communicate * with * @param controllerConfig the configuration of the SDNC controller to use * @param restClient the REST client to use @@ -109,11 +109,11 @@ public class SdncOscA1Client implements A1Client { * @throws IllegalArgumentException when the protocolType is wrong. */ public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig, - AsyncRestClient restClient) { + AsyncRestClient restClient) { if (!(A1ProtocolType.SDNC_OSC_STD_V1_1.equals(protocolType) - || A1ProtocolType.SDNC_OSC_OSC_V1.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); + + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType); } this.restClient = restClient; this.ricConfig = ricConfig; @@ -129,8 +129,8 @@ public class SdncOscA1Client implements A1Client { OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig); final String ricUrl = uri.createPolicyTypesUri(); return post(GET_POLICY_RPC, ricUrl, Optional.empty()) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) // - .collectList(); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) // + .collectList(); } } @@ -138,7 +138,7 @@ public class SdncOscA1Client implements A1Client { @Override public Mono<List<String>> getPolicyIdentities() { return getPolicyIds() // - .collectList(); + .collectList(); } @Override @@ -149,17 +149,17 @@ public class SdncOscA1Client implements A1Client { 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)); + .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId)); } } @Override public Mono<String> putPolicy(Policy policy) { return getUriBuilder() // - .flatMap(builder -> { - String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id()); - return post("putA1Policy", ricUrl, Optional.of(policy.json())); - }); + .flatMap(builder -> { + String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id()); + return post("putA1Policy", ricUrl, Optional.of(policy.json())); + }); } @Override @@ -171,38 +171,38 @@ public class SdncOscA1Client implements A1Client { public Flux<String> deleteAllPolicies() { if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) { return getPolicyIds() // - .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); // + .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); // } else { OscA1Client.UriBuilder uriBuilder = new OscA1Client.UriBuilder(ricConfig); return getPolicyTypeIdentities() // - .flatMapMany(Flux::fromIterable) // - .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC); + .flatMapMany(Flux::fromIterable) // + .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC); } } private Flux<String> oscGetInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) { return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty()) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Flux<String> oscDeleteInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) { return oscGetInstancesForType(uriBuilder, type) // - .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC); + .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC); } @Override public Mono<A1ProtocolType> getProtocolVersion() { return tryStdProtocolVersion() // - .onErrorResume(t -> tryOscProtocolVersion()); + .onErrorResume(t -> tryOscProtocolVersion()); } @Override public Mono<String> getPolicyStatus(Policy policy) { return getUriBuilder() // - .flatMap(builder -> { - String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id()); - return post("getA1PolicyStatus", ricUrl, Optional.empty()); - }); + .flatMap(builder -> { + String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id()); + return post("getA1PolicyStatus", ricUrl, Optional.empty()); + }); } private Mono<A1UriBuilder> getUriBuilder() { @@ -216,13 +216,13 @@ public class SdncOscA1Client implements A1Client { private Mono<A1ProtocolType> tryOscProtocolVersion() { OscA1Client.UriBuilder oscApiuriBuilder = new OscA1Client.UriBuilder(ricConfig); return post(GET_POLICY_RPC, oscApiuriBuilder.createHealtcheckUri(), Optional.empty()) // - .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_OSC_V1)); + .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_OSC_V1)); } private Mono<A1ProtocolType> tryStdProtocolVersion() { StdA1ClientVersion1.UriBuilder uriBuilder = new StdA1ClientVersion1.UriBuilder(ricConfig); return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(), Optional.empty()) // - .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V1_1)); + .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V1_1)); } private Flux<String> getPolicyIds() { @@ -230,36 +230,36 @@ public class SdncOscA1Client implements A1Client { StdA1ClientVersion1.UriBuilder uri = new StdA1ClientVersion1.UriBuilder(ricConfig); final String ricUrl = uri.createGetPolicyIdsUri(); return post(GET_POLICY_RPC, ricUrl, Optional.empty()) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } 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); + .flatMapMany(Flux::fromIterable) + .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) // + .flatMap(SdncJsonHelper::parseJsonArrayOfString); } } private Mono<String> deletePolicyById(String type, String policyId) { return getUriBuilder() // - .flatMap(builder -> { - String ricUrl = builder.createDeleteUri(type, policyId); - return post("deleteA1Policy", ricUrl, Optional.empty()); - }); + .flatMap(builder -> { + String ricUrl = builder.createDeleteUri(type, policyId); + return post("deleteA1Policy", ricUrl, Optional.empty()); + }); } private Mono<String> post(String rpcName, String ricUrl, Optional<String> body) { AdapterRequest inputParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(ricUrl) // - .body(body) // - .build(); + .nearRtRicUrl(ricUrl) // + .body(body) // + .build(); final String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); logger.debug("POST inputJsonString = {}", inputJsonString); return restClient - .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(), - this.controllerConfig.password()) // - .flatMap(this::extractResponseBody); + .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(), + this.controllerConfig.password()) // + .flatMap(this::extractResponseBody); } private Mono<String> extractResponse(JSONObject responseOutput) { @@ -272,7 +272,7 @@ public class SdncOscA1Client implements A1Client { logger.debug("Error response: {} {}", output.httpStatus(), body); byte[] responseBodyBytes = body.getBytes(StandardCharsets.UTF_8); WebClientResponseException responseException = new WebClientResponseException(output.httpStatus(), - "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null); + "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null); return Mono.error(responseException); } @@ -280,7 +280,7 @@ public class SdncOscA1Client implements A1Client { private Mono<String> extractResponseBody(String responseStr) { return SdncJsonHelper.getOutput(responseStr) // - .flatMap(this::extractResponse); + .flatMap(this::extractResponse); } private String controllerUrl(String rpcName) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java index 51beea71..0da9a267 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java @@ -97,7 +97,7 @@ public class StdA1ClientVersion1 implements A1Client { @Override public Mono<List<String>> getPolicyIdentities() { return getPolicyIds() // - .collectList(); + .collectList(); } @Override @@ -123,13 +123,13 @@ public class StdA1ClientVersion1 implements A1Client { @Override public Flux<String> deleteAllPolicies() { return getPolicyIds() // - .flatMap(this::deletePolicyById); // + .flatMap(this::deletePolicyById); // } @Override public Mono<A1ProtocolType> getProtocolVersion() { return getPolicyIdentities() // - .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1)); + .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1)); } @Override @@ -139,7 +139,7 @@ public class StdA1ClientVersion1 implements A1Client { private Flux<String> getPolicyIds() { return restClient.get(uri.createGetPolicyIdsUri()) // - .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); + .flatMapMany(SdncJsonHelper::parseJsonArrayOfString); } private Mono<String> deletePolicyById(String policyId) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java index 4f8e87fd..65c6daa3 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java @@ -80,14 +80,14 @@ public class ApplicationConfig { public WebClientConfig getWebClientConfig() { return ImmutableWebClientConfig.builder() // - .keyStoreType(this.sslKeyStoreType) // - .keyStorePassword(this.sslKeyStorePassword) // - .keyStore(this.sslKeyStore) // - .keyPassword(this.sslKeyPassword) // - .isTrustStoreUsed(this.sslTrustStoreUsed) // - .trustStore(this.sslTrustStore) // - .trustStorePassword(this.sslTrustStorePassword) // - .build(); + .keyStoreType(this.sslKeyStoreType) // + .keyStorePassword(this.sslKeyStorePassword) // + .keyStore(this.sslKeyStore) // + .keyPassword(this.sslKeyPassword) // + .isTrustStoreUsed(this.sslTrustStoreUsed) // + .trustStore(this.sslTrustStore) // + .trustStorePassword(this.sslTrustStorePassword) // + .build(); } public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException { @@ -123,7 +123,7 @@ public class ApplicationConfig { } public synchronized Flux<RicConfigUpdate> setConfiguration( - ApplicationConfigParser.ConfigParserResult parserResult) { + ApplicationConfigParser.ConfigParserResult parserResult) { Collection<RicConfigUpdate> modifications = new ArrayList<>(); this.controllerConfigs = parserResult.controllerConfigs(); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java index 07c04e1a..bc1f62a4 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java @@ -87,15 +87,15 @@ public class ApplicationConfigParser { checkConfigurationConsistency(ricConfigs, controllerConfigs); return ImmutableConfigParserResult.builder() // - .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) // - .dmaapProducerTopicUrl(dmaapProducerTopicUrl) // - .ricConfigs(ricConfigs) // - .controllerConfigs(controllerConfigs) // - .build(); + .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) // + .dmaapProducerTopicUrl(dmaapProducerTopicUrl) // + .ricConfigs(ricConfigs) // + .controllerConfigs(controllerConfigs) // + .build(); } private void checkConfigurationConsistency(List<RicConfig> ricConfigs, - Map<String, ControllerConfig> controllerConfigs) throws ServiceException { + Map<String, ControllerConfig> controllerConfigs) throws ServiceException { Set<String> ricUrls = new HashSet<>(); Set<String> ricNames = new HashSet<>(); for (RicConfig ric : ricConfigs) { @@ -107,7 +107,7 @@ public class ApplicationConfigParser { } if (!ric.controllerName().isEmpty() && controllerConfigs.get(ric.controllerName()) == null) { throw new ServiceException( - "Configuration error, controller configuration not found: " + ric.controllerName()); + "Configuration error, controller configuration not found: " + ric.controllerName()); } } @@ -119,11 +119,11 @@ public class ApplicationConfigParser { JsonObject ricAsJson = ricElem.getAsJsonObject(); JsonElement controllerNameElement = ricAsJson.get(CONTROLLER); RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) // - .baseUrl(get(ricAsJson, "baseUrl").getAsString()) // - .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) // - .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") // - .build(); + .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) // + .baseUrl(get(ricAsJson, "baseUrl").getAsString()) // + .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) // + .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") // + .build(); result.add(ricConfig); } return result; @@ -137,15 +137,15 @@ public class ApplicationConfigParser { for (JsonElement element : getAsJsonArray(config, CONTROLLER)) { JsonObject controllerAsJson = element.getAsJsonObject(); ImmutableControllerConfig controllerConfig = ImmutableControllerConfig.builder() // - .name(get(controllerAsJson, "name").getAsString()) // - .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) // - .password(get(controllerAsJson, "password").getAsString()) // - .userName(get(controllerAsJson, "userName").getAsString()) // ) - .build(); + .name(get(controllerAsJson, "name").getAsString()) // + .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) // + .password(get(controllerAsJson, "password").getAsString()) // + .userName(get(controllerAsJson, "userName").getAsString()) // ) + .build(); if (result.put(controllerConfig.name(), controllerConfig) != null) { throw new ServiceException( - "Configuration error, more than one controller with name: " + controllerConfig.name()); + "Configuration error, more than one controller with name: " + controllerConfig.name()); } } return result; @@ -179,7 +179,7 @@ public class ApplicationConfigParser { Set<Entry<String, JsonElement>> streamConfigEntries = streamCfg.entrySet(); if (streamConfigEntries.size() != 1) { throw new ServiceException( - "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries); + "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries); } JsonObject streamConfigEntry = streamConfigEntries.iterator().next().getValue().getAsJsonObject(); JsonObject dmaapInfo = get(streamConfigEntry, "dmaap_info").getAsJsonObject(); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java index 6ee656cc..a2b9af4b 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java @@ -27,6 +27,5 @@ import org.immutables.gson.Gson; @Gson.TypeAdapters @ApiModel(value = "void", description = "Void/empty") public class VoidResponse { - private VoidResponse() { - } + private VoidResponse() {} } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java index cef31c30..c54394e0 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java @@ -24,6 +24,5 @@ public class Consts { public static final String V1_API_NAME = "A1 Policy Management Version 1.0"; - private Consts() { - } + private Consts() {} } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java index 2c8ad7f2..d5024581 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java @@ -92,18 +92,17 @@ public class PolicyController { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // @GetMapping("/policy_schemas") @ApiOperation(value = "Returns policy type schema definitions") - @ApiResponses( - value = { + @ApiResponses(value = { @ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), // - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)}) + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)}) public ResponseEntity<String> getPolicySchemas( // - @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get the definitions for.") // - @RequestParam(name = "ric", required = false) String ricName) { + @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") // + @RequestParam(name = "ric", required = false) String ricName) { if (ricName == null) { Collection<PolicyType> types = this.policyTypes.getAll(); return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); @@ -119,13 +118,13 @@ public class PolicyController { @GetMapping("/policy_schema") @ApiOperation(value = "Returns one policy type schema definition") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy schema", response = Object.class), @ApiResponse(code = 404, message = "The policy type is not found", response = String.class)}) public ResponseEntity<String> getPolicySchema( // - @ApiParam(name = "id", required = true, value = "The identity of the policy type to get the definition for.") // - @RequestParam(name = "id", required = true) String id) { + @ApiParam(name = "id", required = true, + value = "The identity of the policy type to get the definition for.") // + @RequestParam(name = "id", required = true) String id) { try { PolicyType type = policyTypes.getType(id); return new ResponseEntity<>(type.schema(), HttpStatus.OK); @@ -136,17 +135,13 @@ public class PolicyController { @GetMapping("/policy_types") @ApiOperation(value = "Query policy type names") - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "Policy type names", - response = String.class, - responseContainer = "List"), - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)}) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Policy type names", response = String.class, + responseContainer = "List"), + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)}) public ResponseEntity<String> getPolicyTypes( // - @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get types for.") // - @RequestParam(name = "ric", required = false) String ricName) { + @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") // + @RequestParam(name = "ric", required = false) String ricName) { if (ricName == null) { Collection<PolicyType> types = this.policyTypes.getAll(); return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK); @@ -162,14 +157,13 @@ public class PolicyController { @GetMapping("/policy") @ApiOperation(value = "Returns a policy configuration") // - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy found", response = Object.class), // @ApiResponse(code = 404, message = "Policy is not found")} // ) public ResponseEntity<String> getPolicy( // - @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // - @RequestParam(name = "id", required = true) String id) { + @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // + @RequestParam(name = "id", required = true) String id) { try { Policy p = policies.getPolicy(id); return new ResponseEntity<>(p.json(), HttpStatus.OK); @@ -180,57 +174,55 @@ public class PolicyController { @DeleteMapping("/policy") @ApiOperation(value = "Delete a policy", response = Object.class) - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class), @ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class), @ApiResponse(code = 404, message = "Policy is not found", response = String.class), - @ApiResponse(code = 423, message = "NearRT-RIC is not operational", response = String.class)}) + @ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class)}) public Mono<ResponseEntity<Object>> deletePolicy( // - @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // - @RequestParam(name = "id", required = true) String id) { + @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // + @RequestParam(name = "id", required = true) String id) { try { Policy policy = policies.getPolicy(id); keepServiceAlive(policy.ownerServiceId()); Ric ric = policy.ric(); return ric.getLock().lock(LockType.SHARED) // - .flatMap(notUsed -> assertRicStateIdle(ric)) // - .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) // - .doOnNext(notUsed -> policies.remove(policy)) // - .flatMap(client -> client.deletePolicy(policy)) // - .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // - .doOnError(notUsed -> ric.getLock().unlockBlocking()) // - .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT))) - .onErrorResume(this::handleException); + .flatMap(notUsed -> assertRicStateIdle(ric)) // + .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) // + .doOnNext(notUsed -> policies.remove(policy)) // + .flatMap(client -> client.deletePolicy(policy)) // + .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // + .doOnError(notUsed -> ric.getLock().unlockBlocking()) // + .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT))) + .onErrorResume(this::handleException); } catch (ServiceException e) { return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } } @PutMapping(path = "/policy") - @ApiOperation(value = "Put a policy", response = String.class) - @ApiResponses( - value = { // + @ApiOperation(value = "Put a policy", response = VoidResponse.class) + @ApiResponses(value = { // @ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), // @ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), // - @ApiResponse(code = 423, message = "NearRT-RIC is not operational", response = String.class), // - @ApiResponse(code = 404, message = "NearRT-RIC or policy type is not found", response = String.class) // - }) + @ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class), // + @ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found", response = String.class) // + }) public Mono<ResponseEntity<Object>> putPolicy( // - @ApiParam(name = "type", required = false, value = "The name of the policy type.") // - @RequestParam(name = "type", required = false, defaultValue = "") String typeName, // - @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // - @RequestParam(name = "id", required = true) String instanceId, // - @ApiParam(name = "ric", required = true, value = "The name of the NearRT-RIC where the policy will be " + // - "created.") // - @RequestParam(name = "ric", required = true) String ricName, // - @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") // - @RequestParam(name = "service", required = true) String service, // - @ApiParam(name = "transient", required = false, value = "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 NearRT-RIC.") // - @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, // - @RequestBody Object jsonBody) { + @ApiParam(name = "type", required = false, value = "The name of the policy type.") // + @RequestParam(name = "type", required = false, defaultValue = "") String typeName, // + @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") // + @RequestParam(name = "id", required = true) String instanceId, // + @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + // + "created.") // + @RequestParam(name = "ric", required = true) String ricName, // + @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") // + @RequestParam(name = "service", required = true) String service, // + @ApiParam(name = "transient", required = false, value = "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-RT RIC.") // + @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, // + @RequestBody Object jsonBody) { String jsonString = gson.toJson(jsonBody); Ric ric = rics.get(ricName); @@ -240,28 +232,28 @@ public class PolicyController { return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } Policy policy = ImmutablePolicy.builder() // - .id(instanceId) // - .json(jsonString) // - .type(type) // - .ric(ric) // - .ownerServiceId(service) // - .lastModified(Instant.now()) // - .isTransient(isTransient) // - .build(); + .id(instanceId) // + .json(jsonString) // + .type(type) // + .ric(ric) // + .ownerServiceId(service) // + .lastModified(Instant.now()) // + .isTransient(isTransient) // + .build(); final boolean isCreate = this.policies.get(policy.id()) == null; return ric.getLock().lock(LockType.SHARED) // - .flatMap(notUsed -> assertRicStateIdle(ric)) // - .flatMap(notUsed -> checkSupportedType(ric, type)) // - .flatMap(notUsed -> validateModifiedPolicy(policy)) // - .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) // - .flatMap(client -> client.putPolicy(policy)) // - .doOnNext(notUsed -> policies.put(policy)) // - .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // - .doOnError(trowable -> ric.getLock().unlockBlocking()) // - .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) // - .onErrorResume(this::handleException); + .flatMap(notUsed -> assertRicStateIdle(ric)) // + .flatMap(notUsed -> checkSupportedType(ric, type)) // + .flatMap(notUsed -> validateModifiedPolicy(policy)) // + .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) // + .flatMap(client -> client.putPolicy(policy)) // + .doOnNext(notUsed -> policies.put(policy)) // + .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // + .doOnError(trowable -> ric.getLock().unlockBlocking()) // + .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) // + .onErrorResume(this::handleException); } @SuppressWarnings({"unchecked"}) @@ -287,8 +279,8 @@ public class PolicyController { Policy current = this.policies.get(policy.id()); if (current != null && !current.ric().id().equals(policy.ric().id())) { RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + // - ", RIC name: " + current.ric().id() + // - ", new name: " + policy.ric().id(), HttpStatus.CONFLICT); + ", RIC name: " + current.ric().id() + // + ", new name: " + policy.ric().id(), HttpStatus.CONFLICT); logger.debug("Request rejected, {}", e.getMessage()); return Mono.error(e); } @@ -299,7 +291,7 @@ public class PolicyController { if (!ric.isSupportingType(type.id())) { logger.debug("Request rejected, type not supported, RIC: {}", ric); RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(), - HttpStatus.NOT_FOUND); + HttpStatus.NOT_FOUND); return Mono.error(e); } return Mono.just("OK"); @@ -311,30 +303,29 @@ public class PolicyController { } else { logger.debug("Request rejected RIC not IDLE, ric: {}", ric); RejectionException e = new RejectionException( - "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED); + "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED); return Mono.error(e); } } @GetMapping("/policies") @ApiOperation(value = "Query policies") - @ApiResponses( - value = { + @ApiResponses(value = { @ApiResponse(code = 200, message = "Policies", response = PolicyInfo.class, responseContainer = "List"), - @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)}) + @ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)}) public ResponseEntity<String> getPolicies( // - @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") // - @RequestParam(name = "type", required = false) String type, // - @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get policies for.") // - @RequestParam(name = "ric", required = false) String ric, // - @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") // - @RequestParam(name = "service", required = false) String service) // + @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") // + @RequestParam(name = "type", required = false) String type, // + @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") // + @RequestParam(name = "ric", required = false) String ric, // + @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") // + @RequestParam(name = "service", required = false) String service) // { if ((type != null && this.policyTypes.get(type) == null)) { return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND); } if ((ric != null && this.rics.get(ric) == null)) { - return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND); + return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND); } String filteredPolicies = policiesToJson(filter(type, ric, service)); @@ -342,23 +333,24 @@ public class PolicyController { } @GetMapping("/policy_ids") - @ApiOperation(value = "Query policies, only IDs returned") - @ApiResponses( - value = {@ApiResponse(code = 200, message = "Policy ids", response = String.class, responseContainer = "List"), - @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)}) + @ApiOperation(value = "Query policies, only policy identities returned") + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Policy identitiess", response = String.class, + responseContainer = "List"), + @ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)}) public ResponseEntity<String> getPolicyIds( // - @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") // - @RequestParam(name = "type", required = false) String type, // - @ApiParam(name = "ric", required = false, value = "The name of the NearRT-RIC to get policies for.") // - @RequestParam(name = "ric", required = false) String ric, // - @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") // - @RequestParam(name = "service", required = false) String service) // + @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") // + @RequestParam(name = "type", required = false) String type, // + @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") // + @RequestParam(name = "ric", required = false) String ric, // + @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") // + @RequestParam(name = "service", required = false) String service) // { if ((type != null && this.policyTypes.get(type) == null)) { return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND); } if ((ric != null && this.rics.get(ric) == null)) { - return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND); + return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND); } String policyIdsJson = toPolicyIdsJson(filter(type, ric, service)); @@ -367,22 +359,20 @@ public class PolicyController { @GetMapping("/policy_status") @ApiOperation(value = "Returns a policy status") // - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy status", response = Object.class), // @ApiResponse(code = 404, message = "Policy is not found", response = String.class)} // ) public Mono<ResponseEntity<String>> getPolicyStatus( // - @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam( - name = "id", // - required = true) String id) { + @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam(name = "id", // + required = true) String id) { try { Policy policy = policies.getPolicy(id); return a1ClientFactory.createA1Client(policy.ric()) // - .flatMap(client -> client.getPolicyStatus(policy)) // - .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK))) - .onErrorResume(this::handleException); + .flatMap(client -> client.getPolicyStatus(policy)) // + .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK))) + .onErrorResume(this::handleException); } catch (ServiceException e) { return Mono.just(new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND)); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java index 4cb91c0d..21e5b96c 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java @@ -35,7 +35,7 @@ public class PolicyInfo { @ApiModelProperty(value = "name of the policy type") public String type; - @ApiModelProperty(value = "identity of the target NearRT-RIC") + @ApiModelProperty(value = "identity of the target Near-RT RIC") public String ric; @ApiModelProperty(value = "the configuration of the policy") @@ -47,8 +47,7 @@ public class PolicyInfo { @ApiModelProperty(value = "timestamp, last modification time") public String lastModified; - PolicyInfo() { - } + PolicyInfo() {} public boolean validate() { return id != null && type != null && ric != null && json != null && service != null && lastModified != null; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java index 4257a263..467afdb9 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java @@ -30,7 +30,7 @@ import org.immutables.gson.Gson; @Gson.TypeAdapters @ApiModel(value = "ric_info_v1") class RicInfo { - @ApiModelProperty(value = "identity of the NearRT-RIC") + @ApiModelProperty(value = "identity of the Near-RT RIC") public final String ricName; @ApiModelProperty(value = "O1 identities for managed entities") diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java index 5036356e..31c4f3bf 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java @@ -54,22 +54,21 @@ public class RicRepositoryController { PolicyTypes types; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // /** * Example: http://localhost:8081/rics?managedElementId=kista_1 */ @GetMapping("/ric") @ApiOperation(value = "Returns the name of a RIC managing one Mananged Element") - @ApiResponses( - value = { // - @ApiResponse(code = 200, message = "NearRT-RIC is found", response = String.class), // - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class) // - }) + @ApiResponses(value = { // + @ApiResponse(code = 200, message = "Near-RT RIC is found", response = String.class), // + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class) // + }) public ResponseEntity<String> getRic( // - @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") // - @RequestParam(name = "managedElementId", required = true) String managedElementId) { + @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") // + @RequestParam(name = "managedElementId", required = true) String managedElementId) { Optional<Ric> ric = this.rics.lookupRicForManagedElement(managedElementId); if (ric.isPresent()) { @@ -83,14 +82,13 @@ public class RicRepositoryController { * @return a Json array of all RIC data Example: http://localhost:8081/ric */ @GetMapping("/rics") - @ApiOperation(value = "Query NearRT-RIC information") - @ApiResponses( - value = { // + @ApiOperation(value = "Query Near-RT RIC information") + @ApiResponses(value = { // @ApiResponse(code = 200, message = "OK", response = RicInfo.class, responseContainer = "List"), // @ApiResponse(code = 404, message = "Policy type is not found", response = String.class)}) public ResponseEntity<String> getRics( // - @ApiParam(name = "policyType", required = false, value = "The name of the policy type") // - @RequestParam(name = "policyType", required = false) String supportingPolicyType) { + @ApiParam(name = "policyType", required = false, value = "The name of the policy type") // + @RequestParam(name = "policyType", required = false) String supportingPolicyType) { if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) { return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND); } @@ -99,7 +97,7 @@ public class RicRepositoryController { for (Ric ric : rics.getRics()) { if (supportingPolicyType == null || ric.isSupportingType(supportingPolicyType)) { result.add(new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(), - ric.getState().toString())); + ric.getState().toString())); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java index bb85ad14..8f51c686 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java @@ -59,7 +59,7 @@ public class ServiceController { private final Policies policies; private static Gson gson = new GsonBuilder() // - .create(); // + .create(); // @Autowired ServiceController(Services services, Policies policies) { @@ -69,13 +69,12 @@ public class ServiceController { @GetMapping("/services") @ApiOperation(value = "Returns service information") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "OK", response = ServiceStatus.class, responseContainer = "List"), // @ApiResponse(code = 404, message = "Service is not found", response = String.class)}) public ResponseEntity<String> getServices(// - @ApiParam(name = "name", required = false, value = "The name of the service") // - @RequestParam(name = "name", required = false) String name) { + @ApiParam(name = "name", required = false, value = "The name of the service") // + @RequestParam(name = "name", required = false) String name) { if (name != null && this.services.get(name) == null) { return new ResponseEntity<>("Service not found", HttpStatus.NOT_FOUND); } @@ -93,11 +92,11 @@ public class ServiceController { private ServiceStatus toServiceStatus(Service s) { return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(), - s.getCallbackUrl()); + s.getCallbackUrl()); } private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo) - throws ServiceException, MalformedURLException { + throws ServiceException, MalformedURLException { if (registrationInfo.serviceName.isEmpty()) { throw new ServiceException("Missing mandatory parameter 'serviceName'"); } @@ -110,14 +109,13 @@ public class ServiceController { } @ApiOperation(value = "Register a service") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service updated", response = String.class), @ApiResponse(code = 201, message = "Service created", response = String.class), // @ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted", response = String.class)}) @PutMapping("/service") public ResponseEntity<String> putService(// - @RequestBody ServiceRegistrationInfo registrationInfo) { + @RequestBody ServiceRegistrationInfo registrationInfo) { try { validateRegistrationInfo(registrationInfo); final boolean isCreate = this.services.get(registrationInfo.serviceName) == null; @@ -129,15 +127,14 @@ public class ServiceController { } @ApiOperation(value = "Delete a service") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 204, message = "Service deleted"), @ApiResponse(code = 204, message = "Not used", response = VoidResponse.class), @ApiResponse(code = 404, message = "Service not found", response = String.class)}) @DeleteMapping("/services") public ResponseEntity<String> deleteService(// - @ApiParam(name = "name", required = true, value = "The name of the service") // - @RequestParam(name = "name", required = true) String serviceName) { + @ApiParam(name = "name", required = true, value = "The name of the service") // + @RequestParam(name = "name", required = true) String serviceName) { try { Service service = removeService(serviceName); // Remove the policies from the repo and let the consistency monitoring @@ -150,14 +147,13 @@ public class ServiceController { } @ApiOperation(value = "Heartbeat from a serice") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"), @ApiResponse(code = 404, message = "The service is not found, needs re-registration")}) @PutMapping("/services/keepalive") public ResponseEntity<String> keepAliveService(// - @ApiParam(name = "name", required = true, value = "The name of the service") // - @RequestParam(name = "name", required = true) String serviceName) { + @ApiParam(name = "name", required = true, value = "The name of the service") // + @RequestParam(name = "name", required = true) String serviceName) { try { services.getService(serviceName).keepAlive(); return new ResponseEntity<>("OK", HttpStatus.OK); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java index 89016919..38e9b3b4 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java @@ -34,8 +34,7 @@ public class ServiceRegistrationInfo { @SerializedName("serviceName") public String serviceName = ""; - @ApiModelProperty( - value = "keep alive interval for the service. This is a heartbeat supervision of the service, " + @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, " + "which in regular intevals must invoke a 'keepAlive' REST call. " + "When a service does not invoke this call within the given time, it is considered unavailble. " + "An unavailable service will be automatically deregistered and its policies will be deleted. " @@ -47,8 +46,7 @@ public class ServiceRegistrationInfo { @SerializedName("callbackUrl") public String callbackUrl = ""; - public ServiceRegistrationInfo() { - } + public ServiceRegistrationInfo() {} public ServiceRegistrationInfo(String name, long keepAliveIntervalSeconds, String callbackUrl) { this.serviceName = name; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java index e520a282..492b1ea8 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java @@ -37,10 +37,9 @@ public class StatusController { @GetMapping("/status") @ApiOperation(value = "Returns status and statistics of this service") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service is living", response = String.class) // - }) + }) public Mono<ResponseEntity<String>> getStatus() { return Mono.just(new ResponseEntity<>("hunky dory", HttpStatus.OK)); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java index 68c1d717..478b8c27 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java @@ -31,6 +31,5 @@ public class Consts { public static final String V2_API_ROOT = "/v2"; public static final String V2_API_NAME = "A1 Policy Management Version 2.0 (in progress)"; - private Consts() { - } + private Consts() {} } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java index 2ba63abc..988fbc2a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java @@ -35,7 +35,7 @@ import reactor.core.publisher.Mono; class ErrorResponse { private static Gson gson = new GsonBuilder() // - .create(); // + .create(); // // Returned as body for all failed REST calls @ApiModel(value = "error_information", description = "Problem as defined in https://tools.ietf.org/html/rfc7807") @@ -60,16 +60,14 @@ class ErrorResponse { this.status = status; } - @ApiModelProperty( - example = "503", - value = "The HTTP status code generated by the origin server for this occurrence of the problem. ") + @ApiModelProperty(example = "503", + value = "The HTTP status code generated by the origin server for this occurrence of the problem. ") public Integer getStatus() { return status; } - @ApiModelProperty( - example = "Policy type not found", - value = " A human-readable explanation specific to this occurrence of the problem.") + @ApiModelProperty(example = "Policy type not found", + value = " A human-readable explanation specific to this occurrence of the problem.") public String getDetail() { return this.detail; } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java index 9290ca07..fea1d097 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java @@ -25,6 +25,7 @@ import io.swagger.annotations.ApiModel; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "json_object", description = "A JSON object. The schema is defined by the Policy Type") +@ApiModel(value = "json_object", + description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.") class JsonObject { } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java deleted file mode 100644 index ff1b8edc..00000000 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * ONAP : ccsdk oran - * ====================================================================== - * 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=================================== - */ - -package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2; - -import io.swagger.annotations.ApiModel; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@ApiModel(value = "json_schema", description = "A JSON schema following http://json-schema.org/draft-07/schema") -class JsonSchema { -} diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java index 9bf6c4b5..8d3ecf6c 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java @@ -66,7 +66,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti import reactor.core.publisher.Mono; @RestController("PolicyControllerV2") -@Api(tags = Consts.V2_API_NAME) +@Api(tags = {Consts.V2_API_NAME}, description = "Policy management") public class PolicyController { public static class RejectionException extends Exception { @@ -94,39 +94,41 @@ public class PolicyController { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // @GetMapping(path = Consts.V2_API_ROOT + "/policy-schemas", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Returns policy type schema definitions") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy schemas", response = PolicySchemaList.class), // - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class)}) + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getPolicySchemas( // - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = false, - value = "The identity of the NearRT-RIC to get the definitions for.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, - @ApiParam( - name = Consts.POLICY_TYPE_ID_PARAM, - required = true, - value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") // - @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) { + @ApiParam(name = Consts.RIC_ID_PARAM, required = false, + value = "The identity of the Near-RT RIC to get the definitions for.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, + @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = true, + value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") // + @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) { try { - if (ricId == null && policyTypeId == null) { + Ric ric = ricId == null ? null : rics.getRic(ricId); + if (ric == null && policyTypeId == null) { Collection<PolicyType> types = this.policyTypes.getAll(); return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); - } else if (ricId != null && policyTypeId != null) { - Collection<PolicyType> types = new ArrayList<>(); - if (rics.getRic(ricId).isSupportingType(policyTypeId)) { - types.add(policyTypes.getType(policyTypeId)); + } else if (ric != null && policyTypeId != null) { + synchronized (ric) { + assertRicStateIdleSync(ric); + Collection<PolicyType> types = new ArrayList<>(); + if (rics.getRic(ricId).isSupportingType(policyTypeId)) { + types.add(policyTypes.getType(policyTypeId)); + } + return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); + } + } else if (ric != null) { + synchronized (ric) { + assertRicStateIdleSync(ric); + Collection<PolicyType> types = rics.getRic(ricId).getSupportedPolicyTypes(); + return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); } - return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); - } else if (ricId != null) { - Collection<PolicyType> types = rics.getRic(ricId).getSupportedPolicyTypes(); - return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK); } else { Collection<PolicyType> types = new ArrayList<>(); types.add(policyTypes.getType(policyTypeId)); @@ -139,15 +141,12 @@ public class PolicyController { @GetMapping(path = Consts.V2_API_ROOT + "/policy-types", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Query policy type identities", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiResponses( - value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class), - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class)}) + @ApiResponses(value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class), + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getPolicyTypes( // - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = false, - value = "The identity of the NearRT-RIC to get types for.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) { + @ApiParam(name = Consts.RIC_ID_PARAM, required = false, + value = "The identity of the Near-RT RIC to get types for.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) { if (ricId == null) { Collection<PolicyType> types = this.policyTypes.getAll(); return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK); @@ -163,14 +162,13 @@ public class PolicyController { @GetMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Returns a policy configuration") // - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy found", response = JsonObject.class), // @ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} // ) public ResponseEntity<Object> getPolicy( // - @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // - @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) { + @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // + @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) { try { Policy p = policies.getPolicy(id); return new ResponseEntity<>(p.json(), HttpStatus.OK); @@ -181,31 +179,28 @@ public class PolicyController { @DeleteMapping(Consts.V2_API_ROOT + "/policy") @ApiOperation(value = "Delete a policy") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class), @ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class), @ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class), - @ApiResponse( - code = 423, - message = "NearRT-RIC is not operational", - response = ErrorResponse.ErrorInfo.class)}) + @ApiResponse(code = 423, message = "Near-RT RIC is not operational", + response = ErrorResponse.ErrorInfo.class)}) public Mono<ResponseEntity<Object>> deletePolicy( // - @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // - @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) { + @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // + @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) { try { Policy policy = policies.getPolicy(id); keepServiceAlive(policy.ownerServiceId()); Ric ric = policy.ric(); return ric.getLock().lock(LockType.SHARED) // - .flatMap(notUsed -> assertRicStateIdle(ric)) // - .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) // - .doOnNext(notUsed -> policies.remove(policy)) // - .flatMap(client -> client.deletePolicy(policy)) // - .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // - .doOnError(notUsed -> ric.getLock().unlockBlocking()) // - .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT))) - .onErrorResume(this::handleException); + .flatMap(notUsed -> assertRicStateIdle(ric)) // + .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) // + .doOnNext(notUsed -> policies.remove(policy)) // + .flatMap(client -> client.deletePolicy(policy)) // + .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // + .doOnError(notUsed -> ric.getLock().unlockBlocking()) // + .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT))) + .onErrorResume(this::handleException); } catch (ServiceException e) { return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND); } @@ -213,74 +208,64 @@ public class PolicyController { @PutMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Create or update a policy") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), // @ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), // - @ApiResponse( - code = 423, - message = "NearRT-RIC is not operational", - response = ErrorResponse.ErrorInfo.class), // - @ApiResponse( - code = 404, - message = "NearRT-RIC or policy type is not found", - response = ErrorResponse.ErrorInfo.class) // - }) + @ApiResponse(code = 423, message = "Near-RT RIC is not operational", + response = ErrorResponse.ErrorInfo.class), // + @ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found", + response = ErrorResponse.ErrorInfo.class) // + }) public Mono<ResponseEntity<Object>> putPolicy( // - @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") // - @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, // - @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // - @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, // - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = true, - value = "The identity of the NearRT-RIC where the policy will be " + // - "created.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, // - @ApiParam( - name = Consts.SERVICE_ID_PARAM, - required = true, - value = "The identity of the service creating the policy.") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, // - @ApiParam( - name = Consts.TRANSIENT_PARAM, - required = false, - value = "If the policy is transient or not (boolean " + // - "defaulted to false). A policy is transient if it will not be recreated in the NearRT-RIC " + // - "when it has been lost (for instance due to a restart)") // - @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, // - @RequestBody Object jsonBody) { + @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") // + @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, // + @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") // + @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, // + @ApiParam(name = Consts.RIC_ID_PARAM, required = true, + value = "The identity of the Near-RT RIC where the policy will be " + // + "created.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, // + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, + value = "The identity of the service creating the policy.") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, // + @ApiParam(name = Consts.TRANSIENT_PARAM, required = false, + value = "If the policy is transient or not (boolean " + // + "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC " + + // + "when it has been lost (for instance due to a restart)") // + @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, // + @RequestBody Object jsonBody) { String jsonString = gson.toJson(jsonBody); Ric ric = rics.get(ricId); PolicyType type = policyTypes.get(policyTypeId); keepServiceAlive(serviceId); if (ric == null || type == null) { - return ErrorResponse.createMono("NearRT-RIC or policy type not found", HttpStatus.NOT_FOUND); + return ErrorResponse.createMono("Near-RT RIC or policy type not found", HttpStatus.NOT_FOUND); } Policy policy = ImmutablePolicy.builder() // - .id(instanceId) // - .json(jsonString) // - .type(type) // - .ric(ric) // - .ownerServiceId(serviceId) // - .lastModified(Instant.now()) // - .isTransient(isTransient) // - .build(); + .id(instanceId) // + .json(jsonString) // + .type(type) // + .ric(ric) // + .ownerServiceId(serviceId) // + .lastModified(Instant.now()) // + .isTransient(isTransient) // + .build(); final boolean isCreate = this.policies.get(policy.id()) == null; return ric.getLock().lock(LockType.SHARED) // - .flatMap(notUsed -> assertRicStateIdle(ric)) // - .flatMap(notUsed -> checkSupportedType(ric, type)) // - .flatMap(notUsed -> validateModifiedPolicy(policy)) // - .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) // - .flatMap(client -> client.putPolicy(policy)) // - .doOnNext(notUsed -> policies.put(policy)) // - .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // - .doOnError(trowable -> ric.getLock().unlockBlocking()) // - .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) // - .onErrorResume(this::handleException); + .flatMap(notUsed -> assertRicStateIdle(ric)) // + .flatMap(notUsed -> checkSupportedType(ric, type)) // + .flatMap(notUsed -> validateModifiedPolicy(policy)) // + .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) // + .flatMap(client -> client.putPolicy(policy)) // + .doOnNext(notUsed -> policies.put(policy)) // + .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // + .doOnError(trowable -> ric.getLock().unlockBlocking()) // + .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) // + .onErrorResume(this::handleException); } private Mono<ResponseEntity<Object>> handleException(Throwable throwable) { @@ -300,8 +285,8 @@ public class PolicyController { Policy current = this.policies.get(policy.id()); if (current != null && !current.ric().id().equals(policy.ric().id())) { RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + // - ", RIC ID: " + current.ric().id() + // - ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT); + ", RIC ID: " + current.ric().id() + // + ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT); logger.debug("Request rejected, {}", e.getMessage()); return Mono.error(e); } @@ -312,56 +297,56 @@ public class PolicyController { if (!ric.isSupportingType(type.id())) { logger.debug("Request rejected, type not supported, RIC: {}", ric); RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(), - HttpStatus.NOT_FOUND); + HttpStatus.NOT_FOUND); return Mono.error(e); } return Mono.just("{}"); } + private void assertRicStateIdleSync(Ric ric) throws ServiceException { + if (ric.getState() != Ric.RicState.AVAILABLE) { + throw new ServiceException("Near-RT RIC: " + ric.id() + " is " + ric.getState()); + } + } + private Mono<Object> assertRicStateIdle(Ric ric) { if (ric.getState() == Ric.RicState.AVAILABLE) { return Mono.just("{}"); } else { - logger.debug("Request rejected RIC not IDLE, ric: {}", ric); + logger.debug("Request rejected Near-RT RIC not IDLE, ric: {}", ric); RejectionException e = new RejectionException( - "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED); + "Near-RT RIC: is not operational, id: " + ric.id() + ", state: " + ric.getState(), + HttpStatus.LOCKED); return Mono.error(e); } } + static final String GET_POLICIES_QUERY_DETAILS = + "Returns a list of A1 policies matching given search criteria. <br>" // + + "If several query parameters are defined, the policies matching all conditions are returned."; + @GetMapping(path = Consts.V2_API_ROOT + "/policies", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation( - value = "Query policies", - notes = "If several query parameters are defined, the policies matching all conditions are returned") - @ApiResponses( - value = { // + @ApiOperation(value = "Query for existing A1 policies", notes = GET_POLICIES_QUERY_DETAILS) + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class), - @ApiResponse( - code = 404, - message = "NearRT-RIC, policy type or service not found", - response = ErrorResponse.ErrorInfo.class)}) + @ApiResponse(code = 404, message = "Near-RT RIC, policy type or service not found", + response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getPolicies( // - @ApiParam( - name = Consts.POLICY_TYPE_ID_PARAM, - required = false, - value = "The identity of the policy type to get policies for.") // - @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, // - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = false, - value = "The identity of the NearRT-RIC to get policies for.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, // - @ApiParam( - name = Consts.SERVICE_ID_PARAM, - required = false, - value = "The identity of the service to get policies for.") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) // + @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, + value = "The identity of the policy type to get policies for.") // + @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, // + @ApiParam(name = Consts.RIC_ID_PARAM, required = false, + value = "The identity of the Near-RT RIC to get policies for.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, // + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, + value = "The identity of the service to get policies for.") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) // { if ((type != null && this.policyTypes.get(type) == null)) { return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND); } if ((ric != null && this.rics.get(ric) == null)) { - return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND); + return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND); } String filteredPolicies = policiesToJson(filter(type, ric, service)); @@ -369,36 +354,26 @@ public class PolicyController { } @GetMapping(path = Consts.V2_API_ROOT + "/policy-ids", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Query policies, only IDs returned") - @ApiResponses( - value = { // - @ApiResponse(code = 200, message = "Policy ids", response = PolicyIdList.class), - @ApiResponse( - code = 404, - message = "NearRT-RIC or type not found", - response = ErrorResponse.ErrorInfo.class)}) + @ApiOperation(value = "Query policies, only policy identities are returned", notes = GET_POLICIES_QUERY_DETAILS) + @ApiResponses(value = { // + @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class), @ApiResponse( + code = 404, message = "Near-RT RIC or type not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getPolicyIds( // - @ApiParam( - name = Consts.POLICY_TYPE_ID_PARAM, - required = false, - value = "The identity of the policy type to get policies for.") // - @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, // - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = false, - value = "The identity of the NearRT-RIC to get policies for.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, // - @ApiParam( - name = Consts.SERVICE_ID_PARAM, - required = false, - value = "The identity of the service to get policies for.") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) // + @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, + value = "The identity of the policy type to get policies for.") // + @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, // + @ApiParam(name = Consts.RIC_ID_PARAM, required = false, + value = "The identity of the Near-RT RIC to get policies for.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, // + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, + value = "The identity of the service to get policies for.") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) // { if ((policyTypeId != null && this.policyTypes.get(policyTypeId) == null)) { return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND); } if ((ricId != null && this.rics.get(ricId) == null)) { - return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND); + return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND); } String policyIdsJson = toPolicyIdsJson(filter(policyTypeId, ricId, serviceId)); @@ -407,21 +382,20 @@ public class PolicyController { @GetMapping(path = Consts.V2_API_ROOT + "/policy-status", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Returns a policy status") // - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Policy status", response = JsonObject.class), // @ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} // ) public Mono<ResponseEntity<Object>> getPolicyStatus( // - @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") // - @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) { + @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") // + @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) { try { Policy policy = policies.getPolicy(policyId); return a1ClientFactory.createA1Client(policy.ric()) // - .flatMap(client -> client.getPolicyStatus(policy)) // - .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK))) - .onErrorResume(this::handleException); + .flatMap(client -> client.getPolicyStatus(policy)) // + .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK))) + .onErrorResume(this::handleException); } catch (ServiceException e) { return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java index 4ba3dc79..ab812790 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java @@ -42,7 +42,7 @@ public class PolicyInfo { @JsonProperty("policy_type_id") public String policyTypeId; - @ApiModelProperty(value = "identity of the target NearRT-RIC") + @ApiModelProperty(value = "identity of the target Near-RT RIC") @SerializedName("ric_id") @JsonProperty("ric_id") public String ricId; @@ -62,12 +62,11 @@ public class PolicyInfo { @JsonProperty("last_modified") public String lastModified; - PolicyInfo() { - } + PolicyInfo() {} public boolean validate() { return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null - && lastModified != null; + && lastModified != null; } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java index 66296f50..d550db4e 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java @@ -37,7 +37,8 @@ import org.immutables.gson.Gson; @ApiModel(value = "policy_schema_list_v2", description = "Policy type json schemas") public class PolicySchemaList { - @ApiModelProperty(value = "Policy type json schemas") + @ApiModelProperty( + value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema") @SerializedName("policy_schemas") @JsonProperty("policy_schemas") public final Collection<Object> schemas; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java index 63b4bd60..938d5106 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java @@ -31,22 +31,22 @@ import java.util.Collection; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "ric_info_v2", description = "Information for a NearRT-RIC") +@ApiModel(value = "ric_info_v2", description = "Information for a Near-RT RIC") public class RicInfo { @Gson.TypeAdapters - @ApiModel(value = "ric_state_v2", description = "Represents the states for a NearRT-RIC") + @ApiModel(value = "ric_state_v2", description = "Represents the states for a Near-RT RIC") public enum RicState { UNAVAILABLE, AVAILABLE, SYNCHRONIZING, CONSISTENCY_CHECK } - private static final String STATE_DESCRIPTION = "State for the NearRT-RIC, values: \n" - + "UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent \n" - + "AVAILABLE: The normal state. Policies can be configured. +\n" - + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the NearRT-RIC. Policies cannot be configured. \n" - + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured."; + private static final String STATE_DESCRIPTION = "State for the Near-RT RIC, values: \n" + + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n" + + "AVAILABLE: The normal state. Policies can be configured. +\n" + + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n" + + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured."; - @ApiModelProperty(value = "identity of the NearRT-RIC") + @ApiModelProperty(value = "identity of the Near-RT RIC") @SerializedName("ric_id") @JsonProperty("ric_id") public final String ricId; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java index 7ca49be7..7932dc54 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java @@ -31,10 +31,10 @@ import java.util.Collection; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "ric_info_list_v2", description = "List of NearRT-RIC information") +@ApiModel(value = "ric_info_list_v2", description = "List of Near-RT RIC information") public class RicInfoList { - @ApiModelProperty(value = "List of NearRT-RIC information") + @ApiModelProperty(value = "List of Near-RT RIC information") @SerializedName("rics") @JsonProperty("rics") public final Collection<RicInfo> rics; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java index a0987ada..a7505016 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java @@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController("RicRepositoryControllerV2") -@Api(tags = Consts.V2_API_NAME) +@Api(tags = {Consts.V2_API_NAME}) public class RicRepositoryController { @Autowired @@ -56,30 +56,30 @@ public class RicRepositoryController { PolicyTypes types; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // + + private static final String GET_RIC_BRIEF = "Returns info for a Near-RT RIC"; + private static final String GET_RIC_DETAILS = + "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" // + + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU)."; /** * Example: http://localhost:8081/v2/ric?managed_element_id=kista_1 */ @GetMapping(path = Consts.V2_API_ROOT + "/ric", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Returns info for the NearRT-RIC with the given identity or managing one Mananged Element") - @ApiResponses( - value = { // - @ApiResponse(code = 200, message = "NearRT-RIC is found", response = RicInfo.class), // - @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class) // - }) + @ApiOperation(value = GET_RIC_BRIEF, notes = GET_RIC_DETAILS) + @ApiResponses(value = { // + @ApiResponse(code = 200, message = "Near-RT RIC is found", response = RicInfo.class), // + @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class) // + }) public ResponseEntity<Object> getRic( // - @ApiParam( - name = Consts.MANAGED_ELEMENT_ID_PARAM, - required = false, - value = "The identity of a Managed Element. If given, the NearRT-RIC managing the ME is returned.") // - @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId, - @ApiParam( - name = Consts.RIC_ID_PARAM, - required = false, - value = "The identity of a NearRT-RIC to get information for.") // - @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) { + @ApiParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false, + value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") // + @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId, + @ApiParam(name = Consts.RIC_ID_PARAM, required = false, + value = "The identity of a Near-RT RIC to get information for.") // + @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) { try { if (managedElementId != null && ricId != null) { return ErrorResponse.create("Give one query parameter", HttpStatus.BAD_REQUEST); @@ -88,7 +88,7 @@ public class RicRepositoryController { if (ric.isPresent()) { return new ResponseEntity<>(gson.toJson(toRicInfo(ric.get())), HttpStatus.OK); } else { - return ErrorResponse.create("No NearRT-RIC managing the ME is found", HttpStatus.NOT_FOUND); + return ErrorResponse.create("No Near-RT RIC managing the ME is found", HttpStatus.NOT_FOUND); } } else if (ricId != null) { RicInfo info = toRicInfo(this.rics.getRic(ricId)); @@ -101,21 +101,21 @@ public class RicRepositoryController { } } + static final String QUERY_RIC_INFO_DETAILS = + "The call returns all Near-RT RICs that supports a given policy type identity"; + /** * @return a Json array of all RIC data Example: http://localhost:8081/v2/ric */ @GetMapping(path = Consts.V2_API_ROOT + "/rics", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Query NearRT-RIC information") - @ApiResponses( - value = { // + @ApiOperation(value = "Query Near-RT RIC information", notes = QUERY_RIC_INFO_DETAILS) + @ApiResponses(value = { // @ApiResponse(code = 200, message = "OK", response = RicInfoList.class), // @ApiResponse(code = 404, message = "Policy type is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getRics( // - @ApiParam( - name = Consts.POLICY_TYPE_ID_PARAM, - required = false, - value = "The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned") // - @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) { + @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, + value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") // + @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) { if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) { return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND); } @@ -131,20 +131,22 @@ public class RicRepositoryController { } private RicInfo.RicState toRicState(Ric.RicState state) { - if (state == Ric.RicState.AVAILABLE) { - return RicInfo.RicState.AVAILABLE; - } else if (state == Ric.RicState.CONSISTENCY_CHECK) { - return RicInfo.RicState.CONSISTENCY_CHECK; - } else if (state == Ric.RicState.SYNCHRONIZING) { - return RicInfo.RicState.SYNCHRONIZING; - } else if (state == Ric.RicState.UNAVAILABLE) { - return RicInfo.RicState.UNAVAILABLE; + switch (state) { + case AVAILABLE: + return RicInfo.RicState.AVAILABLE; + case CONSISTENCY_CHECK: + return RicInfo.RicState.CONSISTENCY_CHECK; + case SYNCHRONIZING: + return RicInfo.RicState.SYNCHRONIZING; + case UNAVAILABLE: + return RicInfo.RicState.UNAVAILABLE; + default: + return RicInfo.RicState.UNAVAILABLE; } - return RicInfo.RicState.UNAVAILABLE; } private RicInfo toRicInfo(Ric ric) { return new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(), - toRicState(ric.getState())); + toRicState(ric.getState())); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java index 19d68161..73e421be 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java @@ -60,7 +60,7 @@ public class ServiceController { private final Policies policies; private static Gson gson = new GsonBuilder() // - .create(); // + .create(); // @Autowired ServiceController(Services services, Policies policies) { @@ -68,17 +68,19 @@ public class ServiceController { this.policies = policies; } + private static final String GET_SERVICE_DETAILS = + "Either information about a registered service with given identity or all registered services are returned."; + @GetMapping(path = Consts.V2_API_ROOT + "/services", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Returns service information") - @ApiResponses( - value = { // + @ApiOperation(value = "Returns service information", notes = GET_SERVICE_DETAILS) + @ApiResponses(value = { // @ApiResponse(code = 200, message = "OK", response = ServiceStatusList.class), // @ApiResponse(code = 404, message = "Service is not found", response = ErrorResponse.ErrorInfo.class)}) public ResponseEntity<Object> getServices(// - @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) { + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) { if (name != null && this.services.get(name) == null) { - return ErrorResponse.create("Service type not found", HttpStatus.NOT_FOUND); + return ErrorResponse.create("Service not found", HttpStatus.NOT_FOUND); } Collection<ServiceStatus> servicesStatus = new ArrayList<>(); @@ -94,11 +96,11 @@ public class ServiceController { private ServiceStatus toServiceStatus(Service s) { return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(), - s.getCallbackUrl()); + s.getCallbackUrl()); } private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo) - throws ServiceException, MalformedURLException { + throws ServiceException, MalformedURLException { if (registrationInfo.serviceId.isEmpty()) { throw new ServiceException("Missing mandatory parameter 'serviceName'"); } @@ -110,18 +112,22 @@ public class ServiceController { } } - @ApiOperation(value = "Register a service") - @ApiResponses( - value = { // + private static final String REGISTER_SERVICE_DETAILS = "Registering a service is needed to:" // + + "<ul>" // + + "<li>Get callbacks.</li>" // + + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"// + + "</ul>" // + ; + + @ApiOperation(value = "Register a service", notes = REGISTER_SERVICE_DETAILS) + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service updated"), @ApiResponse(code = 201, message = "Service created"), // - @ApiResponse( - code = 400, - message = "The ServiceRegistrationInfo is not accepted", - response = ErrorResponse.ErrorInfo.class)}) + @ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted", + response = ErrorResponse.ErrorInfo.class)}) @PutMapping(Consts.V2_API_ROOT + "/services") public ResponseEntity<Object> putService(// - @RequestBody ServiceRegistrationInfo registrationInfo) { + @RequestBody ServiceRegistrationInfo registrationInfo) { try { validateRegistrationInfo(registrationInfo); final boolean isCreate = this.services.get(registrationInfo.serviceId) == null; @@ -132,16 +138,15 @@ public class ServiceController { } } - @ApiOperation(value = "Delete a service") - @ApiResponses( - value = { // - @ApiResponse(code = 204, message = "Service deleted"), + @ApiOperation(value = "Unregister a service") + @ApiResponses(value = { // + @ApiResponse(code = 204, message = "Service unregistered"), @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class), @ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)}) @DeleteMapping(Consts.V2_API_ROOT + "/services") public ResponseEntity<Object> deleteService(// - @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The name of the service") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) { + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) { try { Service service = removeService(serviceName); // Remove the policies from the repo and let the consistency monitoring @@ -154,18 +159,15 @@ public class ServiceController { } @ApiOperation(value = "Heartbeat indicates that the service is running") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"), // - @ApiResponse( - code = 404, - message = "The service is not found, needs re-registration", - response = ErrorResponse.ErrorInfo.class)}) + @ApiResponse(code = 404, message = "The service is not found, needs re-registration", + response = ErrorResponse.ErrorInfo.class)}) @PutMapping(Consts.V2_API_ROOT + "/services/keepalive") public ResponseEntity<Object> keepAliveService(// - @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") // - @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) { + @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") // + @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) { try { services.getService(serviceName).keepAlive(); return new ResponseEntity<>(HttpStatus.OK); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java index 30fcb7d6..68afc384 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java @@ -37,8 +37,7 @@ public class ServiceRegistrationInfo { @JsonProperty("service_id") public String serviceId = ""; - @ApiModelProperty( - value = "keep alive interval for the service. This is a heartbeat supervision of the service, " + @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, " + "which in regular intevals must invoke a 'keepAlive' REST call. " + "When a service does not invoke this call within the given time, it is considered unavailble. " + "An unavailable service will be automatically deregistered and its policies will be deleted. " @@ -52,8 +51,7 @@ public class ServiceRegistrationInfo { @JsonProperty("callback_url") public String callbackUrl = ""; - public ServiceRegistrationInfo() { - } + public ServiceRegistrationInfo() {} public ServiceRegistrationInfo(String id, long keepAliveIntervalSeconds, String callbackUrl) { this.serviceId = id; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java index f47cdd5c..1c5a473b 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java @@ -52,10 +52,9 @@ public class StatusController { @GetMapping(path = Consts.V2_API_ROOT + "/status", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Returns status and statistics of this service") - @ApiResponses( - value = { // + @ApiResponses(value = { // @ApiResponse(code = 200, message = "Service is living", response = StatusInfo.class) // - }) + }) public Mono<ResponseEntity<Object>> getStatus() { StatusInfo info = new StatusInfo("hunky dory"); return Mono.just(new ResponseEntity<>(info, HttpStatus.OK)); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java index a4da4bdd..bafa8453 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java @@ -123,7 +123,7 @@ public class DmaapMessageConsumer { String producerTopicUrl = applicationConfig.getDmaapProducerTopicUrl(); String consumerTopicUrl = applicationConfig.getDmaapConsumerTopicUrl(); return (producerTopicUrl != null && consumerTopicUrl != null && !producerTopicUrl.isEmpty() - && !consumerTopicUrl.isEmpty()); + && !consumerTopicUrl.isEmpty()); } private <T> List<T> parseList(String jsonString, Class<T> clazz) { @@ -144,16 +144,16 @@ public class DmaapMessageConsumer { private void sendErrorResponse(String response) { DmaapRequestMessage fakeRequest = ImmutableDmaapRequestMessage.builder() // - .apiVersion("") // - .correlationId("") // - .operation(DmaapRequestMessage.Operation.PUT) // - .originatorId("") // - .payload(Optional.empty()) // - .requestId("") // - .target("") // - .timestamp("") // - .url("URL") // - .build(); + .apiVersion("") // + .correlationId("") // + .operation(DmaapRequestMessage.Operation.PUT) // + .originatorId("") // + .payload(Optional.empty()) // + .requestId("") // + .target("") // + .timestamp("") // + .url("URL") // + .build(); getDmaapMessageHandler().sendDmaapResponse(response, fakeRequest, HttpStatus.BAD_REQUEST).block(); } @@ -175,7 +175,7 @@ public class DmaapMessageConsumer { return parseMessages(response.getBody()); } else { throw new ServiceException("Cannot fetch because of Error respons: " + response.getStatusCode().toString() - + " " + response.getBody()); + + " " + response.getBody()); } } @@ -189,7 +189,7 @@ public class DmaapMessageConsumer { String pmsBaseUrl = "http://localhost:" + this.localServerHttpPort; AsyncRestClient pmsClient = new AsyncRestClient(pmsBaseUrl, this.applicationConfig.getWebClientConfig()); AsyncRestClient producer = new AsyncRestClient(this.applicationConfig.getDmaapProducerTopicUrl(), - this.applicationConfig.getWebClientConfig()); + this.applicationConfig.getWebClientConfig()); this.dmaapMessageHandler = new DmaapMessageHandler(producer, pmsClient); } return this.dmaapMessageHandler; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java index 2d7b5063..967cab1d 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java @@ -65,12 +65,13 @@ public class DmaapMessageHandler { Mono<String> createTask(DmaapRequestMessage dmaapRequestMessage) { return this.invokePolicyManagementService(dmaapRequestMessage) // - .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) // - .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, response.getStatusCode())); + .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) // + .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, + response.getStatusCode())); } private Mono<ResponseEntity<String>> handlePolicyManagementServiceCallError(Throwable error, - DmaapRequestMessage dmaapRequestMessage) { + DmaapRequestMessage dmaapRequestMessage) { logger.debug("Policy Management Service call failed: {}", error.getMessage()); HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; String errorMessage = error.getMessage(); @@ -85,13 +86,13 @@ public class DmaapMessageHandler { logger.warn("Unexpected exception ", error); } return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) // - .flatMap(notUsed -> Mono.empty()); + .flatMap(notUsed -> Mono.empty()); } public Mono<String> sendDmaapResponse(String response, DmaapRequestMessage dmaapRequestMessage, HttpStatus status) { return createDmaapResponseMessage(dmaapRequestMessage, response, status) // - .flatMap(this::sendToDmaap) // - .onErrorResume(this::handleResponseCallError); + .flatMap(this::sendToDmaap) // + .onErrorResume(this::handleResponseCallError); } private Mono<ResponseEntity<String>> invokePolicyManagementService(DmaapRequestMessage dmaapRequestMessage) { @@ -132,16 +133,16 @@ public class DmaapMessageHandler { } private Mono<String> createDmaapResponseMessage(DmaapRequestMessage dmaapRequestMessage, String response, - HttpStatus status) { + HttpStatus status) { DmaapResponseMessage dmaapResponseMessage = ImmutableDmaapResponseMessage.builder() // - .status(status.toString()) // - .message(response == null ? "" : response) // - .type("response") // - .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) // - .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) // - .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) // - .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) // - .build(); + .status(status.toString()) // + .message(response == null ? "" : response) // + .type("response") // + .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) // + .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) // + .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) // + .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) // + .build(); String str = gson.toJson(dmaapResponseMessage); return Mono.just(str); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java index 0cde2e12..6892a503 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java @@ -87,7 +87,7 @@ public class Lock { @Override public synchronized String toString() { return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: " - + this.lockRequestQueue.size(); + + this.lockRequestQueue.size(); } /** returns the current number of granted locks */ diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java index 154809de..c7f471eb 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java @@ -32,7 +32,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1Protocol import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; /** - * Holds information about a NearRT-RIC. + * Holds information about a Near-RT RIC. */ public class Ric { @@ -134,7 +134,7 @@ public class Ric { @Override public synchronized String toString() { return Ric.class.getSimpleName() + ": " + "name: " + id() + ", state: " + state + ", baseUrl: " - + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds(); + + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds(); } /** @@ -142,7 +142,7 @@ public class Ric { */ public enum RicState { /** - * The Policy Management Service's view of the NearRT-RIC may be inconsistent. + * The Policy Management Service's view of the Near-RT RIC may be inconsistent. */ UNAVAILABLE, /** @@ -150,12 +150,12 @@ public class Ric { */ AVAILABLE, /** - * The Policy Management Service is synchronizing the view of the NearRT-RIC. + * The Policy Management Service is synchronizing the view of the Near-RT RIC. */ SYNCHRONIZING, /** - * A consistency check between the Policy Management Service and the NearRT-RIC + * A consistency check between the Policy Management Service and the Near-RT RIC * is done */ CONSISTENCY_CHECK diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java index 840de817..ba81d222 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java @@ -39,19 +39,18 @@ class EnvironmentProcessor { private static final int DEFAULT_CONSUL_PORT = 8500; private static final Logger logger = LoggerFactory.getLogger(EnvironmentProcessor.class); - private EnvironmentProcessor() { - } + private EnvironmentProcessor() {} static Mono<EnvProperties> readEnvironmentVariables(Properties systemEnvironment) { EnvProperties envProperties; try { envProperties = ImmutableEnvProperties.builder() // - .consulHost(getConsulHost(systemEnvironment)) // - .consulPort(getConsultPort(systemEnvironment)) // - .cbsName(getConfigBindingService(systemEnvironment)) // - .appName(getService(systemEnvironment)) // - .build(); + .consulHost(getConsulHost(systemEnvironment)) // + .consulPort(getConsultPort(systemEnvironment)) // + .cbsName(getConfigBindingService(systemEnvironment)) // + .appName(getService(systemEnvironment)) // + .build(); } catch (EnvironmentLoaderException e) { return Mono.error(e); } @@ -61,27 +60,27 @@ class EnvironmentProcessor { private static String getConsulHost(Properties systemEnvironments) throws EnvironmentLoaderException { return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_HOST")) - .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined")); + .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined")); } private static Integer getConsultPort(Properties systemEnvironments) { return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_PORT")) // - .map(Integer::valueOf) // - .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul); + .map(Integer::valueOf) // + .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul); } private static String getConfigBindingService(Properties systemEnvironments) throws EnvironmentLoaderException { return Optional.ofNullable(systemEnvironments.getProperty("CONFIG_BINDING_SERVICE")) // - .orElseThrow( - () -> new EnvironmentLoaderException("$CONFIG_BINDING_SERVICE environment has not been defined")); + .orElseThrow(() -> new EnvironmentLoaderException( + "$CONFIG_BINDING_SERVICE environment has not been defined")); } private static String getService(Properties systemEnvironments) throws EnvironmentLoaderException { return Optional - .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME")) - .orElse(systemEnvironments.getProperty("SERVICE_NAME"))) - .orElseThrow(() -> new EnvironmentLoaderException( - "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")); + .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME")) + .orElse(systemEnvironments.getProperty("SERVICE_NAME"))) + .orElseThrow(() -> new EnvironmentLoaderException( + "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")); } private static Integer getDefaultPortOfConsul() { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java index 248ba32d..5da066f3 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java @@ -94,7 +94,7 @@ public class RefreshConfigTask { @Autowired public RefreshConfigTask(ApplicationConfig appConfig, Rics rics, Policies policies, Services services, - PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) { + PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) { this.appConfig = appConfig; this.rics = rics; this.policies = policies; @@ -107,9 +107,10 @@ public class RefreshConfigTask { logger.debug("Starting refreshConfigTask"); stop(); refreshTask = createRefreshTask() // - .subscribe(notUsed -> logger.debug("Refreshed configuration data"), - throwable -> logger.error("Configuration refresh terminated due to exception {}", throwable.toString()), - () -> logger.error("Configuration refresh terminated")); + .subscribe( + notUsed -> logger.debug("Refreshed configuration data"), throwable -> logger + .error("Configuration refresh terminated due to exception {}", throwable.toString()), + () -> logger.error("Configuration refresh terminated")); } public void stop() { @@ -120,44 +121,44 @@ public class RefreshConfigTask { Flux<RicConfigUpdate.Type> createRefreshTask() { Flux<JsonObject> loadFromFile = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) // - .filter(notUsed -> !this.isConsulUsed) // - .flatMap(notUsed -> loadConfigurationFromFile()) // - .onErrorResume(this::ignoreErrorFlux) // - .doOnNext(json -> logger.debug("loadFromFile succeeded")) // - .doOnTerminate(() -> logger.error("loadFromFile Terminate")); + .filter(notUsed -> !this.isConsulUsed) // + .flatMap(notUsed -> loadConfigurationFromFile()) // + .onErrorResume(this::ignoreErrorFlux) // + .doOnNext(json -> logger.debug("loadFromFile succeeded")) // + .doOnTerminate(() -> logger.error("loadFromFile Terminate")); Flux<JsonObject> loadFromConsul = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) // - .flatMap(i -> getEnvironment(systemEnvironment)) // - .flatMap(this::createCbsClient) // - .flatMap(this::getFromCbs) // - .onErrorResume(this::ignoreErrorMono) // - .doOnNext(json -> logger.debug("loadFromConsul succeeded")) // - .doOnNext(json -> this.isConsulUsed = true) // - .doOnTerminate(() -> logger.error("loadFromConsul Terminated")); + .flatMap(i -> getEnvironment(systemEnvironment)) // + .flatMap(this::createCbsClient) // + .flatMap(this::getFromCbs) // + .onErrorResume(this::ignoreErrorMono) // + .doOnNext(json -> logger.debug("loadFromConsul succeeded")) // + .doOnNext(json -> this.isConsulUsed = true) // + .doOnTerminate(() -> logger.error("loadFromConsul Terminated")); return Flux.merge(loadFromFile, loadFromConsul) // - .flatMap(this::parseConfiguration) // - .flatMap(this::updateConfig) // - .doOnNext(this::handleUpdatedRicConfig) // - .flatMap(configUpdate -> Flux.just(configUpdate.getType())) // - .doOnTerminate(() -> logger.error("Configuration refresh task is terminated")); + .flatMap(this::parseConfiguration) // + .flatMap(this::updateConfig) // + .doOnNext(this::handleUpdatedRicConfig) // + .flatMap(configUpdate -> Flux.just(configUpdate.getType())) // + .doOnTerminate(() -> logger.error("Configuration refresh task is terminated")); } Mono<EnvProperties> getEnvironment(Properties systemEnvironment) { return EnvironmentProcessor.readEnvironmentVariables(systemEnvironment) // - .onErrorResume(t -> Mono.empty()); + .onErrorResume(t -> Mono.empty()); } Mono<CbsClient> createCbsClient(EnvProperties env) { return CbsClientFactory.createCbsClient(env) // - .onErrorResume(this::ignoreErrorMono); + .onErrorResume(this::ignoreErrorMono); } private Mono<JsonObject> getFromCbs(CbsClient cbsClient) { try { final CbsRequest getConfigRequest = CbsRequests.getAll(RequestDiagnosticContext.create()); return cbsClient.get(getConfigRequest) // - .onErrorResume(this::ignoreErrorMono); + .onErrorResume(this::ignoreErrorMono); } catch (Exception e) { return ignoreErrorMono(e); } @@ -223,7 +224,7 @@ public class RefreshConfigTask { void runRicSynchronization(Ric ric) { RicSynchronizationTask synchronizationTask = - new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services); synchronizationTask.run(ric); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java index 9bad36cc..46059fd9 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java @@ -44,7 +44,7 @@ import reactor.core.publisher.Mono; /** * Regularly checks the existing rics towards the local repository to keep it - * consistent. When the policy types or instances in the NearRT-RIC is not + * consistent. When the policy types or instances in the Near-RT RIC is not * consistent, a synchronization is performed. */ @Component @@ -83,7 +83,7 @@ public class RicSupervision { @Autowired public RicSupervision(Rics rics, Policies policies, A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, - Services services) { + Services services) { this.rics = rics; this.policies = policies; this.a1ClientFactory = a1ClientFactory; @@ -102,19 +102,19 @@ public class RicSupervision { private Flux<RicData> createTask() { return Flux.fromIterable(rics.getRics()) // - .flatMap(this::createRicData) // - .flatMap(this::checkOneRic); + .flatMap(this::createRicData) // + .flatMap(this::checkOneRic); } private Mono<RicData> checkOneRic(RicData ricData) { return checkRicState(ricData) // - .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) // - .flatMap(notUsed -> setRicState(ricData)) // - .flatMap(x -> checkRicPolicies(ricData)) // - .flatMap(x -> checkRicPolicyTypes(ricData)) // - .doOnNext(x -> onRicCheckedOk(ricData)) // - .doOnError(t -> onRicCheckedError(t, ricData)) // - .onErrorResume(throwable -> Mono.empty()); + .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) // + .flatMap(notUsed -> setRicState(ricData)) // + .flatMap(x -> checkRicPolicies(ricData)) // + .flatMap(x -> checkRicPolicyTypes(ricData)) // + .doOnNext(x -> onRicCheckedOk(ricData)) // + .doOnError(t -> onRicCheckedError(t, ricData)) // + .onErrorResume(throwable -> Mono.empty()); } private void onRicCheckedError(Throwable t, RicData ricData) { @@ -148,14 +148,14 @@ public class RicSupervision { private Mono<RicData> createRicData(Ric ric) { return Mono.just(ric) // - .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) // - .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client))); + .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) // + .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client))); } private Mono<RicData> checkRicState(RicData ric) { if (ric.ric.getState() == RicState.UNAVAILABLE) { return startSynchronization(ric) // - .onErrorResume(t -> Mono.empty()); + .onErrorResume(t -> Mono.empty()); } else if (ric.ric.getState() == RicState.SYNCHRONIZING || ric.ric.getState() == RicState.CONSISTENCY_CHECK) { return Mono.empty(); } else { @@ -165,7 +165,7 @@ public class RicSupervision { private Mono<RicData> checkRicPolicies(RicData ric) { return ric.getClient().getPolicyIdentities() // - .flatMap(ricP -> validateInstances(ricP, ric)); + .flatMap(ricP -> validateInstances(ricP, ric)); } private Mono<RicData> validateInstances(Collection<String> ricPolicies, RicData ric) { @@ -185,7 +185,7 @@ public class RicSupervision { private Mono<RicData> checkRicPolicyTypes(RicData ric) { return ric.getClient().getPolicyTypeIdentities() // - .flatMap(ricTypes -> validateTypes(ricTypes, ric)); + .flatMap(ricTypes -> validateTypes(ricTypes, ric)); } private Mono<RicData> validateTypes(Collection<String> ricTypes, RicData ric) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java index d8cd04e2..ccc57852 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java @@ -43,12 +43,12 @@ import reactor.core.publisher.Mono; import reactor.core.publisher.SignalType; /** - * Synchronizes the content of a NearRT-RIC with the content in the repository. + * Synchronizes the content of a Near-RT RIC with the content in the repository. * This means: * <p> * load all policy types * <p> - * send all policy instances to the NearRT-RIC + * send all policy instances to the Near-RT RIC * <p> * if that fails remove all policy instances * <p> @@ -66,7 +66,7 @@ public class RicSynchronizationTask { private final Services services; public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies, - Services services) { + Services services) { this.a1ClientFactory = a1ClientFactory; this.policyTypes = policyTypes; this.policies = policies; @@ -82,27 +82,28 @@ public class RicSynchronizationTask { } ric.getLock().lock(LockType.EXCLUSIVE) // - .flatMap(notUsed -> setRicState(ric)) // - .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) // - .flatMapMany(client -> runSynchronization(ric, client)) // - .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable)) - .subscribe(new BaseSubscriber<Object>() { - @Override - protected void hookOnError(Throwable throwable) { - logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(), throwable.getMessage()); - ric.setState(RicState.UNAVAILABLE); - } - - @Override - protected void hookOnComplete() { - onSynchronizationComplete(ric); - } - - @Override - protected void hookFinally(SignalType type) { - ric.getLock().unlockBlocking(); - } - }); + .flatMap(notUsed -> setRicState(ric)) // + .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) // + .flatMapMany(client -> runSynchronization(ric, client)) // + .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable)) + .subscribe(new BaseSubscriber<Object>() { + @Override + protected void hookOnError(Throwable throwable) { + logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(), + throwable.getMessage()); + ric.setState(RicState.UNAVAILABLE); + } + + @Override + protected void hookOnComplete() { + onSynchronizationComplete(ric); + } + + @Override + protected void hookFinally(SignalType type) { + ric.getLock().unlockBlocking(); + } + }); } @SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields @@ -136,12 +137,12 @@ public class RicSynchronizationTask { String url = service.getCallbackUrl(); if (url.length() > 0) { createNotificationClient(url) // - .put("", body) // - .subscribe( // - notUsed -> logger.debug("Service {} notified", service.getName()), - throwable -> logger.warn("Service notification failed for service: {}. Cause: {}", - service.getName(), throwable.getMessage()), - () -> logger.debug("All services notified")); + .put("", body) // + .subscribe( // + notUsed -> logger.debug("Service {} notified", service.getName()), + throwable -> logger.warn("Service notification failed for service: {}. Cause: {}", + service.getName(), throwable.getMessage()), + () -> logger.debug("All services notified")); } } } @@ -151,10 +152,10 @@ public class RicSynchronizationTask { deleteAllPoliciesInRepository(ric); Flux<PolicyType> synchronizedTypes = this.a1ClientFactory.createA1Client(ric) // - .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client)); + .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client)); Flux<?> deletePoliciesInRic = this.a1ClientFactory.createA1Client(ric) // - .flatMapMany(A1Client::deleteAllPolicies) // - .doOnComplete(() -> deleteAllPoliciesInRepository(ric)); + .flatMapMany(A1Client::deleteAllPolicies) // + .doOnComplete(() -> deleteAllPoliciesInRepository(ric)); return Flux.concat(synchronizedTypes, deletePoliciesInRic); } @@ -165,11 +166,11 @@ public class RicSynchronizationTask { private Flux<PolicyType> synchronizePolicyTypes(Ric ric, A1Client a1Client) { return a1Client.getPolicyTypeIdentities() // - .doOnNext(x -> ric.clearSupportedPolicyTypes()) // - .flatMapMany(Flux::fromIterable) // - .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) // - .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) // - .doOnNext(ric::addSupportedPolicyType); // + .doOnNext(x -> ric.clearSupportedPolicyTypes()) // + .flatMapMany(Flux::fromIterable) // + .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) // + .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) // + .doOnNext(ric::addSupportedPolicyType); // } private Mono<PolicyType> getPolicyType(String policyTypeId, A1Client a1Client) { @@ -177,7 +178,7 @@ public class RicSynchronizationTask { return Mono.just(policyTypes.get(policyTypeId)); } return a1Client.getPolicyTypeSchema(policyTypeId) // - .flatMap(schema -> createPolicyType(policyTypeId, schema)); + .flatMap(schema -> createPolicyType(policyTypeId, schema)); } private Mono<PolicyType> createPolicyType(String policyTypeId, String schema) { @@ -195,7 +196,7 @@ public class RicSynchronizationTask { private Flux<Policy> putPolicy(Policy policy, Ric ric, A1Client a1Client) { logger.debug("Recreating policy: {}, for ric: {}", policy.id(), ric.getConfig().ricId()); return a1Client.putPolicy(policy) // - .flatMapMany(notUsed -> Flux.just(policy)); + .flatMapMany(notUsed -> Flux.just(policy)); } private boolean checkTransient(Policy policy) { @@ -207,8 +208,8 @@ public class RicSynchronizationTask { private Flux<Policy> recreateAllPoliciesInRic(Ric ric, A1Client a1Client) { return Flux.fromIterable(policies.getForRic(ric.id())) // - .filter(policy -> !checkTransient(policy)) // - .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC); + .filter(policy -> !checkTransient(policy)) // + .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC); } } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java index a46ff1f9..4c063e2d 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java @@ -62,7 +62,7 @@ public class ServiceSupervision { } public ServiceSupervision(Services services, Policies policies, A1ClientFactory a1ClientFactory, - Duration checkInterval) { + Duration checkInterval) { this.services = services; this.policies = policies; this.a1ClientFactory = a1ClientFactory; @@ -77,32 +77,32 @@ public class ServiceSupervision { private Flux<?> createTask() { return Flux.interval(this.checkInterval) // - .flatMap(notUsed -> checkAllServices()); + .flatMap(notUsed -> checkAllServices()); } Flux<Policy> checkAllServices() { return Flux.fromIterable(services.getAll()) // - .filter(Service::isExpired) // - .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) // - .doOnNext(service -> services.remove(service.getName())) // - .flatMap(this::getAllPoliciesForService) // - .flatMap(this::deletePolicy, CONCURRENCY_RIC); + .filter(Service::isExpired) // + .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) // + .doOnNext(service -> services.remove(service.getName())) // + .flatMap(this::getAllPoliciesForService) // + .flatMap(this::deletePolicy, CONCURRENCY_RIC); } @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally private Flux<Policy> deletePolicy(Policy policy) { Lock lock = policy.ric().getLock(); return lock.lock(LockType.SHARED) // - .doOnNext(notUsed -> policies.remove(policy)) // - .flatMap(notUsed -> deletePolicyInRic(policy)) - .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}", policy.id(), - policy.ownerServiceId())) // - .doOnNext(notUsed -> lock.unlockBlocking()) // - .doOnError(throwable -> lock.unlockBlocking()) // - .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(), - throwable.getMessage())) // - .flatMapMany(notUsed -> Flux.just(policy)) // - .onErrorResume(throwable -> Flux.empty()); + .doOnNext(notUsed -> policies.remove(policy)) // + .flatMap(notUsed -> deletePolicyInRic(policy)) + .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}", + policy.id(), policy.ownerServiceId())) // + .doOnNext(notUsed -> lock.unlockBlocking()) // + .doOnError(throwable -> lock.unlockBlocking()) // + .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(), + throwable.getMessage())) // + .flatMapMany(notUsed -> Flux.just(policy)) // + .onErrorResume(throwable -> Flux.empty()); } private Flux<Policy> getAllPoliciesForService(Service service) { @@ -111,14 +111,14 @@ public class ServiceSupervision { private Mono<Policy> deletePolicyInRic(Policy policy) { return a1ClientFactory.createA1Client(policy.ric()) // - .flatMap(client -> client.deletePolicy(policy) // - .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) // - .map(nothing -> policy)); + .flatMap(client -> client.deletePolicy(policy) // + .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) // + .map(nothing -> policy)); } private Mono<String> handleDeleteFromRicFailure(Policy policy, Throwable e) { logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.id(), policy.ric().id(), - e.getMessage()); + e.getMessage()); return Mono.empty(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java index 6ccf162c..ab318615 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java @@ -57,8 +57,7 @@ import org.springframework.util.StringUtils; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) class MockPolicyManagementService { @@ -170,7 +169,7 @@ class MockPolicyManagementService { await().until(() -> rics.size() == noOfRicsInConfigFile); } catch (Exception e) { logger.info("Loaded rics: {}, and no of rics in config file: {} never matched!", rics.size(), - StringUtils.countOccurrencesOf(json, "baseUrl")); + StringUtils.countOccurrencesOf(json, "baseUrl")); } } @@ -186,14 +185,14 @@ class MockPolicyManagementService { String json = getConfigJsonFromFile(); Policy policy = ImmutablePolicy.builder() // - .id("typelessPolicy") // - .json(json) // - .ownerServiceId("MockPolicyManagementService") // - .ric(ric) // - .type(unnamedPolicyType) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id("typelessPolicy") // + .json(json) // + .ownerServiceId("MockPolicyManagementService") // + .ric(ric) // + .type(unnamedPolicyType) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); this.policies.put(policy); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java index 685c5611..89adf68a 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java @@ -70,11 +70,11 @@ class A1ClientFactoryTest { private static ImmutableRicConfig ricConfig(String controllerName) { return ImmutableRicConfig.builder() // - .ricId(RIC_NAME) // - .baseUrl("baseUrl") // - .managedElementIds(new Vector<>()) // - .controllerName(controllerName) // - .build(); + .ricId(RIC_NAME) // + .baseUrl("baseUrl") // + .managedElementIds(new Vector<>()) // + .controllerName(controllerName) // + .build(); } @BeforeEach @@ -114,9 +114,9 @@ class A1ClientFactoryTest { doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any()); StepVerifier.create(factoryUnderTest.createA1Client(ric)) // - .expectSubscription() // - .expectError() // - .verify(); + .expectSubscription() // + .expectError() // + .verify(); assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Protocol negotiation failed for " + ric.id()); } @@ -156,11 +156,11 @@ class A1ClientFactoryTest { private void whenGetGetControllerConfigReturn() throws ServiceException { ControllerConfig controllerCfg = ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password("pass") // - .userName("user") // - .build(); + .name("name") // + .baseUrl("baseUrl") // + .password("pass") // + .userName("user") // + .build(); when(applicationConfigMock.getControllerConfig(any())).thenReturn(controllerCfg); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java index 855a917f..cec5c2c6 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java @@ -36,8 +36,7 @@ import reactor.core.publisher.Mono; public class A1ClientHelper { - private A1ClientHelper() { - } + private A1ClientHelper() {} protected static Mono<String> createOutputJsonResponse(String key, String value) { JSONObject paramsJson = new JSONObject(); @@ -49,23 +48,23 @@ public class A1ClientHelper { protected static Ric createRic(String url) { RicConfig cfg = ImmutableRicConfig.builder().ricId("ric") // - .baseUrl(url) // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("") // - .build(); + .baseUrl(url) // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("") // + .build(); return new Ric(cfg); } protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) { return ImmutablePolicy.builder() // - .id(policyId) // - .json(json) // - .ownerServiceId("service") // - .ric(createRic(nearRtRicUrl)) // - .type(createPolicyType(type)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(policyId) // + .json(json) // + .ownerServiceId("service") // + .ric(createRic(nearRtRicUrl)) // + .type(createPolicyType(type)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); } protected static PolicyType createPolicyType(String name) { diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java index 28343322..36bbda57 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java @@ -69,8 +69,8 @@ class AsyncRestClientTest { @Test void testGetNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -82,14 +82,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPutNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -101,7 +101,7 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test @@ -118,14 +118,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPostNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -137,14 +137,14 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test void testPostWithAuthHeaderNoError() { mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); + .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // + .setBody(TEST_JSON)); Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD); StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); @@ -156,6 +156,6 @@ class AsyncRestClientTest { Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java index d6d12ba1..6aacc914 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java @@ -67,11 +67,11 @@ class OscA1ClientTest { @BeforeEach void init() { RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId("name") // - .baseUrl("RicBaseUrl") // - .managedElementIds(new ArrayList<>()) // - .controllerName("") // - .build(); + .ricId("name") // + .baseUrl("RicBaseUrl") // + .managedElementIds(new ArrayList<>()) // + .controllerName("") // + .build(); asyncRestClientMock = mock(AsyncRestClient.class); clientUnderTest = new OscA1Client(ricConfig, asyncRestClientMock); } @@ -93,7 +93,7 @@ class OscA1ClientTest { Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString()); Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString()); when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp) - .thenReturn(policyIdsType2Resp); + .thenReturn(policyIdsType2Resp); List<String> returned = clientUnderTest.getPolicyIdentities().block(); @@ -113,7 +113,7 @@ class OscA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).get(POLICYTYPES_URL + POLICY_TYPE_1_ID); StepVerifier.create(returnedMono).expectNext(A1ClientHelper.getCreateSchema(policyType, POLICY_TYPE_1_ID)) - .expectComplete().verify(); + .expectComplete().verify(); } @Test @@ -144,9 +144,10 @@ class OscA1ClientTest { when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty()); clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)).block(); + .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) + .block(); verify(asyncRestClientMock).put(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID, - POLICY_JSON_VALID); + POLICY_JSON_VALID); } @Test @@ -154,7 +155,7 @@ class OscA1ClientTest { when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).delete(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID); StepVerifier.create(returnedMono).expectComplete().verify(); } @@ -165,7 +166,7 @@ class OscA1ClientTest { Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString()); Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString()); when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp) - .thenReturn(policyIdsType2Resp); + .thenReturn(policyIdsType2Resp); when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty()); Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java index b1323859..c2118c12 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java @@ -69,78 +69,78 @@ class SdncOnapA1ClientTest { void init() { asyncRestClientMock = mock(AsyncRestClient.class); ControllerConfig controllerCfg = ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password(CONTROLLER_PASSWORD) // - .userName(CONTROLLER_USERNAME) // - .build(); - - clientUnderTest = - new SdncOnapA1Client(A1ClientHelper.createRic(RIC_1_URL).getConfig(), controllerCfg, asyncRestClientMock); + .name("name") // + .baseUrl("baseUrl") // + .password(CONTROLLER_PASSWORD) // + .userName(CONTROLLER_USERNAME) // + .build(); + + clientUnderTest = new SdncOnapA1Client(A1ClientHelper.createRic(RIC_1_URL).getConfig(), controllerCfg, + asyncRestClientMock); } @Test void testGetPolicyTypeIdentities() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); whenAsyncPostThenReturn(policyTypeIdsResp); Mono<List<String>> returnedMono = clientUnderTest.getPolicyTypeIdentities(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectNext(policyTypeIds).expectComplete().verify(); } @Test void testGetPolicyIdentities() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .build(); String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID); Mono<String> policyIdsType1Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID); Mono<String> policyIdsType2Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(policyIdsType2Resp); Mono<List<String>> returnedMono = clientUnderTest.getPolicyIdentities(); StepVerifier.create(returnedMono).expectNext(Arrays.asList(POLICY_1_ID, POLICY_2_ID)).expectComplete().verify(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); } @Test void testGetValidPolicyType() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_VALID + ", \"statusSchema\": {} }"; @@ -149,16 +149,16 @@ class SdncOnapA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectNext(POLICY_TYPE_SCHEMA_VALID).expectComplete().verify(); } @Test void testGetInvalidPolicyType() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_INVALID + ", \"statusSchema\": {} }"; @@ -167,105 +167,105 @@ class SdncOnapA1ClientTest { Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectErrorMatches(throwable -> throwable instanceof JSONException).verify(); } @Test void testPutPolicy() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .policyInstance(POLICY_JSON_VALID) // - .properties(new ArrayList<String>()) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .policyInstance(POLICY_JSON_VALID) // + .properties(new ArrayList<String>()) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); whenAsyncPostThenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).postWithAuthHeader(PUT_POLICY_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectComplete().verify(); } @Test void testDeletePolicy() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .build(); String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams); whenAsyncPostThenReturn(Mono.empty()); Mono<String> returnedMono = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); + .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonString, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono).expectComplete().verify(); } @Test void testDeleteAllPolicies() { SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .build(); + .nearRtRicId(RIC_1_URL) // + .build(); String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .build(); String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .build(); String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_1_ID) // - .policyInstanceId(POLICY_1_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_1_ID) // + .policyInstanceId(POLICY_1_ID) // + .build(); String inputJsonStringDeletePolicy1 = SdncJsonHelper.createInputJsonString(inputParams); inputParams = ImmutableSdncOnapAdapterInput.builder() // - .nearRtRicId(RIC_1_URL) // - .policyTypeId(POLICY_TYPE_2_ID) // - .policyInstanceId(POLICY_2_ID) // - .build(); + .nearRtRicId(RIC_1_URL) // + .policyTypeId(POLICY_TYPE_2_ID) // + .policyInstanceId(POLICY_2_ID) // + .build(); String inputJsonStringDeletePolicy2 = SdncJsonHelper.createInputJsonString(inputParams); List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID); Mono<String> policyTypeIdsResp = - A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); + A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString()); List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID); Mono<String> policyIdsType1Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString()); List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID); Mono<String> policyIdsType2Resp = - A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); + A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString()); whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(Mono.empty()) - .thenReturn(policyIdsType2Resp).thenReturn(Mono.empty()); + .thenReturn(policyIdsType2Resp).thenReturn(Mono.empty()); Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies(); StepVerifier.create(returnedFlux).expectComplete().verify(); verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy1, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy2, - CONTROLLER_USERNAME, CONTROLLER_PASSWORD); + CONTROLLER_USERNAME, CONTROLLER_PASSWORD); } private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) { return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString())) - .thenReturn(response); + .thenReturn(response); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java index 1e9695c7..bbb2b8e9 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java @@ -78,11 +78,11 @@ class SdncOscA1ClientTest { private ControllerConfig controllerConfig() { return ImmutableControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password(CONTROLLER_PASSWORD) // - .userName(CONTROLLER_USERNAME) // - .build(); + .name("name") // + .baseUrl("baseUrl") // + .password(CONTROLLER_PASSWORD) // + .userName(CONTROLLER_USERNAME) // + .build(); } @BeforeEach @@ -90,7 +90,7 @@ class SdncOscA1ClientTest { Ric ric = A1ClientHelper.createRic(RIC_1_URL); clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), controllerConfig(), - asyncRestClientMock); + asyncRestClientMock); } @Test @@ -111,8 +111,8 @@ class SdncOscA1ClientTest { @Test void getPolicyTypeIdentities_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); String response = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID)); whenAsyncPostThenReturn(Mono.just(response)); @@ -124,11 +124,11 @@ class SdncOscA1ClientTest { String expUrl = RIC_1_URL + "/a1-p/policytypes"; ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -141,8 +141,8 @@ class SdncOscA1ClientTest { @Test void getTypeSchema_OSC() throws IOException { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); String ricResponse = loadFile("test_osc_get_schema_response.json"); JsonElement elem = gson().fromJson(ricResponse, JsonElement.class); @@ -153,7 +153,7 @@ class SdncOscA1ClientTest { JsonElement respJson = gson().fromJson(response, JsonElement.class); assertEquals("policyTypeId", respJson.getAsJsonObject().get("title").getAsString(), - "title should be updated to contain policyType ID"); + "title should be updated to contain policyType ID"); } @Test @@ -178,19 +178,19 @@ class SdncOscA1ClientTest { assertEquals(2, returned.size()); ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(policiesUrl()) // - .build(); + .nearRtRicUrl(policiesUrl()) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test void getPolicyIdentities_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + 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)); @@ -201,11 +201,11 @@ class SdncOscA1ClientTest { assertEquals(2, returned.size()); ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") // - .build(); + .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); + CONTROLLER_PASSWORD); } @Test @@ -213,15 +213,15 @@ class SdncOscA1ClientTest { whenPostReturnOkResponse(); String returned = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) - .block(); + .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() // - .nearRtRicUrl(expUrl) // - .body(POLICY_JSON_VALID) // - .build(); + .nearRtRicUrl(expUrl) // + .body(POLICY_JSON_VALID) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD); @@ -231,30 +231,30 @@ class SdncOscA1ClientTest { void putPolicyRejected() { final String policyJson = "{}"; AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() // - .body("NOK") // - .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR - .build(); + .body("NOK") // + .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR + .build(); String resp = SdncJsonHelper.createOutputJsonString(adapterOutput); whenAsyncPostThenReturn(Mono.just(resp)); Mono<String> returnedMono = clientUnderTest - .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID)); + .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID)); StepVerifier.create(returnedMono) // - .expectSubscription() // - .expectErrorMatches(t -> t instanceof WebClientResponseException) // - .verify(); + .expectSubscription() // + .expectErrorMatches(t -> t instanceof WebClientResponseException) // + .verify(); final String expUrl = policiesUrl() + "/" + POLICY_1_ID; AdapterRequest expRequestParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .body(policyJson) // - .build(); + .nearRtRicUrl(expUrl) // + .body(policyJson) // + .build(); String expRequest = SdncJsonHelper.createInputJsonString(expRequestParams); verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expRequest, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); + .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); } @Test @@ -262,18 +262,18 @@ class SdncOscA1ClientTest { whenPostReturnOkResponse(); String returned = clientUnderTest - .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)) - .block(); + .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() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -288,12 +288,12 @@ class SdncOscA1ClientTest { final String expUrl = policiesUrl() + "/" + POLICY_1_ID + "/status"; AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() // - .nearRtRicUrl(expUrl) // - .build(); + .nearRtRicUrl(expUrl) // + .build(); String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams); verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME, - CONTROLLER_PASSWORD); + CONTROLLER_PASSWORD); } @Test @@ -314,8 +314,8 @@ class SdncOscA1ClientTest { @Test void getVersion_OSC() { clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + A1ClientHelper.createRic(RIC_1_URL).getConfig(), // + controllerConfig(), asyncRestClientMock); whenAsyncPostThenReturn(Mono.error(new Exception("Error"))).thenReturn(Mono.just(createOkResponseString(true))); @@ -349,9 +349,9 @@ class SdncOscA1ClientTest { private String createOkResponseWithBody(Object body) { AdapterOutput output = ImmutableAdapterOutput.builder() // - .body(gson().toJson(body)) // - .httpStatus(HttpStatus.OK.value()) // - .build(); + .body(gson().toJson(body)) // + .httpStatus(HttpStatus.OK.value()) // + .build(); return SdncJsonHelper.createOutputJsonString(output); } @@ -367,6 +367,6 @@ class SdncOscA1ClientTest { private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) { return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString())) - .thenReturn(response); + .thenReturn(response); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java index 834a2a2f..b4709767 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java @@ -102,7 +102,7 @@ class StdA1ClientTest { when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.just(POLICY_JSON)); Mono<String> policyMono = - clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE)); + clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE)); verify(asyncRestClientMock).put(policiesBaseUrl() + POLICY_1_ID, POLICY_JSON); StepVerifier.create(policyMono).expectNext(POLICY_JSON).expectComplete().verify(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java index d0417a0a..0a75fd30 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java @@ -57,17 +57,17 @@ class ApplicationConfigParserTest { topicUrl = result.dmaapConsumerTopicUrl(); assertEquals( - "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100", - topicUrl, "controller contents"); + "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100", + topicUrl, "controller contents"); Map<String, ControllerConfig> controllers = result.controllerConfigs(); assertEquals(1, controllers.size(), "size"); ImmutableControllerConfig expectedControllerConfig = ImmutableControllerConfig.builder() // - .baseUrl("http://localhost:8083/") // - .name("controller1") // - .userName("user") // - .password("password") // - .build(); // + .baseUrl("http://localhost:8083/") // + .name("controller1") // + .userName("user") // + .password("password") // + .build(); // assertEquals(expectedControllerConfig, controllers.get("controller1"), "controller contents"); } @@ -78,7 +78,7 @@ class ApplicationConfigParserTest { private static InputStream getCorrectJson() throws IOException { URL url = ApplicationConfigParser.class.getClassLoader() - .getResource("test_application_configuration_with_dmaap_config.json"); + .getResource("test_application_configuration_with_dmaap_config.json"); String string = Resources.toString(url, Charsets.UTF_8); return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); } @@ -92,12 +92,12 @@ class ApplicationConfigParserTest { json.add("fake_info_object", new Gson().toJsonTree(fake_info_object)); DataPublishing data = new Gson().fromJson(json.toString(), DataPublishing.class); final String expectedMessage = - "Invalid configuration. Number of streams must be one, config: " + data.toString(); + "Invalid configuration. Number of streams must be one, config: " + data.toString(); Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject)); assertEquals(expectedMessage, actualException.getMessage(), - "Wrong error message when the DMaaP config has several streams publishing"); + "Wrong error message when the DMaaP config has several streams publishing"); } class DataPublishing { @@ -107,7 +107,7 @@ class ApplicationConfigParserTest { @Override public String toString() { return String.format("[dmaap_publisher=%s, fake_info_object=%s]", dmaap_publisher.toString(), - fake_info_object.toString()); + fake_info_object.toString()); } } @@ -120,12 +120,12 @@ class ApplicationConfigParserTest { json.add("fake_info_object", new Gson().toJsonTree(fake_info_object)); DataSubscribing data = new Gson().fromJson(json.toString(), DataSubscribing.class); final String expectedMessage = - "Invalid configuration. Number of streams must be one, config: " + data.toString(); + "Invalid configuration. Number of streams must be one, config: " + data.toString(); Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject)); assertEquals(expectedMessage, actualException.getMessage(), - "Wrong error message when the DMaaP config has several streams subscribing"); + "Wrong error message when the DMaaP config has several streams subscribing"); } private class DataSubscribing { @@ -135,7 +135,7 @@ class ApplicationConfigParserTest { @Override public String toString() { return String.format("[dmaap_subscriber=%s, fake_info_object=%s]", dmaap_subscriber.toString(), - fake_info_object.toString()); + fake_info_object.toString()); } } @@ -152,8 +152,8 @@ class ApplicationConfigParserTest { } JsonObject getDmaapInfo(JsonObject jsonRootObject, String streamsPublishesOrSubscribes, - String dmaapPublisherOrSubscriber) throws Exception { + String dmaapPublisherOrSubscriber) throws Exception { return jsonRootObject.getAsJsonObject("config").getAsJsonObject(streamsPublishesOrSubscribes) - .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info"); + .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info"); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java index eb2c1477..cf4739c8 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java @@ -40,19 +40,19 @@ import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException class ApplicationConfigTest { private static final ImmutableRicConfig RIC_CONFIG_1 = ImmutableRicConfig.builder() // - .ricId("ric1") // - .baseUrl("ric1_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric1") // + .baseUrl("ric1_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); ConfigParserResult configParserResult(RicConfig... rics) { return ImmutableConfigParserResult.builder() // - .ricConfigs(Arrays.asList(rics)) // - .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") // - .dmaapProducerTopicUrl("dmaapProducerTopicUrl") // - .controllerConfigs(new HashMap<>()) // - .build(); + .ricConfigs(Arrays.asList(rics)) // + .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") // + .dmaapProducerTopicUrl("dmaapProducerTopicUrl") // + .controllerConfigs(new HashMap<>()) // + .build(); } @Test @@ -77,7 +77,7 @@ class ApplicationConfigTest { assertTrue(appConfigUnderTest.getRicConfigs().contains(RIC_CONFIG_1), "Ric not added to configurations."); assertEquals(RIC_CONFIG_1, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()), - "Not correct Ric retrieved from configurations."); + "Not correct Ric retrieved from configurations."); update = appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)).blockFirst(); assertNull(update, "Nothing should be updated"); @@ -92,17 +92,17 @@ class ApplicationConfigTest { appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)); ImmutableRicConfig changedRicConfig = ImmutableRicConfig.builder() // - .ricId("ric1") // - .baseUrl("changed_ric1_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric1") // + .baseUrl("changed_ric1_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); RicConfigUpdate update = appConfigUnderTest.setConfiguration(configParserResult(changedRicConfig)).blockFirst(); assertEquals(RicConfigUpdate.Type.CHANGED, update.getType()); assertEquals(changedRicConfig, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()), - "Changed Ric not retrieved from configurations."); + "Changed Ric not retrieved from configurations."); } @Test @@ -110,11 +110,11 @@ class ApplicationConfigTest { ApplicationConfig appConfigUnderTest = new ApplicationConfig(); ImmutableRicConfig ricConfig2 = ImmutableRicConfig.builder() // - .ricId("ric2") // - .baseUrl("ric2_url") // - .managedElementIds(new Vector<>()) // - .controllerName("") // - .build(); + .ricId("ric2") // + .baseUrl("ric2_url") // + .managedElementIds(new Vector<>()) // + .controllerName("") // + .build(); appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1, ricConfig2)); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV1.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java index 971f358c..f8c15b6a 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV1.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.ccsdk.oran.a1policymanagementservice; +package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v1; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -49,9 +49,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicC import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableWebClientConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v1.PolicyInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v1.ServiceRegistrationInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v1.ServiceStatus; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy; import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType; @@ -91,12 +88,11 @@ import reactor.util.annotation.Nullable; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) -class ApplicationTestV1 { - private static final Logger logger = LoggerFactory.getLogger(ApplicationTestV1.class); +class ApplicationTest { + private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class); @Autowired ApplicationContext context; @@ -123,8 +119,8 @@ class ApplicationTestV1 { Services services; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // public static class MockApplicationConfig extends ApplicationConfig { @Override @@ -222,13 +218,13 @@ class ApplicationTestV1 { // This tests also validation of trusted certs restClient(true) rsp = restClient(true).get(url).block(); assertThat(rsp).contains("ric2") // - .doesNotContain("ric1") // - .contains("AVAILABLE"); + .doesNotContain("ric1") // + .contains("AVAILABLE"); // All RICs rsp = restClient().get("/rics").block(); assertThat(rsp).contains("ric2") // - .contains("ric1"); + .contains("ric1"); // Non existing policy type url = "/rics?policyType=XXXX"; @@ -288,13 +284,13 @@ class ApplicationTestV1 { } private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId, - boolean isTransient) { + boolean isTransient) { String url; if (policyTypeName.isEmpty()) { url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName; } else { url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type=" - + policyTypeName; + + policyTypeName; } if (isTransient) { url += "&transient=true"; @@ -376,7 +372,7 @@ class ApplicationTestV1 { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null, - responseBodyBytes, StandardCharsets.UTF_8, null); + responseBodyBytes, StandardCharsets.UTF_8, null); doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any()); // PUT Policy @@ -464,7 +460,7 @@ class ApplicationTestV1 { String url = "/policy_schemas"; String rsp = this.restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("[{\"title\":\"type2\"}"); + .contains("{\"title\":\"type2\"}"); List<String> info = parseSchemas(rsp); assertThat(info).hasSize(2); @@ -489,7 +485,7 @@ class ApplicationTestV1 { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("type1") // - .contains("title"); + .contains("title"); // Get non existing schema url = "/policy_schema?id=type1XX"; @@ -540,15 +536,15 @@ class ApplicationTestV1 { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policies?type=type1&service=service2"; rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).doesNotContain("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); // Test get policies for non existing type url = "/policies?type=type1XXX"; @@ -569,8 +565,8 @@ class ApplicationTestV1 { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policy_ids?type=type1&service=service1&ric=ric1"; rsp = restClient().get(url).block(); @@ -626,7 +622,7 @@ class ApplicationTestV1 { testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST); testErrorCode(restClient().put("/service", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST); testErrorCode(restClient().put("/service", createServiceJson(serviceName, 0, "missing.portandprotocol.com")), - HttpStatus.BAD_REQUEST); + HttpStatus.BAD_REQUEST); // GET non existing service testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND); @@ -666,14 +662,14 @@ class ApplicationTestV1 { private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException { addRic(ric); Policy policy = ImmutablePolicy.builder() // - .id(id) // - .json(jsonString()) // - .ownerServiceId(service) // - .ric(rics.getRic(ric)) // - .type(addPolicyType(typeName, ric)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json(jsonString()) // + .ownerServiceId(service) // + .ric(rics.getRic(ric)) // + .type(addPolicyType(typeName, ric)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); policies.put(policy); return policy; } @@ -717,14 +713,14 @@ class ApplicationTestV1 { private AsyncRestClient restClient(boolean useTrustValidation) { WebClientConfig config = this.applicationConfig.getWebClientConfig(); config = ImmutableWebClientConfig.builder() // - .keyStoreType(config.keyStoreType()) // - .keyStorePassword(config.keyStorePassword()) // - .keyStore(config.keyStore()) // - .keyPassword(config.keyPassword()) // - .isTrustStoreUsed(useTrustValidation) // - .trustStore(config.trustStore()) // - .trustStorePassword(config.trustStorePassword()) // - .build(); + .keyStoreType(config.keyStoreType()) // + .keyStorePassword(config.keyStorePassword()) // + .keyStore(config.keyStore()) // + .keyPassword(config.keyPassword()) // + .isTrustStoreUsed(useTrustValidation) // + .trustStore(config.trustStore()) // + .trustStorePassword(config.trustStorePassword()) // + .build(); return new AsyncRestClient(baseUrl(), config); } @@ -739,9 +735,9 @@ class ApplicationTestV1 { private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) { StepVerifier.create(request) // - .expectSubscription() // - .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) // - .verify(); + .expectSubscription() // + .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) // + .verify(); } private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) { @@ -758,9 +754,9 @@ class ApplicationTestV1 { private PolicyType createPolicyType(String policyTypeName) { return ImmutablePolicyType.builder() // - .id(policyTypeName) // - .schema("{\"title\":\"" + policyTypeName + "\"}") // - .build(); + .id(policyTypeName) // + .schema("{\"title\":\"" + policyTypeName + "\"}") // + .build(); } private PolicyType addPolicyType(String policyTypeName, String ricName) { @@ -783,11 +779,11 @@ class ApplicationTestV1 { mes.add(managedElement); } RicConfig conf = ImmutableRicConfig.builder() // - .ricId(ricName) // - .baseUrl(ricName) // - .managedElementIds(mes) // - .controllerName("") // - .build(); + .ricId(ricName) // + .baseUrl(ricName) // + .managedElementIds(mes) // + .controllerName("") // + .build(); Ric ric = new Ric(conf); ric.setState(Ric.RicState.AVAILABLE); this.rics.put(ric); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java index 3a7068d6..87589f22 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.ccsdk.oran.a1policymanagementservice; +package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -47,16 +47,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicC import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableWebClientConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.WebClientConfig; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.Consts; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyIdList; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyInfoList; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicySchemaList; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.PolicyTypeIdList; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.RicInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ServiceRegistrationInfo; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ServiceStatus; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ServiceStatusList; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy; import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicyType; @@ -97,12 +87,11 @@ import reactor.util.annotation.Nullable; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource( - properties = { // +@TestPropertySource(properties = { // "server.ssl.key-store=./config/keystore.jks", // "app.webclient.trust-store=./config/truststore.jks"}) -class ApplicationTestV2 { - private static final Logger logger = LoggerFactory.getLogger(ApplicationTestV2.class); +class ApplicationTest { + private static final Logger logger = LoggerFactory.getLogger(ApplicationTest.class); @Autowired ApplicationContext context; @@ -129,8 +118,8 @@ class ApplicationTestV2 { Services services; private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + .serializeNulls() // + .create(); // public static class MockApplicationConfig extends ApplicationConfig { @Override @@ -228,13 +217,13 @@ class ApplicationTestV2 { // This tests also validation of trusted certs restClient(true) rsp = restClient(true).get(url).block(); assertThat(rsp).contains("ric2") // - .doesNotContain("ric1") // - .contains("AVAILABLE"); + .doesNotContain("ric1") // + .contains("AVAILABLE"); // All RICs rsp = restClient().get("/rics").block(); assertThat(rsp).contains("ric2") // - .contains("ric1"); + .contains("ric1"); // Non existing policy type url = "/rics?policytype_id=XXXX"; @@ -255,7 +244,7 @@ class ApplicationTestV2 { Policy policy2 = addPolicy("policyId2", "typeName", "service", ric1Name); Ric ric2 = addRic("ric2"); - getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (NearRT-RIC) + getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (Near-RT RIC) policies.remove(policy2); // Remove it from the repo -> should be deleted in the RIC String policyId = "policyId"; @@ -263,9 +252,9 @@ class ApplicationTestV2 { supervision.checkAllRics(); // The created policy should be put in the RIC // Wait until synch is completed - await().untilAsserted(() -> RicState.SYNCHRONIZING.equals(rics.getRic(ric1Name).getState())); - await().untilAsserted(() -> RicState.AVAILABLE.equals(rics.getRic(ric1Name).getState())); - await().untilAsserted(() -> RicState.AVAILABLE.equals(rics.getRic("ric2").getState())); + waitForRicState(ric1Name, RicState.SYNCHRONIZING); + waitForRicState(ric1Name, RicState.AVAILABLE); + waitForRicState("ric2", RicState.AVAILABLE); Policies ricPolicies = getA1Client(ric1Name).getPolicies(); assertThat(ricPolicies.size()).isEqualTo(1); @@ -303,13 +292,13 @@ class ApplicationTestV2 { } private String putPolicyUrl(String serviceName, String ricId, String policyTypeName, String policyInstanceId, - boolean isTransient) { + boolean isTransient) { String url; if (policyTypeName.isEmpty()) { url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName; } else { url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName - + "&policytype_id=" + policyTypeName; + + "&policytype_id=" + policyTypeName; } if (isTransient) { url += "&transient=true"; @@ -391,7 +380,7 @@ class ApplicationTestV2 { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null, - responseBodyBytes, StandardCharsets.UTF_8, null); + responseBodyBytes, StandardCharsets.UTF_8, null); doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any()); // PUT Policy @@ -476,10 +465,13 @@ class ApplicationTestV2 { addPolicyType("type1", "ric1"); addPolicyType("type2", "ric2"); + waitForRicState("ric1", RicState.AVAILABLE); + waitForRicState("ric2", RicState.AVAILABLE); + String url = "/policy-schemas"; String rsp = this.restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("[{\"title\":\"type2\"}"); + .contains("{\"title\":\"type2\"}"); PolicySchemaList info = parseSchemas(rsp); assertThat(info.schemas).hasSize(2); @@ -494,7 +486,7 @@ class ApplicationTestV2 { url = "/policy-schemas?policytype_id=type1"; rsp = restClient().get(url).block(); assertThat(rsp).contains("type1") // - .contains("title"); + .contains("title"); // Both type and ric specified url = "/policy-schemas?ric_id=ric1&policytype_id=type1"; @@ -569,15 +561,15 @@ class ApplicationTestV2 { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policies?policytype_id=type1&service_id=service2"; rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).doesNotContain("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); // Test get policies for non existing type url = "/policies?policytype_id=type1XXX"; @@ -598,8 +590,8 @@ class ApplicationTestV2 { String rsp = restClient().get(url).block(); logger.info(rsp); assertThat(rsp).contains("id1") // - .contains("id2") // - .doesNotContain("id3"); + .contains("id2") // + .doesNotContain("id3"); url = "/policy-ids?policytype_id=type1&service_id=service1&ric=ric1"; rsp = restClient().get(url).block(); @@ -655,9 +647,9 @@ class ApplicationTestV2 { testErrorCode(restClient().put("/services", "crap"), HttpStatus.BAD_REQUEST, false); testErrorCode(restClient().put("/services", "{}"), HttpStatus.BAD_REQUEST, false); testErrorCode(restClient().put("/services", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST, - false); + false); testErrorCode(restClient().put("/services", createServiceJson(serviceName, 0, "missing.portandprotocol.com")), - HttpStatus.BAD_REQUEST, false); + HttpStatus.BAD_REQUEST, false); // GET non existing service testErrorCode(restClient().get("/services?service_id=XXX"), HttpStatus.NOT_FOUND); @@ -697,14 +689,14 @@ class ApplicationTestV2 { private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException { addRic(ric); Policy policy = ImmutablePolicy.builder() // - .id(id) // - .json(jsonString()) // - .ownerServiceId(service) // - .ric(rics.getRic(ric)) // - .type(addPolicyType(typeName, ric)) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json(jsonString()) // + .ownerServiceId(service) // + .ric(rics.getRic(ric)) // + .type(addPolicyType(typeName, ric)) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); policies.put(policy); return policy; } @@ -758,7 +750,7 @@ class ApplicationTestV2 { for (int i = 0; i < 10; ++i) { AsyncRestClient restClient = restClient(); ConcurrencyTestRunnable test = - new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes); + new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes); Thread thread = new Thread(test, "TestThread_" + i); thread.start(); threads.add(thread); @@ -777,14 +769,14 @@ class ApplicationTestV2 { private AsyncRestClient restClient(boolean useTrustValidation) { WebClientConfig config = this.applicationConfig.getWebClientConfig(); config = ImmutableWebClientConfig.builder() // - .keyStoreType(config.keyStoreType()) // - .keyStorePassword(config.keyStorePassword()) // - .keyStore(config.keyStore()) // - .keyPassword(config.keyPassword()) // - .isTrustStoreUsed(useTrustValidation) // - .trustStore(config.trustStore()) // - .trustStorePassword(config.trustStorePassword()) // - .build(); + .keyStoreType(config.keyStoreType()) // + .keyStorePassword(config.keyStorePassword()) // + .keyStore(config.keyStore()) // + .keyPassword(config.keyPassword()) // + .isTrustStoreUsed(useTrustValidation) // + .trustStore(config.trustStore()) // + .trustStorePassword(config.trustStorePassword()) // + .build(); return new AsyncRestClient(baseUrl(), config); } @@ -806,16 +798,21 @@ class ApplicationTestV2 { } private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains, - boolean expectApplicationProblemJsonMediaType) { + boolean expectApplicationProblemJsonMediaType) { StepVerifier.create(request) // - .expectSubscription() // - .expectErrorMatches( - t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) // - .verify(); + .expectSubscription() // + .expectErrorMatches( + t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) // + .verify(); + } + + private void waitForRicState(String ricId, RicState state) throws ServiceException { + Ric ric = rics.getRic(ricId); + await().untilAsserted(() -> state.equals(ric.getState())); } private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains, - boolean expectApplicationProblemJsonMediaType) { + boolean expectApplicationProblemJsonMediaType) { assertTrue(throwable instanceof WebClientResponseException); WebClientResponseException responseException = (WebClientResponseException) throwable; assertThat(responseException.getStatusCode()).isEqualTo(expStatus); @@ -832,9 +829,9 @@ class ApplicationTestV2 { private PolicyType createPolicyType(String policyTypeName) { return ImmutablePolicyType.builder() // - .id(policyTypeName) // - .schema("{\"title\":\"" + policyTypeName + "\"}") // - .build(); + .id(policyTypeName) // + .schema("{\"title\":\"" + policyTypeName + "\"}") // + .build(); } private PolicyType addPolicyType(String policyTypeName, String ricId) { @@ -857,11 +854,11 @@ class ApplicationTestV2 { mes.add(managedElement); } RicConfig conf = ImmutableRicConfig.builder() // - .ricId(ricId) // - .baseUrl(ricId) // - .managedElementIds(mes) // - .controllerName("") // - .build(); + .ricId(ricId) // + .baseUrl(ricId) // + .managedElementIds(mes) // + .controllerName("") // + .build(); Ric ric = new Ric(conf); ric.setState(Ric.RicState.AVAILABLE); this.rics.put(ric); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ConcurrencyTestRunnable.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java index 0e8803a5..89a76e95 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ConcurrencyTestRunnable.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.ccsdk.oran.a1policymanagementservice; +package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2; import java.time.Instant; import java.util.concurrent.atomic.AtomicInteger; @@ -53,7 +53,7 @@ class ConcurrencyTestRunnable implements Runnable { private boolean failed = false; ConcurrencyTestRunnable(AsyncRestClient client, RicSupervision supervision, MockA1ClientFactory a1ClientFactory, - Rics rics, PolicyTypes types) { + Rics rics, PolicyTypes types) { this.count = nextCount.incrementAndGet(); this.supervision = supervision; this.a1ClientFactory = a1ClientFactory; @@ -108,14 +108,14 @@ class ConcurrencyTestRunnable implements Runnable { Ric ric = this.rics.get("ric"); PolicyType type = this.types.get("type1"); return ImmutablePolicy.builder() // - .id(id) // - .json("{}") // - .type(type) // - .ric(ric) // - .ownerServiceId("") // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(id) // + .json("{}") // + .type(type) // + .ric(ric) // + .ownerServiceId("") // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); } private void createInconsistency() { diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java index 2bd8c7f4..b6d3cc07 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java @@ -143,12 +143,12 @@ class DmaapMessageConsumerTest { when(messageRouterConsumerMock.getForEntity(any())).thenReturn(response); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN); + LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN); messageConsumerUnderTest.start().join(); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error"); + .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error"); verify(messageConsumerUnderTest).sleep(DmaapMessageConsumer.TIME_BETWEEN_DMAAP_RETRIES); } @@ -204,9 +204,9 @@ class DmaapMessageConsumerTest { doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler(); doReturn(Mono.just("OK")).when(messageHandlerMock).sendDmaapResponse(any(), any(), any()); Exception actualException = - assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); + assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); assertThat(actualException.getMessage()) - .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException"); + .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException"); verify(messageHandlerMock).sendDmaapResponse(any(), any(), any()); } @@ -216,9 +216,9 @@ class DmaapMessageConsumerTest { messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock)); doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler(); doReturn(Mono.error(new Exception("Sending response failed"))).when(messageHandlerMock).sendDmaapResponse(any(), - any(), any()); + any(), any()); Exception actualException = - assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); + assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]")); assertThat(actualException.getMessage()).contains("Sending response failed"); verify(messageHandlerMock).sendDmaapResponse(any(), any(), any()); @@ -239,16 +239,16 @@ class DmaapMessageConsumerTest { private DmaapRequestMessage dmaapRequestMessage(Operation operation) { return ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(operation) // - .originatorId("originatorId") // - .payload(new JsonObject()) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url("URL") // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(operation) // + .originatorId("originatorId") // + .payload(new JsonObject()) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url("URL") // + .build(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java index 3656ec1a..bab09931 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java @@ -80,19 +80,19 @@ class DmaapMessageHandlerTest { DmaapRequestMessage dmaapRequestMessage(Operation operation) { Optional<JsonObject> payload = - ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson()) - : Optional.empty()); + ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson()) + : Optional.empty()); return ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(operation) // - .originatorId("originatorId") // - .payload(payload) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url(URL) // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(operation) // + .originatorId("originatorId") // + .payload(payload) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url(URL) // + .build(); } private Mono<ResponseEntity<String>> okResponse() { @@ -113,10 +113,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.DELETE); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).deleteForEntity(URL); verifyNoMoreInteractions(pmsClient); @@ -133,10 +133,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.GET); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).getForEntity(URL); verifyNoMoreInteractions(pmsClient); @@ -149,21 +149,21 @@ class DmaapMessageHandlerTest { void exceptionFromPmsWhenGet_thenPostError() throws IOException { String errorBody = "Unavailable"; WebClientResponseException webClientResponseException = new WebClientResponseException( - HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null); + HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null); doReturn(Mono.error(webClientResponseException)).when(pmsClient).getForEntity(anyString()); doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString()); DmaapRequestMessage message = dmaapRequestMessage(Operation.GET); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .verifyComplete(); // ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(dmaapClient).post(anyString(), captor.capture()); String actualMessage = captor.getValue(); assertThat(actualMessage).contains(HttpStatus.SERVICE_UNAVAILABLE.toString()) // - .contains(errorBody); + .contains(errorBody); } @Test @@ -173,10 +173,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.PUT); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).putForEntity(URL, payloadAsString()); verifyNoMoreInteractions(pmsClient); @@ -192,10 +192,10 @@ class DmaapMessageHandlerTest { DmaapRequestMessage message = dmaapRequestMessage(Operation.POST); StepVerifier // - .create(testedObject.createTask(message)) // - .expectSubscription() // - .expectNext("OK") // - .verifyComplete(); // + .create(testedObject.createTask(message)) // + .expectSubscription() // + .expectNext("OK") // + .verifyComplete(); // verify(pmsClient).postForEntity(URL, payloadAsString()); verifyNoMoreInteractions(pmsClient); @@ -220,7 +220,7 @@ class DmaapMessageHandlerTest { verify(dmaapClient).post(anyString(), captor.capture()); String actualMessage = captor.getValue(); assertThat(actualMessage).as("Message \"%s\" sent to DMaaP contains %s", actualMessage, HttpStatus.BAD_GATEWAY) - .contains(HttpStatus.BAD_GATEWAY.toString()); + .contains(HttpStatus.BAD_GATEWAY.toString()); verifyNoMoreInteractions(dmaapClient); } @@ -228,24 +228,24 @@ class DmaapMessageHandlerTest { @Test void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception { DmaapRequestMessage message = ImmutableDmaapRequestMessage.builder() // - .apiVersion("apiVersion") // - .correlationId("correlationId") // - .operation(DmaapRequestMessage.Operation.PUT) // - .originatorId("originatorId") // - .payload(Optional.empty()) // - .requestId("requestId") // - .target("target") // - .timestamp("timestamp") // - .url(URL) // - .build(); + .apiVersion("apiVersion") // + .correlationId("correlationId") // + .operation(DmaapRequestMessage.Operation.PUT) // + .originatorId("originatorId") // + .payload(Optional.empty()) // + .requestId("requestId") // + .target("target") // + .timestamp("timestamp") // + .url(URL) // + .build(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN); + LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN); testedObject.handleDmaapMsg(message); assertThat(logAppender.list.get(0).getFormattedMessage()) - .startsWith("Expected payload in message from DMAAP: "); + .startsWith("Expected payload in message from DMAAP: "); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java index 520e5c7a..a63f15f1 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java @@ -73,14 +73,14 @@ class LockTest { Lock lock = new Lock(); Mono<Lock> seq = lock.lock(LockType.EXCLUSIVE) // - .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) // - .flatMap(l -> lock.unlock()); + .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) // + .flatMap(l -> lock.unlock()); asynchUnlock(lock); StepVerifier.create(seq) // - .expectSubscription() // - .expectNext(lock) // - .verifyComplete(); + .expectSubscription() // + .expectNext(lock) // + .verifyComplete(); assertThat(lock.getLockCounter()).isZero(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java index e2bc8700..5a1dbea7 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java @@ -55,14 +55,14 @@ class EnvironmentProcessorTest { systemEnvironment.put(HOSTNAME, HOSTNAME_VALUE); EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(consulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(consulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); } @Test @@ -70,9 +70,9 @@ class EnvironmentProcessorTest { Properties systemEnvironment = new Properties(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException - && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined")) - .verify(); + .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException + && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined")) + .verify(); } @Test @@ -84,20 +84,20 @@ class EnvironmentProcessorTest { String defaultConsulPort = "8500"; EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(defaultConsulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(defaultConsulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN); + LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort); + .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort); } @Test @@ -106,9 +106,9 @@ class EnvironmentProcessorTest { systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException - && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined")) - .verify(); + .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException + && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined")) + .verify(); } @Test @@ -121,14 +121,14 @@ class EnvironmentProcessorTest { systemEnvironment.put("SERVICE_NAME", HOSTNAME_VALUE); EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() // - .consulHost(CONSUL_HOST_VALUE) // - .consulPort(Integer.valueOf(consulPort)) // - .cbsName(CONFIG_BINDING_SERVICE_VALUE) // - .appName(HOSTNAME_VALUE) // - .build(); + .consulHost(CONSUL_HOST_VALUE) // + .consulPort(Integer.valueOf(consulPort)) // + .cbsName(CONFIG_BINDING_SERVICE_VALUE) // + .appName(HOSTNAME_VALUE) // + .build(); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectNext(expectedEnvProperties).expectComplete(); + .expectNext(expectedEnvProperties).expectComplete(); } @Test @@ -138,8 +138,9 @@ class EnvironmentProcessorTest { systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE); StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment)) - .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage() - .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")) - .verify(); + .expectErrorMatches( + throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage() + .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment")) + .verify(); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java index 72b20600..c62626c1 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java @@ -102,19 +102,19 @@ class RefreshConfigTaskTest { private static final String RIC_1_NAME = "ric1"; private static final RicConfig CORRECT_RIC_CONIFG = ImmutableRicConfig.builder() // - .ricId(RIC_1_NAME) // - .baseUrl("http://localhost:8080/") // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("") // - .build(); + .ricId(RIC_1_NAME) // + .baseUrl("http://localhost:8080/") // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("") // + .build(); private static EnvProperties properties() { return ImmutableEnvProperties.builder() // - .consulHost("host") // - .consulPort(123) // - .cbsName("cbsName") // - .appName("appName") // - .build(); + .consulHost("host") // + .consulPort(123) // + .cbsName("cbsName") // + .appName("appName") // + .build(); } private RefreshConfigTask createTestObject(boolean configFileExists) { @@ -122,9 +122,9 @@ class RefreshConfigTaskTest { } private RefreshConfigTask createTestObject(boolean configFileExists, Rics rics, Policies policies, - boolean stubConfigFileExists) { + boolean stubConfigFileExists) { RefreshConfigTask obj = spy(new RefreshConfigTask(appConfig, rics, policies, new Services(), new PolicyTypes(), - new A1ClientFactory(appConfig))); + new A1ClientFactory(appConfig))); if (stubConfigFileExists) { doReturn(configFileExists).when(obj).fileExists(any()); } @@ -144,21 +144,6 @@ class RefreshConfigTaskTest { } @Test - void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() { - refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false); - String errorMessage = "Error"; - doReturn(Flux.error(new Exception(errorMessage))).when(refreshTaskUnderTest).createRefreshTask(); - - final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR); - - refreshTaskUnderTest.start(); - - ILoggingEvent event = logAppender.list.get(0); - assertThat(event.getFormattedMessage()) - .isEqualTo("Configuration refresh terminated due to exception java.lang.Exception: " + errorMessage); - } - - @Test void stop_thenTaskIsDisposed() throws Exception { refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false); refreshTaskUnderTest.systemEnvironment = new Properties(); @@ -178,12 +163,12 @@ class RefreshConfigTaskTest { doReturn("fileName").when(appConfig).getLocalConfigurationFilePath(); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNext(Type.ADDED) // - .expectNext(Type.ADDED) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNext(Type.ADDED) // + .expectNext(Type.ADDED) // + .thenCancel() // + .verify(); // Then verify(refreshTaskUnderTest).loadConfigurationFromFile(); @@ -202,17 +187,18 @@ class RefreshConfigTaskTest { refreshTaskUnderTest.systemEnvironment = new Properties(); // When - doReturn(getIncorrectJson()).when(refreshTaskUnderTest).createInputStream(any()); + final String JUNK_JSON = "{\"junk }"; + doReturn(getJsonSteam(JUNK_JSON)).when(refreshTaskUnderTest).createInputStream(any()); doReturn("fileName").when(appConfig).getLocalConfigurationFilePath(); final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(100)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(100)) // + .thenCancel() // + .verify(); // Then verify(refreshTaskUnderTest).loadConfigurationFromFile(); @@ -220,7 +206,7 @@ class RefreshConfigTaskTest { await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()) - .startsWith("Local configuration file not loaded: fileName, "); + .startsWith("Local configuration file not loaded: fileName, "); } @Test @@ -237,15 +223,15 @@ class RefreshConfigTaskTest { final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, WARN); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(1000)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(1000)) // + .thenCancel() // + .verify(); await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()) - .isEqualTo("Could not refresh application configuration. java.io.IOException"); + .isEqualTo("Could not refresh application configuration. java.io.IOException"); } @Test @@ -269,20 +255,20 @@ class RefreshConfigTaskTest { doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any()); doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props); - JsonObject configAsJson = getJsonRootObject(true); + JsonObject configAsJson = getJsonRootObject(getCorrectJson()); String newBaseUrl = "newBaseUrl"; modifyTheRicConfiguration(configAsJson, newBaseUrl); when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson)); doNothing().when(refreshTaskUnderTest).runRicSynchronization(any(Ric.class)); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNext(Type.CHANGED) // - .expectNext(Type.ADDED) // - .expectNext(Type.REMOVED) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNext(Type.CHANGED) // + .expectNext(Type.ADDED) // + .expectNext(Type.REMOVED) // + .thenCancel() // + .verify(); assertThat(appConfig.getRicConfigs()).hasSize(2); assertThat(appConfig.getRic(RIC_1_NAME).baseUrl()).isEqualTo(newBaseUrl); @@ -309,68 +295,68 @@ class RefreshConfigTaskTest { 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)); + JsonObject emptyJsonObject = new JsonObject(); + when(cbsClient.get(any())).thenReturn(Mono.just(emptyJsonObject)); final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR); StepVerifier // - .create(refreshTaskUnderTest.createRefreshTask()) // - .expectSubscription() // - .expectNoEvent(Duration.ofMillis(1000)) // - .thenCancel() // - .verify(); + .create(refreshTaskUnderTest.createRefreshTask()) // + .expectSubscription() // + .expectNoEvent(Duration.ofMillis(1000)) // + .thenCancel() // + .verify(); await().until(() -> logAppender.list.size() > 0); assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith( - "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: "); + "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: "); } private RicConfig getRicConfig(String name) { RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId(name) // - .baseUrl("url") // - .managedElementIds(Collections.emptyList()) // - .controllerName("controllerName") // - .build(); + .ricId(name) // + .baseUrl("url") // + .managedElementIds(Collections.emptyList()) // + .controllerName("controllerName") // + .build(); return ricConfig; } private Policy getPolicy(Ric ric) { ImmutablePolicyType type = ImmutablePolicyType.builder() // - .id("type") // - .schema("{}") // - .build(); + .id("type") // + .schema("{}") // + .build(); Policy policy = ImmutablePolicy.builder() // - .id("id") // - .type(type) // - .lastModified(Instant.now()) // - .ric(ric) // - .json("{}") // - .ownerServiceId("ownerServiceId") // - .isTransient(false) // - .build(); + .id("id") // + .type(type) // + .lastModified(Instant.now()) // + .ric(ric) // + .json("{}") // + .ownerServiceId("ownerServiceId") // + .isTransient(false) // + .build(); return policy; } ConfigParserResult configParserResult(RicConfig... rics) { return ImmutableConfigParserResult.builder() // - .ricConfigs(Arrays.asList(rics)) // - .dmaapConsumerTopicUrl("") // - .dmaapProducerTopicUrl("") // - .controllerConfigs(new HashMap<>()) // - .build(); + .ricConfigs(Arrays.asList(rics)) // + .dmaapConsumerTopicUrl("") // + .dmaapProducerTopicUrl("") // + .controllerConfigs(new HashMap<>()) // + .build(); } private void modifyTheRicConfiguration(JsonObject configAsJson, String newBaseUrl) { ((JsonObject) configAsJson.getAsJsonObject("config") // - .getAsJsonArray("ric").get(0)) // - .addProperty("baseUrl", newBaseUrl); + .getAsJsonArray("ric").get(0)) // + .addProperty("baseUrl", newBaseUrl); } - private JsonObject getJsonRootObject(boolean valid) throws JsonIOException, JsonSyntaxException, IOException { - JsonObject rootObject = JsonParser - .parseReader(new InputStreamReader(valid ? getCorrectJson() : getIncorrectJson())).getAsJsonObject(); + private JsonObject getJsonRootObject(InputStream inStream) + throws JsonIOException, JsonSyntaxException, IOException { + JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject(); return rootObject; } @@ -380,8 +366,7 @@ class RefreshConfigTaskTest { return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); } - private static InputStream getIncorrectJson() { - String string = "{}"; // - return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8))); + private static InputStream getJsonSteam(String json) { + return new ByteArrayInputStream((json.getBytes(StandardCharsets.UTF_8))); } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java index bb3b3461..25a7ddc4 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java @@ -60,37 +60,37 @@ import reactor.core.publisher.Mono; class RicSupervisionTest { private static final String POLICY_TYPE_1_NAME = "type1"; private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() // - .id(POLICY_TYPE_1_NAME) // - .schema("") // - .build(); + .id(POLICY_TYPE_1_NAME) // + .schema("") // + .build(); private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() // - .ricId("ric_1") // - .baseUrl("baseUrl1") // - .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("controllerName") // - .build()); + .ricId("ric_1") // + .baseUrl("baseUrl1") // + .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // + .controllerName("controllerName") // + .build()); private static final String POLICY_1_ID = "policyId1"; private static final Policy POLICY_1 = ImmutablePolicy.builder() // - .id(POLICY_1_ID) // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(POLICY_1_ID) // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); private static final Policy POLICY_2 = ImmutablePolicy.builder() // - .id("policyId2") // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id("policyId2") // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); @Mock private A1Client a1ClientMock; @@ -285,9 +285,9 @@ class RicSupervisionTest { void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() { doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class)); PolicyType policyType2 = ImmutablePolicyType.builder() // - .id("policyType2") // - .schema("") // - .build(); + .id("policyType2") // + .schema("") // + .build(); RIC_1.setState(RicState.AVAILABLE); RIC_1.addSupportedPolicyType(POLICY_TYPE_1); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java index 93d252f7..e1c0c6b8 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java @@ -69,28 +69,28 @@ import reactor.core.publisher.Mono; class RicSynchronizationTaskTest { private static final String POLICY_TYPE_1_NAME = "type1"; private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() // - .id(POLICY_TYPE_1_NAME) // - .schema("") // - .build(); + .id(POLICY_TYPE_1_NAME) // + .schema("") // + .build(); private static final String RIC_1_NAME = "ric1"; private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() // - .ricId(RIC_1_NAME) // - .baseUrl("baseUrl1") // - .managedElementIds(Collections.emptyList()) // - .controllerName("controllerName") // - .build()); + .ricId(RIC_1_NAME) // + .baseUrl("baseUrl1") // + .managedElementIds(Collections.emptyList()) // + .controllerName("controllerName") // + .build()); private static Policy createPolicy(String policyId, boolean isTransient) { return ImmutablePolicy.builder() // - .id(policyId) // - .json("") // - .ownerServiceId("service") // - .ric(RIC_1) // - .type(POLICY_TYPE_1) // - .lastModified(Instant.now()) // - .isTransient(isTransient) // - .build(); + .id(policyId) // + .json("") // + .ownerServiceId("service") // + .ric(RIC_1) // + .type(POLICY_TYPE_1) // + .lastModified(Instant.now()) // + .isTransient(isTransient) // + .build(); } private static final Policy POLICY_1 = createPolicy("policyId1", false); @@ -127,7 +127,7 @@ class RicSynchronizationTaskTest { policies.put(POLICY_1); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -153,7 +153,7 @@ class RicSynchronizationTaskTest { simulateRicWithOnePolicyType(); RicSynchronizationTask synchronizerUnderTest = - spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); + spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest); when(restClientMock.put(anyString(), anyString())).thenReturn(Mono.just("Ok")); @@ -185,7 +185,7 @@ class RicSynchronizationTaskTest { when(a1ClientMock.getPolicyTypeSchema(POLICY_TYPE_1_NAME)).thenReturn(Mono.just(typeSchema)); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -214,7 +214,7 @@ class RicSynchronizationTaskTest { when(a1ClientMock.putPolicy(any(Policy.class))).thenReturn(Mono.just("OK")); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -237,11 +237,11 @@ class RicSynchronizationTaskTest { simulateRicWithNoPolicyTypes(); when(a1ClientMock.deleteAllPolicies()) // - .thenReturn(Flux.error(new Exception("Exception"))) // - .thenReturn(Flux.just("OK")); + .thenReturn(Flux.error(new Exception("Exception"))) // + .thenReturn(Flux.just("OK")); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); synchronizerUnderTest.run(RIC_1); @@ -266,15 +266,15 @@ class RicSynchronizationTaskTest { when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(new Exception(originalErrorMessage))); RicSynchronizationTask synchronizerUnderTest = - new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); + new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); + LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); synchronizerUnderTest.run(RIC_1); verifyCorrectLogMessage(0, logAppender, - "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage); + "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage); verify(a1ClientMock, times(2)).deleteAllPolicies(); verifyNoMoreInteractions(a1ClientMock); @@ -296,10 +296,10 @@ class RicSynchronizationTaskTest { simulateRicWithOnePolicyType(); final ListAppender<ILoggingEvent> logAppender = - LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); + LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN); RicSynchronizationTask synchronizerUnderTest = - spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); + spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services)); AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest); String originalErrorMessage = "Exception"; @@ -310,7 +310,7 @@ class RicSynchronizationTaskTest { ILoggingEvent loggingEvent = logAppender.list.get(0); assertThat(loggingEvent.getLevel()).isEqualTo(WARN); verifyCorrectLogMessage(0, logAppender, - "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage); + "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage); } private void setUpCreationOfA1Client() { @@ -333,7 +333,7 @@ class RicSynchronizationTaskTest { } private void verifyCorrectLogMessage(int messageIndex, ListAppender<ILoggingEvent> logAppender, - String expectedMessage) { + String expectedMessage) { ILoggingEvent loggingEvent = logAppender.list.get(messageIndex); assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedMessage); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java index 3e7bea64..1a8e9b3e 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java @@ -72,25 +72,25 @@ class ServiceSupervisionTest { private Service service; private Policies policies; private RicConfig ricConfig = ImmutableRicConfig.builder() // - .ricId(RIC_NAME) // - .baseUrl("baseUrl") // - .managedElementIds(Collections.emptyList()) // - .controllerName("") // - .build(); + .ricId(RIC_NAME) // + .baseUrl("baseUrl") // + .managedElementIds(Collections.emptyList()) // + .controllerName("") // + .build(); private Ric ric = new Ric(ricConfig); private PolicyType policyType = ImmutablePolicyType.builder() // - .id("policyTypeName") // - .schema("schema") // - .build(); + .id("policyTypeName") // + .schema("schema") // + .build(); private Policy policy = ImmutablePolicy.builder() // - .id(POLICY_ID) // - .json("json") // - .ownerServiceId(SERVICE_NAME) // - .ric(ric) // - .type(policyType) // - .lastModified(Instant.now()) // - .isTransient(false) // - .build(); + .id(POLICY_ID) // + .json("json") // + .ownerServiceId(SERVICE_NAME) // + .ric(ric) // + .type(policyType) // + .lastModified(Instant.now()) // + .isTransient(false) // + .build(); @Test void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() { @@ -100,7 +100,7 @@ class ServiceSupervisionTest { when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.just("Policy deleted")); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired); @@ -122,7 +122,7 @@ class ServiceSupervisionTest { when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.error(new Exception(originalErrorMessage))); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired); @@ -136,7 +136,7 @@ class ServiceSupervisionTest { ILoggingEvent loggingEvent = logAppender.list.get(0); assertThat(loggingEvent.getLevel()).isEqualTo(WARN); String expectedLogMessage = - "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage; + "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage; assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedLogMessage); } @@ -145,7 +145,7 @@ class ServiceSupervisionTest { setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2)); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); serviceSupervisionUnderTest.checkAllServices().blockLast(); @@ -161,7 +161,7 @@ class ServiceSupervisionTest { setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0)); ServiceSupervision serviceSupervisionUnderTest = - new ServiceSupervision(services, policies, a1ClientFactoryMock); + new ServiceSupervision(services, policies, a1ClientFactoryMock); serviceSupervisionUnderTest.checkAllServices().blockLast(); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java index 14de691d..482fa395 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java @@ -101,7 +101,7 @@ public class MockA1Client implements A1Client { public Flux<String> deleteAllPolicies() { this.policies.clear(); return mono("OK") // - .flatMapMany(Flux::just); + .flatMapMany(Flux::just); } @Override @@ -120,7 +120,7 @@ public class MockA1Client implements A1Client { Mono<String> monoError(String responseBody, HttpStatus status) { byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); WebClientResponseException a1Exception = new WebClientResponseException(status.value(), - status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null); + status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null); return Mono.error(a1Exception); } @@ -19,9 +19,17 @@ ~ ============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> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>odlparent-lite</artifactId> + <version>2.0.1-SNAPSHOT</version> + <relativePath/> + </parent> + <groupId>org.onap.ccsdk.oran</groupId> <artifactId>ccsdk-oran</artifactId> <version>1.0.0-SNAPSHOT</version> @@ -35,6 +43,7 @@ <properties> <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version> </properties> + <build> <plugins> <!-- support sonar in multi-module project --> diff --git a/version.properties b/version.properties new file mode 100644 index 00000000..edf2cd0a --- /dev/null +++ b/version.properties @@ -0,0 +1,14 @@ +########################################################### +# Versioning variables +# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... ) +# because they are used in Jenkins, whose plug-in doesn't support + + +release_name=1 +sprint_number=0 +feature_revision=0 + +base_version=${release_name}.${sprint_number}.${feature_revision} + +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT |