aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-06-16 12:08:01 +0100
committerliamfallon <liam.fallon@est.tech>2021-06-17 15:51:34 +0100
commit2d186df9e3ed47599dbc86c2f435f7884535398c (patch)
treed77b85e48927ad072248e784c7b99b12205f4e0b /runtime
parent17f5d3c97e47064407452122bc6cb801e43df5f9 (diff)
Clean up CLAMP Sonar and checkstyle issues
This commit cleans up sonar and checkstyle issues identified in the CLAMP repository. Issue-ID: POLICY-3206 Change-Id: I16b61bbe771cc17de15183a24b2a5e82a8d35872 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/Application.java19
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java10
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java70
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java24
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java192
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java44
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java17
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java41
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java3
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java49
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java38
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java13
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java17
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java21
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java6
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java7
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java10
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java3
35 files changed, 328 insertions, 329 deletions
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
index ba300ac09..07c174293 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
@@ -39,7 +39,6 @@ import org.apache.catalina.connector.Connector;
import org.onap.policy.clamp.clds.util.ClampVersioning;
import org.onap.policy.clamp.clds.util.ResourceFileUtils;
import org.onap.policy.clamp.util.PassDecoder;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -54,7 +53,6 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
@@ -99,9 +97,6 @@ public class Application extends SpringBootServletInitializer {
@Value("${clamp.config.keyFile:classpath:/clds/aaf/org.onap.clamp.keyfile}")
private String keyFile;
- @Autowired
- private Environment env;
-
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
@@ -124,11 +119,11 @@ public class Application extends SpringBootServletInitializer {
* @throws IOException IO Exception
*/
@Bean
- public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
+ public ServletRegistrationBean<ClampServlet> camelServletRegistrationBean() throws IOException {
eelfLogger.info(ResourceFileUtils.getResourceAsString("boot-message.txt") + "(v"
+ ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator")
+ getSslExpirationDate());
- ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/*");
+ var registration = new ServletRegistrationBean<ClampServlet>(new ClampServlet(), "/restservices/clds/*");
registration.setName("CamelServlet");
return registration;
}
@@ -140,11 +135,11 @@ public class Application extends SpringBootServletInitializer {
*/
@Bean
public ServletWebServerFactory getEmbeddedServletContainerFactory() {
- TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
+ var tomcat = new TomcatServletWebServerFactory();
if (httpRedirectedPort != null && keystoreFile != null) {
// Automatically redirect to HTTPS
tomcat = new TomcatEmbeddedServletContainerFactoryRedirection();
- Connector newConnector = createRedirectConnector(Integer.parseInt(springServerPort));
+ var newConnector = createRedirectConnector(Integer.parseInt(springServerPort));
if (newConnector != null) {
tomcat.addAdditionalTomcatConnectors(newConnector);
}
@@ -158,7 +153,7 @@ public class Application extends SpringBootServletInitializer {
+ " (Connector disabled)");
return null;
}
- Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+ var connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setSecure(false);
connector.setPort(Integer.parseInt(httpRedirectedPort));
@@ -167,10 +162,10 @@ public class Application extends SpringBootServletInitializer {
}
private String getSslExpirationDate() throws IOException {
- StringBuilder result = new StringBuilder(" :: SSL Certificates :: ");
+ var result = new StringBuilder(" :: SSL Certificates :: ");
try {
if (keystoreFile != null) {
- KeyStore keystore = KeyStore.getInstance(keyStoreType);
+ var keystore = KeyStore.getInstance(keyStoreType);
keystore.load(ResourceFileUtils.getResourceAsStream(keystoreFile.replace("classpath:", "")),
PassDecoder.decode(keyStorePass, keyFile).toCharArray());
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
index 9b6338e00..720a3f995 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
@@ -50,8 +50,8 @@ public class AafConfiguration {
* @return FilterRegistrationBean
*/
@Bean
- public FilterRegistrationBean cadiFilterRegistration() {
- FilterRegistrationBean registration = new FilterRegistrationBean();
+ public FilterRegistrationBean<Filter> cadiFilterRegistration() {
+ var registration = new FilterRegistrationBean<Filter>();
registration.setFilter(cadiFilter());
registration.addUrlPatterns("/restservices/clds/v1/user/*");
registration.addUrlPatterns("/restservices/clds/v2/dictionary/*");
@@ -64,4 +64,4 @@ public class AafConfiguration {
registration.setOrder(0);
return registration;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
index 5f10c0afb..0880e9b74 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
@@ -117,22 +117,22 @@ public class CamelConfiguration extends RouteBuilder {
private void configureCamelHttpComponent()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException,
IOException {
- RequestConfig requestConfig = RequestConfig.custom()
+ var requestConfig = RequestConfig.custom()
.setConnectTimeout(connectTimeout)
.setConnectionRequestTimeout(connectRequestTimeout)
.setSocketTimeout(socketTimeout).build();
if (trustStore != null) {
- KeyStore truststore = KeyStore.getInstance(trustStoreType);
+ var truststore = KeyStore.getInstance(trustStoreType);
truststore.load(
ResourceFileUtils.getResourceAsStream(trustStore),
Objects.requireNonNull(PassDecoder.decode(trustStorePass, keyFile)).toCharArray());
- TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
+ var trustFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
trustFactory.init(truststore);
- SSLContext sslcontext = SSLContext.getInstance("TLS");
+ var sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, trustFactory.getTrustManagers(), null);
camelContext.getComponent(HTTPS, HttpComponent.class).setHttpClientConfigurer(builder -> {
- SSLSocketFactory factory = new SSLSocketFactory(sslcontext,
+ var factory = new SSLSocketFactory(sslcontext,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
builder.setSSLSocketFactory(factory);
builder.setConnectionManager(new BasicHttpClientConnectionManager(
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
index a69d1a353..248fdcaea 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
@@ -53,7 +53,7 @@ public class DcaeInventoryCache {
}
public Set<String> getAllLoopIds() {
- return this.blueprintsMap.keySet();
+ return blueprintsMap.keySet();
}
public Set<DcaeInventoryResponse> getAllBlueprintsPerLoopId(String loopId) {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
index fb684b57b..d1d45a37d 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
@@ -24,6 +24,8 @@
package org.onap.policy.clamp.clds.tosca.update;
public class UnknownComponentException extends Exception {
+ private static final long serialVersionUID = 1187337836071750628L;
+
public UnknownComponentException(String nameEntry) {
this.getWrongName(nameEntry);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
index 651456ca6..bdf9af08b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
@@ -31,6 +31,8 @@ import java.util.Map.Entry;
import org.onap.policy.clamp.clds.tosca.update.templates.JsonTemplate;
public class Constraint {
+ private static final String ARRAY = "array";
+ private static final String STRING = "string";
private LinkedHashMap<String, Object> constraints;
private JsonTemplate jsonTemplate;
@@ -43,7 +45,7 @@ public class Constraint {
/**
* Deploy the linkedhashmap which contains the constraints, to extract them one to one.
*
- * @param jsonSchema The json Schema
+ * @param jsonSchema The json Schema
* @param typeProperty The ype property
* @return the json object
*/
@@ -57,14 +59,14 @@ public class Constraint {
/**
* Each case of Tosca constraints below parse specifically the field in the JsonObject.
*
- * @param jsonSchema Json Schema
- * @param nameConstraint Name constraint
+ * @param jsonSchema Json Schema
+ * @param nameConstraint Name constraint
* @param valueConstraint value constraint
- * @param typeProperty Type Property
+ * @param typeProperty Type Property
*/
@SuppressWarnings("unchecked")
public void parseConstraint(JsonObject jsonSchema, String nameConstraint, Object valueConstraint,
- String typeProperty) {
+ String typeProperty) {
switch (nameConstraint) {
case "equal":
checkTemplateField("const", jsonSchema, valueConstraint);
@@ -100,7 +102,7 @@ public class Constraint {
String[] maxtab = nameConstraint.split("_");
this.getLimitValue(jsonSchema, valueConstraint, typeProperty, maxtab[0]);
break;
- default://valid_value
+ default:// valid_value
this.getValueArray(jsonSchema, valueConstraint, typeProperty);
break;
}
@@ -110,17 +112,17 @@ public class Constraint {
/**
* To be done.
*
- * @param jsonSchema json schema
- * @param fieldValue field value
+ * @param jsonSchema json schema
+ * @param fieldValue field value
* @param typeProperty For the complex components, get a specific number of items/properties
*/
public void getSpecificLength(JsonObject jsonSchema, Object fieldValue, String typeProperty) {
switch (typeProperty.toLowerCase()) {
- case "string":
+ case STRING:
checkTemplateField("minLength", jsonSchema, fieldValue);
checkTemplateField("maxLength", jsonSchema, fieldValue);
break;
- case "array":
+ case ARRAY:
if (fieldValue.equals(1) && jsonTemplate.hasFields("uniqueItems")) {
jsonSchema.addProperty("uniqueItems", true);
} else {
@@ -139,48 +141,46 @@ public class Constraint {
/**
* To be done.
*
- * @param jsonSchema json schema
- * @param fieldValue field value
+ * @param jsonSchema json schema
+ * @param fieldValue field value
* @param typeProperty type property
- * @param side Get the limits fieldValue for the properties : depend of the type of the component
+ * @param side Get the limits fieldValue for the properties : depend of the type of the component
*/
public void getLimitValue(JsonObject jsonSchema, Object fieldValue, String typeProperty, String side) {
- switch (typeProperty) {
- case "string":
- if (side.equals("min")) {
- checkTemplateField("minLength", jsonSchema, fieldValue);
- } else {
- checkTemplateField("maxLength", jsonSchema, fieldValue);
- }
- break;
- default:// Array
- if (side.equals("min")) {
- checkTemplateField("minItems", jsonSchema, fieldValue);
- } else {
- checkTemplateField("maxItems", jsonSchema, fieldValue);
- }
- break;
+ if (typeProperty.equals(STRING)) {
+ if (side.equals("min")) {
+ checkTemplateField("minLength", jsonSchema, fieldValue);
+ } else {
+ checkTemplateField("maxLength", jsonSchema, fieldValue);
+ }
+ } else {
+ if (side.equals("min")) {
+ checkTemplateField("minItems", jsonSchema, fieldValue);
+ } else {
+ checkTemplateField("maxItems", jsonSchema, fieldValue);
+ }
}
-
}
/**
* To be done.
*
- * @param jsonSchema Json schema
- * @param fieldValue field value
+ * @param jsonSchema Json schema
+ * @param fieldValue field value
* @param typeProperty Get as Enum the valid values for the property
*/
public void getValueArray(JsonObject jsonSchema, Object fieldValue, String typeProperty) {
if (jsonTemplate.hasFields("enum")) {
- JsonArray enumeration = new JsonArray();
- if (typeProperty.equals("string") || typeProperty.equals("String")) {
+ var enumeration = new JsonArray();
+ if (typeProperty.equals(STRING) || typeProperty.equals("String")) {
+ @SuppressWarnings("unchecked")
ArrayList<String> arrayValues = (ArrayList<String>) fieldValue;
for (String arrayItem : arrayValues) {
enumeration.add(arrayItem);
}
jsonSchema.add("enum", enumeration);
} else {
+ @SuppressWarnings("unchecked")
ArrayList<Number> arrayValues = (ArrayList<Number>) fieldValue;
for (Number arrayItem : arrayValues) {
enumeration.add(arrayItem);
@@ -193,7 +193,7 @@ public class Constraint {
/**
* To be done.
*
- * @param field Field
+ * @param field Field
* @param jsonSchema Json schema
* @param fieldValue Simple way to avoid code duplication
*/
@@ -219,4 +219,4 @@ public class Constraint {
}
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
index 4db8b0356..77d920860 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
@@ -27,6 +27,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.List;
import org.onap.policy.clamp.clds.tosca.update.templates.JsonTemplate;
public class ToscaElementProperty {
@@ -40,7 +41,7 @@ public class ToscaElementProperty {
/**
* Constructor.
*
- * @param name the name
+ * @param name the name
* @param items the items
*/
public ToscaElementProperty(String name, LinkedHashMap<String, Object> items) {
@@ -69,9 +70,10 @@ public class ToscaElementProperty {
* For each primitive value, requires to get each field Value and cast it and add it in a Json.
*
* @param fieldsContent field
- * @param fieldName field
- * @param value value
+ * @param fieldName field
+ * @param value value
*/
+ @SuppressWarnings("unchecked")
public void addFieldToJson(JsonObject fieldsContent, String fieldName, Object value) {
if (value != null) {
String typeValue = value.getClass().getSimpleName();
@@ -89,7 +91,7 @@ public class ToscaElementProperty {
fieldsContent.addProperty(fieldName, (Integer) value);
break;
default:
- fieldsContent.add(fieldName, parseArray((ArrayList) value));
+ fieldsContent.add(fieldName, parseArray((ArrayList<Object>) value));
break;
}
}
@@ -101,31 +103,29 @@ public class ToscaElementProperty {
* @param arrayProperties array pro
* @return a json array
*/
- public JsonArray parseArray(ArrayList<Object> arrayProperties) {
- JsonArray arrayContent = new JsonArray();
+ public JsonArray parseArray(List<Object> arrayProperties) {
ArrayList<Object> arrayComponent = new ArrayList<>();
for (Object itemArray : arrayProperties) {
arrayComponent.add(itemArray);
}
- ArrayField af = new ArrayField(arrayComponent);
- arrayContent = af.deploy();
- return arrayContent;
+ var af = new ArrayField(arrayComponent);
+ return af.deploy();
}
/**
* Create an instance of Constraint, to extract the values and add it to the Json (according to the type
- * * of the current property).
+ * * of the current property).
*
* @param json a json
* @param constraints constraints
* @param jsonTemplate template
*/
@SuppressWarnings("unchecked")
- public void addConstraintsAsJson(JsonObject json, ArrayList<Object> constraints, JsonTemplate jsonTemplate) {
+ public void addConstraintsAsJson(JsonObject json, List<Object> constraints, JsonTemplate jsonTemplate) {
for (Object constraint : constraints) {
if (constraint instanceof LinkedHashMap) {
LinkedHashMap<String, Object> valueConstraint = (LinkedHashMap<String, Object>) constraint;
- Constraint constraintParser = new Constraint(valueConstraint, jsonTemplate);
+ var constraintParser = new Constraint(valueConstraint, jsonTemplate);
constraintParser.deployConstraints(json, (String) getItems().get("type"));
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
index 74fd8e5fd..1d5ed26e0 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
@@ -45,6 +45,20 @@ import org.onap.policy.clamp.loop.service.Service;
* @see org.onap.policy.clamp.clds.tosca.update.parser.ToscaConverterToJsonSchema#getJsonSchemaOfToscaElement
*/
public class ToscaConverterToJsonSchema {
+ private static final String ARRAY = "array";
+ private static final String CONSTRAINTS = "constraints";
+ private static final String DESCRIPTION = "description";
+ private static final String ENTRY_SCHEMA = "entry_schema";
+ private static final String FORMAT = "format";
+ private static final String LIST = "list";
+ private static final String MAP = "map";
+ private static final String METADATA = "metadata";
+ private static final String OBJECT = "object";
+ private static final String PROPERTIES = "properties";
+ private static final String REQUIRED = "required";
+ private static final String TITLE = "title";
+ private static final String TYPE = "type";
+
private LinkedHashMap<String, ToscaElement> components;
private LinkedHashMap<String, JsonTemplate> templates;
@@ -55,14 +69,14 @@ public class ToscaConverterToJsonSchema {
/**
* Constructor.
*
- * @param toscaElementsMap All the tosca elements found (policy type + data types + native tosca datatypes)
+ * @param toscaElementsMap All the tosca elements found (policy type + data types + native tosca datatypes)
* @param jsonSchemaTemplates All Json schema templates to use
- * @param metadataParser The metadata parser to use for metadata section
- * @param serviceModel The service model for clamp enrichment
+ * @param metadataParser The metadata parser to use for metadata section
+ * @param serviceModel The service model for clamp enrichment
*/
public ToscaConverterToJsonSchema(LinkedHashMap<String, ToscaElement> toscaElementsMap,
- LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates,
- ToscaMetadataParser metadataParser, Service serviceModel) {
+ LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser,
+ Service serviceModel) {
this.components = toscaElementsMap;
this.templates = jsonSchemaTemplates;
this.metadataParser = metadataParser;
@@ -87,23 +101,21 @@ public class ToscaConverterToJsonSchema {
*/
public JsonObject getFieldAsObject(ToscaElement toscaElement) {
- JsonObject globalFields = new JsonObject();
- if (templates.get("object").hasFields("title")) {
- globalFields.addProperty("title", toscaElement.getName());
+ var globalFields = new JsonObject();
+ if (templates.get(OBJECT).hasFields(TITLE)) {
+ globalFields.addProperty(TITLE, toscaElement.getName());
}
- if (templates.get("object").hasFields("type")) {
- globalFields.addProperty("type", "object");
+ if (templates.get(OBJECT).hasFields(TYPE)) {
+ globalFields.addProperty(TYPE, OBJECT);
}
- if (templates.get("object").hasFields("description")) {
- if (toscaElement.getDescription() != null) {
- globalFields.addProperty("description", toscaElement.getDescription());
- }
+ if (templates.get(OBJECT).hasFields(DESCRIPTION) && (toscaElement.getDescription() != null)) {
+ globalFields.addProperty(DESCRIPTION, toscaElement.getDescription());
}
- if (templates.get("object").hasFields("required")) {
- globalFields.add("required", this.getRequirements(toscaElement.getName()));
+ if (templates.get(OBJECT).hasFields(REQUIRED)) {
+ globalFields.add(REQUIRED, this.getRequirements(toscaElement.getName()));
}
- if (templates.get("object").hasFields("properties")) {
- globalFields.add("properties", this.deploy(toscaElement.getName()));
+ if (templates.get(OBJECT).hasFields(PROPERTIES)) {
+ globalFields.add(PROPERTIES, this.deploy(toscaElement.getName()));
}
return globalFields;
}
@@ -115,18 +127,18 @@ public class ToscaConverterToJsonSchema {
* @return a json array
*/
public JsonArray getRequirements(String nameComponent) {
- JsonArray requirements = new JsonArray();
+ var requirements = new JsonArray();
ToscaElement toParse = components.get(nameComponent);
- //Check for a father component, and launch the same process
+ // Check for a father component, and launch the same process
if (!"tosca.datatypes.Root".equals(toParse.getDerivedFrom())
&& !"tosca.policies.Root".equals(toParse.getDerivedFrom())) {
requirements.addAll(getRequirements(toParse.getDerivedFrom()));
}
- //Each property is checked, and add to the requirement array if it's required
+ // Each property is checked, and add to the requirement array if it's required
Collection<ToscaElementProperty> properties = toParse.getProperties().values();
for (ToscaElementProperty toscaElementProperty : properties) {
- if (toscaElementProperty.getItems().containsKey("required")
- && toscaElementProperty.getItems().get("required").equals(true)) {
+ if (toscaElementProperty.getItems().containsKey(REQUIRED)
+ && toscaElementProperty.getItems().get(REQUIRED).equals(true)) {
requirements.add(toscaElementProperty.getName());
}
}
@@ -141,19 +153,19 @@ public class ToscaConverterToJsonSchema {
* @return a json object
*/
public JsonObject deploy(String nameComponent) {
- JsonObject jsonSchema = new JsonObject();
+ var jsonSchema = new JsonObject();
ToscaElement toParse = components.get(nameComponent);
- //Check for a father component, and launch the same process
+ // Check for a father component, and launch the same process
if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root")
&& !toParse.getDerivedFrom().equals("tosca.policies.Root")) {
jsonSchema = this.getParent(toParse.getDerivedFrom());
}
- //For each component property, check if its a complex properties (a component) or not. In that case,
- //launch the analyse of the property.
+ // For each component property, check if its a complex properties (a component) or not. In that case,
+ // launch the analyse of the property.
for (Entry<String, ToscaElementProperty> property : toParse.getProperties().entrySet()) {
- if (getToscaElement((String) property.getValue().getItems().get("type")) != null) {
+ if (getToscaElement((String) property.getValue().getItems().get(TYPE)) != null) {
jsonSchema.add(property.getValue().getName(),
- this.getJsonSchemaOfToscaElement((String) property.getValue().getItems().get("type")));
+ this.getJsonSchemaOfToscaElement((String) property.getValue().getItems().get(TYPE)));
} else {
jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue()));
}
@@ -179,42 +191,42 @@ public class ToscaConverterToJsonSchema {
*/
@SuppressWarnings("unchecked")
public JsonObject complexParse(ToscaElementProperty toscaElementProperty) {
- JsonObject propertiesInJson = new JsonObject();
+ var propertiesInJson = new JsonObject();
JsonTemplate currentPropertyJsonTemplate;
- String typeProperty = (String) toscaElementProperty.getItems().get("type");
- if (typeProperty.toLowerCase().equals("list") || typeProperty.toLowerCase().equals("map")) {
- currentPropertyJsonTemplate = templates.get("object");
+ String typeProperty = (String) toscaElementProperty.getItems().get(TYPE);
+ if (LIST.equalsIgnoreCase(typeProperty) || MAP.equalsIgnoreCase(typeProperty)) {
+ currentPropertyJsonTemplate = templates.get(OBJECT);
} else {
- String propertyType = (String) toscaElementProperty.getItems().get("type");
+ String propertyType = (String) toscaElementProperty.getItems().get(TYPE);
currentPropertyJsonTemplate = templates.get(propertyType.toLowerCase());
}
- //Each "special" field is analysed, and has a specific treatment
+ // Each "special" field is analysed, and has a specific treatment
for (String propertyField : toscaElementProperty.getItems().keySet()) {
switch (propertyField) {
- case "type":
+ case TYPE:
if (currentPropertyJsonTemplate.hasFields(propertyField)) {
String fieldtype = (String) toscaElementProperty.getItems().get(propertyField);
switch (fieldtype.toLowerCase()) {
- case "list":
- propertiesInJson.addProperty("type", "array");
+ case LIST:
+ propertiesInJson.addProperty(TYPE, ARRAY);
break;
- case "map":
- propertiesInJson.addProperty("type", "object");
+ case MAP:
+ propertiesInJson.addProperty(TYPE, OBJECT);
break;
case "scalar-unit.time":
case "scalar-unit.frequency":
case "scalar-unit.size":
- propertiesInJson.addProperty("type", "string");
+ propertiesInJson.addProperty(TYPE, "string");
break;
case "timestamp":
- propertiesInJson.addProperty("type", "string");
- propertiesInJson.addProperty("format", "date-time");
+ propertiesInJson.addProperty(TYPE, "string");
+ propertiesInJson.addProperty(FORMAT, "date-time");
break;
case "float":
- propertiesInJson.addProperty("type", "number");
+ propertiesInJson.addProperty(TYPE, "number");
break;
case "range":
- propertiesInJson.addProperty("type", "integer");
+ propertiesInJson.addProperty(TYPE, "integer");
if (!checkConstraintPresence(toscaElementProperty, "greater_than")
&& currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) {
propertiesInJson.addProperty("exclusiveMinimum", false);
@@ -225,68 +237,58 @@ public class ToscaConverterToJsonSchema {
}
break;
default:
- propertiesInJson.addProperty("type", currentPropertyJsonTemplate.getName());
+ propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName());
break;
}
}
break;
- case "metadata":
+ case METADATA:
if (metadataParser != null) {
metadataParser.processAllMetadataElement(toscaElementProperty, serviceModel).entrySet()
- .forEach((jsonEntry) -> {
- propertiesInJson.add(jsonEntry.getKey(),
- jsonEntry.getValue());
-
- });
+ .forEach(jsonEntry -> propertiesInJson.add(jsonEntry.getKey(), jsonEntry.getValue()));
}
break;
- case "constraints":
+ case CONSTRAINTS:
toscaElementProperty.addConstraintsAsJson(propertiesInJson,
- (ArrayList<Object>) toscaElementProperty.getItems().get("constraints"),
+ (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS),
currentPropertyJsonTemplate);
break;
- case "entry_schema":
- //Here, a way to check if entry is a component (datatype) or a simple string
- if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema"))
- != null) {
- String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema");
- ToscaConverterToJsonSchema child = new ToscaConverterToJsonSchema(components, templates,
- metadataParser, serviceModel);
- JsonObject propertiesContainer = new JsonObject();
+ case ENTRY_SCHEMA:
+ // Here, a way to check if entry is a component (datatype) or a simple string
+ if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) {
+ String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel);
+ var propertiesContainer = new JsonObject();
- switch ((String) toscaElementProperty.getItems().get("type")) {
- case "map": // Get it as an object
- JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
- propertiesContainer.add(nameComponent, componentAsProperty);
- if (currentPropertyJsonTemplate.hasFields("properties")) {
- propertiesInJson.add("properties", propertiesContainer);
- }
- break;
- default://list : get it as an Array
- JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
- if (currentPropertyJsonTemplate.hasFields("properties")) {
- propertiesInJson.add("items", componentAsItem);
- propertiesInJson.addProperty("format", "tabs-top");
- }
- break;
+ if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) {
+ JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
+ propertiesContainer.add(nameComponent, componentAsProperty);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add(PROPERTIES, propertiesContainer);
+ }
+ } else {
+ JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add("items", componentAsItem);
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
+ }
}
-
- } else if (toscaElementProperty.getItems().get("type").equals("list")) {
+ } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) {
// Native cases
- JsonObject itemContainer = new JsonObject();
+ var itemContainer = new JsonObject();
String valueInEntrySchema =
- this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema");
- itemContainer.addProperty("type", valueInEntrySchema);
+ this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ itemContainer.addProperty(TYPE, valueInEntrySchema);
propertiesInJson.add("items", itemContainer);
- propertiesInJson.addProperty("format", "tabs-top");
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
}
// MAP Case, for now nothing
break;
default:
- //Each classical field : type, description, default..
- if (currentPropertyJsonTemplate.hasFields(propertyField) && !propertyField.equals("required")) {
+ // Each classical field : type, description, default..
+ if (currentPropertyJsonTemplate.hasFields(propertyField) && !propertyField.equals(REQUIRED)) {
toscaElementProperty.addFieldToJson(propertiesInJson, propertyField,
toscaElementProperty.getItems().get(propertyField));
}
@@ -319,32 +321,32 @@ public class ToscaConverterToJsonSchema {
* Simple method to extract quickly a type field from particular property item.
*
* @param toscaElementProperty the property
- * @param fieldName the fieldname
+ * @param fieldName the fieldname
* @return a string
*/
@SuppressWarnings("unchecked")
public String extractSpecificFieldFromMap(ToscaElementProperty toscaElementProperty, String fieldName) {
LinkedHashMap<String, String> entrySchemaFields =
(LinkedHashMap<String, String>) toscaElementProperty.getItems().get(fieldName);
- return entrySchemaFields.get("type");
+ return entrySchemaFields.get(TYPE);
}
/**
* Check if a constraint, for a specific property, is there.
*
* @param toscaElementProperty property
- * @param nameConstraint name constraint
+ * @param nameConstraint name constraint
* @return a flag boolean
*/
public boolean checkConstraintPresence(ToscaElementProperty toscaElementProperty, String nameConstraint) {
- boolean presentConstraint = false;
- if (toscaElementProperty.getItems().containsKey("constraints")) {
- ArrayList<Object> constraints = (ArrayList) toscaElementProperty.getItems().get("constraints");
+ var presentConstraint = false;
+ if (toscaElementProperty.getItems().containsKey(CONSTRAINTS)) {
+ @SuppressWarnings("unchecked")
+ ArrayList<Object> constraints = (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS);
for (Object constraint : constraints) {
- if (constraint instanceof LinkedHashMap) {
- if (((LinkedHashMap) constraint).containsKey(nameConstraint)) {
- presentConstraint = true;
- }
+ if (constraint instanceof LinkedHashMap
+ && ((LinkedHashMap<?, ?>) constraint).containsKey(nameConstraint)) {
+ presentConstraint = true;
}
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
index a3dd9c3e1..04d577f86 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
@@ -30,6 +30,11 @@ import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElementProperty;
import org.yaml.snakeyaml.Yaml;
public class ToscaElementParser {
+ private static final String DERIVED_FROM = "derived_from";
+ private static final String DESCRIPTION = "description";
+ private static final String PROPERTIES = "properties";
+ private static final String TYPE_VERSION = "type_version";
+
/**
* Constructor.
*/
@@ -37,17 +42,19 @@ public class ToscaElementParser {
}
private static LinkedHashMap<String, Object> searchAllDataTypesAndPolicyTypes(String toscaYaml) {
+ @SuppressWarnings("unchecked")
LinkedHashMap<String, LinkedHashMap<String, Object>> file =
(LinkedHashMap<String, LinkedHashMap<String, Object>>) new Yaml().load(toscaYaml);
LinkedHashMap<String, Object> allDataTypesFound = file.get("data_types");
LinkedHashMap<String, Object> allPolicyTypesFound = file.get("policy_types");
- LinkedHashMap<String, Object> allItemsFound = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> allItemsFound;
// Put the policies and datatypes in the same collection
allItemsFound = (allDataTypesFound == null) ? (new LinkedHashMap<>()) : allDataTypesFound;
allItemsFound.putAll(allPolicyTypesFound == null ? new LinkedHashMap<>() : allPolicyTypesFound);
return allItemsFound;
}
+ @SuppressWarnings("unchecked")
private static LinkedHashMap<String, Object> searchAllNativeToscaDataTypes(String toscaNativeYaml) {
return ((LinkedHashMap<String, LinkedHashMap<String, Object>>) new Yaml().load(toscaNativeYaml))
.get("data_types");
@@ -57,12 +64,11 @@ public class ToscaElementParser {
* Yaml Parse gets raw policies and datatypes, in different sections : necessary to extract
* all entities and put them at the same level.
*
- * @param toscaYaml the tosca model content
+ * @param toscaYaml the tosca model content
* @param nativeToscaYaml the tosca native datatype content
* @return a map of Tosca Element containing all tosca elements found (policy types and datatypes)
*/
- public static LinkedHashMap<String, ToscaElement> searchAllToscaElements(String toscaYaml,
- String nativeToscaYaml) {
+ public static LinkedHashMap<String, ToscaElement> searchAllToscaElements(String toscaYaml, String nativeToscaYaml) {
LinkedHashMap<String, Object> allItemsFound = searchAllDataTypesAndPolicyTypes(toscaYaml);
allItemsFound.putAll(searchAllNativeToscaDataTypes(nativeToscaYaml));
return parseAllItemsFound(allItemsFound);
@@ -73,25 +79,25 @@ public class ToscaElementParser {
*
* @param allMaps maps
*/
+ @SuppressWarnings("unchecked")
private static LinkedHashMap<String, ToscaElement> parseAllItemsFound(LinkedHashMap<String, Object> allMaps) {
- LinkedHashMap<String, ToscaElement> allItemsFound = new LinkedHashMap<String, ToscaElement>();
- //Component creations, from the file maps
+ LinkedHashMap<String, ToscaElement> allItemsFound = new LinkedHashMap<>();
+ // Component creations, from the file maps
for (Entry<String, Object> itemToParse : allMaps.entrySet()) {
LinkedHashMap<String, Object> componentBody = (LinkedHashMap<String, Object>) itemToParse.getValue();
- ToscaElement toscaElement =
- new ToscaElement(itemToParse.getKey(), (String) componentBody.get("derived_from"),
- (String) componentBody.get("description"));
- //If policy, version and type_version :
- if (componentBody.get("type_version") != null) {
- toscaElement.setVersion((String) componentBody.get("type_version"));
- toscaElement.setTypeVersion((String) componentBody.get("type_version"));
+ var toscaElement = new ToscaElement(itemToParse.getKey(), (String) componentBody.get(DERIVED_FROM),
+ (String) componentBody.get(DESCRIPTION));
+ // If policy, version and type_version :
+ if (componentBody.get(TYPE_VERSION) != null) {
+ toscaElement.setVersion((String) componentBody.get(TYPE_VERSION));
+ toscaElement.setTypeVersion((String) componentBody.get(TYPE_VERSION));
}
- //Properties creation, from the map
- if (componentBody.get("properties") != null) {
- LinkedHashMap<String, Object> properties =
- (LinkedHashMap<String, Object>) componentBody.get("properties");
- for (Entry<String, Object> itemToProperty : properties.entrySet()) {
- ToscaElementProperty toscaElementProperty = new ToscaElementProperty(itemToProperty.getKey(),
+ // Properties creation, from the map
+ if (componentBody.get(PROPERTIES) != null) {
+ LinkedHashMap<String, Object> foundProperties =
+ (LinkedHashMap<String, Object>) componentBody.get(PROPERTIES);
+ for (Entry<String, Object> itemToProperty : foundProperties.entrySet()) {
+ var toscaElementProperty = new ToscaElementProperty(itemToProperty.getKey(),
(LinkedHashMap<String, Object>) itemToProperty.getValue());
toscaElement.addProperties(toscaElementProperty);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
index 4e55263fb..2a886df3c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
@@ -63,10 +63,11 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
}
}
+ @SuppressWarnings("unchecked")
private static JsonObject parseMetadataPossibleValues(LinkedHashMap<String, Object> childNodeMap,
DictionaryService dictionaryService, Service serviceModel,
ToscaMetadataExecutor toscaMetadataExecutor) {
- JsonObject childObject = new JsonObject();
+ var childObject = new JsonObject();
if (childNodeMap.containsKey(ToscaSchemaConstants.METADATA)
&& childNodeMap.get(ToscaSchemaConstants.METADATA) != null) {
((LinkedHashMap<String, Object>) childNodeMap.get(ToscaSchemaConstants.METADATA)).forEach((key,
@@ -108,14 +109,14 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
if (dictionaryKeyArray.length == 2) {
dictionaryElements = new ArrayList<>(dictionaryService.getDictionary(dictionaryKeyArray[0])
.getDictionaryElements());
- JsonArray subDictionaryNames = new JsonArray();
+ var subDictionaryNames = new JsonArray();
new ArrayList<DictionaryElement>(dictionaryService.getDictionary(dictionaryKeyArray[1])
.getDictionaryElements()).forEach(elem -> subDictionaryNames.add(elem.getShortName()));
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
Optional.of(dictionaryElements).get().forEach(c -> {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType()));
if (c.getType() != null
&& c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
@@ -128,7 +129,7 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
jsonArray.add(jsonObject);
});
- JsonObject filterObject = new JsonObject();
+ var filterObject = new JsonObject();
filterObject.add(JsonEditorSchemaConstants.FILTERS, jsonArray);
childObject.addProperty(JsonEditorSchemaConstants.TYPE,
@@ -149,8 +150,8 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
*/
private static void processSimpleDictionaryElements(String[] dictionaryKeyArray, JsonObject childObject,
DictionaryService dictionaryService) {
- JsonArray dictionaryNames = new JsonArray();
- JsonArray dictionaryFullNames = new JsonArray();
+ var dictionaryNames = new JsonArray();
+ var dictionaryFullNames = new JsonArray();
dictionaryService.getDictionary(dictionaryKeyArray[0]).getDictionaryElements().forEach(c -> {
// Json type will be translated before Policy creation
if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
@@ -167,7 +168,7 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
}
// Add Enum titles for generated translated values during JSON instance
// generation
- JsonObject enumTitles = new JsonObject();
+ var enumTitles = new JsonObject();
enumTitles.add(JsonEditorSchemaConstants.ENUM_TITLES, dictionaryNames);
if (childObject.get(JsonEditorSchemaConstants.OPTIONS) != null) {
childObject.get(JsonEditorSchemaConstants.OPTIONS).getAsJsonArray().add(enumTitles);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
index 1813d0786..af7f8cc54 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
@@ -44,9 +44,9 @@ public class JsonTemplateManager {
/**
* Constructor.
*
- * @param toscaYamlContent Policy Tosca Yaml content as string
+ * @param toscaYamlContent Policy Tosca Yaml content as string
* @param nativeToscaDatatypes The tosca yaml with tosca native datatypes
- * @param jsonSchemaTemplates template properties as string
+ * @param jsonSchemaTemplates template properties as string
*/
public JsonTemplateManager(String toscaYamlContent, String nativeToscaDatatypes, String jsonSchemaTemplates) {
if (toscaYamlContent != null && !toscaYamlContent.isEmpty()) {
@@ -57,7 +57,7 @@ public class JsonTemplateManager {
}
}
- //GETTERS & SETTERS
+ // GETTERS & SETTERS
public LinkedHashMap<String, ToscaElement> getToscaElements() {
return toscaElements;
}
@@ -77,12 +77,12 @@ public class JsonTemplateManager {
/**
* Add a template.
*
- * @param name name
+ * @param name name
* @param jsonTemplateFields fields
*/
public void addTemplate(String name, List<JsonTemplateField> jsonTemplateFields) {
- JsonTemplate jsonTemplate = new JsonTemplate(name, jsonTemplateFields);
- //If it is true, the operation does not have any interest :
+ var jsonTemplate = new JsonTemplate(name, jsonTemplateFields);
+ // If it is true, the operation does not have any interest :
// replace OR put two different object with the same body
if (!jsonSchemaTemplates.containsKey(jsonTemplate.getName()) || !this.hasTemplate(jsonTemplate)) {
this.jsonSchemaTemplates.put(jsonTemplate.getName(), jsonTemplate);
@@ -101,11 +101,11 @@ public class JsonTemplateManager {
/**
* Update Template : adding with true flag, removing with false.
*
- * @param nameTemplate name template
+ * @param nameTemplate name template
* @param jsonTemplateField field name
- * @param operation operation
+ * @param operation operation
*/
- public void updateTemplate(String nameTemplate, JsonTemplateField jsonTemplateField, Boolean operation) {
+ public void updateTemplate(String nameTemplate, JsonTemplateField jsonTemplateField, boolean operation) {
// Operation = true && field is not present => add Field
if (operation
&& !this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) {
@@ -124,10 +124,10 @@ public class JsonTemplateManager {
* @return a boolean
*/
public boolean hasTemplate(JsonTemplate jsonTemplate) {
- boolean duplicateTemplate = false;
+ var duplicateTemplate = false;
Collection<String> templatesName = jsonSchemaTemplates.keySet();
if (templatesName.contains(jsonTemplate.getName())) {
- JsonTemplate existingJsonTemplate = jsonSchemaTemplates.get(jsonTemplate.getName());
+ var existingJsonTemplate = jsonSchemaTemplates.get(jsonTemplate.getName());
duplicateTemplate = existingJsonTemplate.checkFields(jsonTemplate);
}
return duplicateTemplate;
@@ -136,17 +136,15 @@ public class JsonTemplateManager {
/**
* For a given policy type, get a corresponding JsonObject from the tosca model.
*
- * @param policyType The policy type in the tosca
+ * @param policyType The policy type in the tosca
* @param toscaMetadataParser The MetadataParser class that must be used if metadata section are encountered,
- * if null they will be skipped
+ * if null they will be skipped
* @return an json object defining the equivalent json schema from the tosca for a given policy type
*/
public JsonObject getJsonSchemaForPolicyType(String policyType, ToscaMetadataParser toscaMetadataParser,
- Service serviceModel)
- throws UnknownComponentException {
- ToscaConverterToJsonSchema
- toscaConverterToJsonSchema = new ToscaConverterToJsonSchema(toscaElements, jsonSchemaTemplates,
- toscaMetadataParser, serviceModel);
+ Service serviceModel) throws UnknownComponentException {
+ var toscaConverterToJsonSchema =
+ new ToscaConverterToJsonSchema(toscaElements, jsonSchemaTemplates, toscaMetadataParser, serviceModel);
if (toscaConverterToJsonSchema.getToscaElement(policyType) == null) {
throw new UnknownComponentException(policyType);
}
@@ -166,7 +164,7 @@ public class JsonTemplateManager {
JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class);
for (Map.Entry<String, JsonElement> templateAsJson : templates.entrySet()) {
- JsonTemplate jsonTemplate = new JsonTemplate(templateAsJson.getKey());
+ var jsonTemplate = new JsonTemplate(templateAsJson.getKey());
JsonObject templateBody = (JsonObject) templateAsJson.getValue();
for (Map.Entry<String, JsonElement> field : templateBody.entrySet()) {
String fieldName = field.getKey();
@@ -174,12 +172,11 @@ public class JsonTemplateManager {
Object fieldValue = bodyFieldAsJson.get("defaultValue").getAsString();
Boolean fieldVisible = bodyFieldAsJson.get("visible").getAsBoolean();
Boolean fieldStatic = bodyFieldAsJson.get("static").getAsBoolean();
- JsonTemplateField
- bodyJsonTemplateField = new JsonTemplateField(fieldName, fieldValue, fieldVisible, fieldStatic);
+ var bodyJsonTemplateField = new JsonTemplateField(fieldName, fieldValue, fieldVisible, fieldStatic);
jsonTemplate.getJsonTemplateFields().add(bodyJsonTemplateField);
}
generatedTemplates.put(jsonTemplate.getName(), jsonTemplate);
}
return generatedTemplates;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
index d6184c656..ab33984da 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
@@ -81,9 +81,9 @@ public final class ResourceFileUtils {
}
private static String streamToString(InputStream inputStream) {
- try (Scanner scanner = new Scanner(inputStream)) {
- Scanner delimitedScanner = scanner.useDelimiter("\\A");
+ try (var scanner = new Scanner(inputStream)) {
+ var delimitedScanner = scanner.useDelimiter("\\A");
return delimitedScanner.hasNext() ? delimitedScanner.next() : "";
}
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java b/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
index 6479cf767..5cb5e143f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
@@ -96,7 +96,7 @@ public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, D
@Override
public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
- try (final OutputStreamWriter osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
+ try (final var osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
final BufferedWriter writer = IOHelper.buffered(osw)) {
gson.toJson(graph, writer);
}
@@ -112,7 +112,7 @@ public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, D
@Override
public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
- try (final InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
+ try (final var isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
final BufferedReader reader = IOHelper.buffered(isr)) {
if (unmarshalType.equals(String.class)) {
return IOUtils.toString(reader);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java b/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
index ed8464b14..ddc39599c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
@@ -73,6 +73,7 @@ public class JsonTypeDescriptor extends AbstractTypeDescriptor<JsonObject> {
return JsonUtils.GSON_JPA_MODEL.fromJson(string, JsonObject.class);
}
+ @SuppressWarnings("unchecked")
@Override
public <X> X unwrap(JsonObject value, Class<X> type, WrapperOptions options) {
if (value == null) {
@@ -95,7 +96,7 @@ public class JsonTypeDescriptor extends AbstractTypeDescriptor<JsonObject> {
return null;
}
- if (String.class.isInstance(value)) {
+ if (value instanceof String) {
return JsonUtils.GSON_JPA_MODEL.fromJson((String) value, JsonObject.class);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
index f46f4227b..2da1c0553 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
@@ -45,7 +45,6 @@ import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.loop.template.LoopElementModel;
import org.onap.policy.clamp.loop.template.LoopTemplate;
import org.onap.policy.clamp.loop.template.LoopTemplatesRepository;
-import org.onap.policy.clamp.loop.template.PolicyModel;
import org.onap.policy.clamp.loop.template.PolicyModelsRepository;
import org.onap.policy.clamp.policy.PolicyEngineServices;
import org.springframework.beans.factory.annotation.Autowired;
@@ -95,11 +94,11 @@ public class CsarInstaller {
boolean alreadyInstalled = csarServiceInstaller.isServiceAlreadyDeployed(csar);
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
- alreadyInstalled = alreadyInstalled
- && loopTemplatesRepository.existsById(LoopTemplate.generateLoopTemplateName(
- csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
- blueprint.getValue().getResourceAttached().getResourceInstanceName(),
- blueprint.getValue().getBlueprintArtifactName()));
+ alreadyInstalled =
+ alreadyInstalled && loopTemplatesRepository.existsById(LoopTemplate.generateLoopTemplateName(
+ csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
+ blueprint.getValue().getResourceAttached().getResourceInstanceName(),
+ blueprint.getValue().getBlueprintArtifactName()));
}
return alreadyInstalled;
}
@@ -109,14 +108,14 @@ public class CsarInstaller {
*
* @param csar The Csar Handler
* @throws SdcArtifactInstallerException The SdcArtifactInstallerException
- * @throws InterruptedException The InterruptedException
- * @throws BlueprintParserException In case of issues with the blueprint
- * parsing
+ * @throws InterruptedException The InterruptedException
+ * @throws BlueprintParserException In case of issues with the blueprint
+ * parsing
*/
public void installTheCsar(CsarHandler csar)
throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException {
logger.info("Installing the CSAR " + csar.getFilePath());
- Service associatedService = csarServiceInstaller.installTheService(csar);
+ var associatedService = csarServiceInstaller.installTheService(csar);
cdsDataInstaller.installCdsServiceProperties(csar, associatedService);
installTheLoopTemplates(csar, associatedService);
@@ -126,12 +125,12 @@ public class CsarInstaller {
/**
* Install the loop templates from the csar.
*
- * @param csar The Csar Handler
+ * @param csar The Csar Handler
* @param service The service object that is related to the loop
* @throws SdcArtifactInstallerException The SdcArtifactInstallerException
- * @throws InterruptedException The InterruptedException
- * @throws BlueprintParserException In case of issues with the blueprint
- * parsing
+ * @throws InterruptedException The InterruptedException
+ * @throws BlueprintParserException In case of issues with the blueprint
+ * parsing
*/
public void installTheLoopTemplates(CsarHandler csar, Service service)
throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException {
@@ -150,10 +149,9 @@ public class CsarInstaller {
}
private LoopTemplate createLoopTemplateFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact,
- Service service)
- throws IOException, ParseException, InterruptedException, BlueprintParserException,
+ Service service) throws IOException, ParseException, InterruptedException, BlueprintParserException,
SdcArtifactInstallerException {
- LoopTemplate newLoopTemplate = new LoopTemplate();
+ var newLoopTemplate = new LoopTemplate();
newLoopTemplate.setBlueprint(blueprintArtifact.getDcaeBlueprint());
newLoopTemplate.setName(LoopTemplate.generateLoopTemplateName(csar.getSdcNotification().getServiceName(),
csar.getSdcNotification().getServiceVersion(),
@@ -173,22 +171,19 @@ public class CsarInstaller {
}
private HashSet<LoopElementModel> createMicroServiceModels(BlueprintArtifact blueprintArtifact,
- List<BlueprintMicroService> microServicesChain)
- throws SdcArtifactInstallerException {
+ List<BlueprintMicroService> microServicesChain) throws SdcArtifactInstallerException {
HashSet<LoopElementModel> newSet = new HashSet<>();
for (BlueprintMicroService microService : microServicesChain) {
- LoopElementModel loopElementModel =
- new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE,
- null);
+ var loopElementModel =
+ new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE, null);
newSet.add(loopElementModel);
- PolicyModel newPolicyModel = policyEngineServices.createPolicyModelFromPolicyEngine(microService);
+ var newPolicyModel = policyEngineServices.createPolicyModelFromPolicyEngine(microService);
if (newPolicyModel != null) {
loopElementModel.addPolicyModel(newPolicyModel);
} else {
- throw new SdcArtifactInstallerException(
- "Unable to find the policy specified in the blueprint " + blueprintArtifact
- .getBlueprintArtifactName() + ") on the Policy Engine:"
- + microService.getModelType() + "/" + microService.getModelVersion());
+ throw new SdcArtifactInstallerException("Unable to find the policy specified in the blueprint "
+ + blueprintArtifact.getBlueprintArtifactName() + ") on the Policy Engine:"
+ + microService.getModelType() + "/" + microService.getModelVersion());
}
}
return newSet;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
index 6a935d011..e6c05ddd9 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
@@ -43,6 +43,10 @@ import org.onap.policy.clamp.loop.Loop;
import org.onap.policy.clamp.policy.microservice.MicroServicePolicy;
public class DcaeComponent extends ExternalComponent {
+ private static final String INSTALL = "install";
+ private static final String PROCESSING = "processing";
+ private static final String SUCCEEDED = "succeeded";
+ private static final String UNINSTALL = "uninstall";
@Transient
private static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeComponent.class);
@@ -136,12 +140,12 @@ public class DcaeComponent extends ExternalComponent {
*/
public static String getDeployPayload(Loop loop) {
JsonObject globalProp = loop.getGlobalPropertiesJson();
- JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(
+ var deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(
UNIQUE_BLUEPRINT_PARAMETERS);
String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId();
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId);
if (deploymentProp != null) {
rootObject.add(DCAE_INPUTS, deploymentProp);
@@ -159,12 +163,12 @@ public class DcaeComponent extends ExternalComponent {
*/
public static String getDeployPayload(Loop loop, MicroServicePolicy microServicePolicy) {
JsonObject globalProp = loop.getGlobalPropertiesJson();
- JsonObject deploymentProp =
+ var deploymentProp =
globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName());
String serviceTypeId = microServicePolicy.getDcaeBlueprintId();
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId);
if (deploymentProp != null) {
rootObject.add(DCAE_INPUTS, deploymentProp);
@@ -180,7 +184,7 @@ public class DcaeComponent extends ExternalComponent {
* @return The payload in string (json)
*/
public static String getUndeployPayload(Loop loop) {
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, loop.getLoopTemplate().getDcaeBlueprintId());
logger.info("DCAE Undeploy payload for unique blueprint: " + rootObject.toString());
return rootObject.toString();
@@ -193,7 +197,7 @@ public class DcaeComponent extends ExternalComponent {
* @return The payload in string (json)
*/
public static String getUndeployPayload(MicroServicePolicy policy) {
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, policy.getDcaeBlueprintId());
logger.info("DCAE Undeploy payload for multiple blueprints: " + rootObject.toString());
return rootObject.toString();
@@ -208,26 +212,26 @@ public class DcaeComponent extends ExternalComponent {
if (dcaeResponse == null) {
setState(BLUEPRINT_DEPLOYED);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("succeeded")) {
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus().equals(SUCCEEDED)) {
setState(MICROSERVICE_INSTALLED_SUCCESSFULLY);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
- .equals("processing")) {
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus()
+ .equals(PROCESSING)) {
setState(PROCESSING_MICROSERVICE_INSTALLATION);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus()
.equals("failed")) {
setState(MICROSERVICE_INSTALLATION_FAILED);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("succeeded")) {
+ if (dcaeResponse.getOperationType().equals(UNINSTALL)
+ && dcaeResponse.getStatus().equals(SUCCEEDED)) {
setState(MICROSERVICE_UNINSTALLED_SUCCESSFULLY);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("processing")) {
+ if (dcaeResponse.getOperationType().equals(UNINSTALL)
+ && dcaeResponse.getStatus().equals(PROCESSING)) {
setState(PROCESSING_MICROSERVICE_UNINSTALLATION);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall") && dcaeResponse.getStatus()
+ if (dcaeResponse.getOperationType().equals(UNINSTALL) && dcaeResponse.getStatus()
.equals("failed")) {
setState(MICROSERVICE_UNINSTALLATION_FAILED);
} else {
@@ -251,10 +255,10 @@ public class DcaeComponent extends ExternalComponent {
*/
public static List<DcaeInventoryResponse> convertToDcaeInventoryResponse(String responseBody)
throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
JSONObject jsonObj = (JSONObject) parser.parse(responseBody);
JSONArray itemsArray = (JSONArray) jsonObj.get("items");
- Iterator it = itemsArray.iterator();
+ Iterator<?> it = itemsArray.iterator();
List<DcaeInventoryResponse> inventoryResponseList = new LinkedList<>();
while (it.hasNext()) {
JSONObject item = (JSONObject) it.next();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java b/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
index 1a1414611..d4b80e509 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
@@ -27,6 +27,8 @@ import com.google.gson.JsonObject;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.clamp.clds.util.JsonUtils;
import org.onap.policy.clamp.loop.Loop;
import org.onap.policy.clamp.loop.components.external.DcaeComponent;
@@ -36,8 +38,8 @@ import org.yaml.snakeyaml.Yaml;
/**
* To decode the bluprint input parameters.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DcaeDeployParameters {
-
private static LinkedHashMap<String, JsonObject> init(Loop loop) {
LinkedHashMap<String, JsonObject> deploymentParamMap = new LinkedHashMap<>();
Set<MicroServicePolicy> microServiceList = loop.getMicroServicePolicies();
@@ -54,9 +56,10 @@ public class DcaeDeployParameters {
microService.getName());
}
+ @SuppressWarnings("unchecked")
private static JsonObject generateDcaeDeployParameter(String blueprint, String policyId) {
- JsonObject deployJsonBody = new JsonObject();
- Yaml yaml = new Yaml();
+ var deployJsonBody = new JsonObject();
+ var yaml = new Yaml();
Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
.load(blueprint)).get("inputs"));
inputsNodes.entrySet().stream().filter(e -> !e.getKey().contains("policy_id")).forEach(elem -> {
@@ -91,8 +94,8 @@ public class DcaeDeployParameters {
* @return The deploymentParameters in Json
*/
public static JsonObject getDcaeDeploymentParametersInJson(Loop loop) {
- JsonObject globalProperties = new JsonObject();
- JsonObject deployParamJson = new JsonObject();
+ var globalProperties = new JsonObject();
+ var deployParamJson = new JsonObject();
if (loop.getLoopTemplate().getUniqueBlueprint()) {
// Normally the unique blueprint could contain multiple microservices but then we can't guess
// the policy id params that will be used, so here we expect only one by default.
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
index f8bdab6c2..11587ce57 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
@@ -27,34 +27,26 @@ package org.onap.policy.clamp.policy;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import java.io.UnsupportedEncodingException;
-import java.util.Map;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
-import org.json.JSONObject;
import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport;
import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.policy.clamp.loop.common.AuditEntity;
import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.loop.template.LoopElementModel;
import org.onap.policy.clamp.loop.template.PolicyModel;
-import org.yaml.snakeyaml.Yaml;
@MappedSuperclass
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public abstract class Policy extends AuditEntity {
@Transient
@@ -89,8 +81,8 @@ public abstract class Policy extends AuditEntity {
@Expose
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumns({@JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"),
- @JoinColumn(name = "policy_model_version", referencedColumnName = "version")})
+ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type")
+ @JoinColumn(name = "policy_model_version", referencedColumnName = "version")
private PolicyModel policyModel;
/**
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
index 4142841e2..d56480053 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.util.LinkedHashMap;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
-import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.ExchangeBuilder;
import org.onap.policy.clamp.clds.config.ClampProperties;
import org.onap.policy.clamp.clds.sdc.controller.installer.BlueprintMicroService;
@@ -95,7 +94,7 @@ public class PolicyEngineServices {
* @return A PolicyModel created from policyEngine data or null if nothing is found on policyEngine
*/
public PolicyModel createPolicyModelFromPolicyEngine(String policyType, String policyVersion) {
- PolicyModel policyModelFound = policyModelsService.getPolicyModel(policyType, policyVersion);
+ var policyModelFound = policyModelsService.getPolicyModel(policyType, policyVersion);
if (policyModelFound == null) {
String policyTosca = this.downloadOnePolicyToscaModel(policyType, policyVersion);
if (policyTosca != null && !policyTosca.isEmpty()) {
@@ -127,6 +126,7 @@ public class PolicyEngineServices {
* This method synchronize the clamp database and the policy engine.
* So it creates the required PolicyModel.
*/
+ @SuppressWarnings("unchecked")
public void synchronizeAllPolicies() {
LinkedHashMap<String, Object> loadedYaml;
loadedYaml = new Yaml().load(downloadAllPolicyModels());
@@ -162,12 +162,12 @@ public class PolicyEngineServices {
*/
public String downloadOnePolicyToscaModel(String policyType, String policyVersion) {
logger.info("Downloading the policy tosca model " + policyType + "/" + policyVersion);
- DumperOptions options = new DumperOptions();
+ var options = new DumperOptions();
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
options.setIndent(4);
options.setPrettyFlow(true);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yamlParser = new Yaml(options);
+ var yamlParser = new Yaml(options);
String responseBody = callCamelRoute(
ExchangeBuilder.anExchange(camelContext).withProperty("policyModelType", policyType)
.withProperty("policyModelVersion", policyVersion).withProperty(RAISE_EXCEPTION_FLAG, false)
@@ -200,9 +200,9 @@ public class PolicyEngineServices {
}
private String callCamelRoute(Exchange exchange, String camelFlow, String logMsg) {
- for (int i = 0; i < retryLimit; i++) {
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate.send(camelFlow, exchange);
+ for (var i = 0; i < retryLimit; i++) {
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate.send(camelFlow, exchange);
if (HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
.is2xxSuccessful()) {
return (String) exchangeResponse.getIn().getBody();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
index 6098d0f63..38425fe93 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
@@ -26,7 +26,6 @@ package org.onap.policy.clamp.policy.pdpgroup;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -82,7 +81,7 @@ public class PdpGroupsAnalyzer {
// Copy the subgroup but empty the policies & types
pdpGroupsDeploymentPerToscaIdentifier.computeIfAbsent(toscaId, toscaKey -> new ConcurrentHashMap<>())
.computeIfAbsent(pdpGroupSource.getName(), pdpGroupName -> {
- PdpGroup pdpGroupCopy = new PdpGroup(pdpGroupSource);
+ var pdpGroupCopy = new PdpGroup(pdpGroupSource);
pdpGroupCopy.setPdpSubgroups(new ArrayList<>());
return pdpGroupCopy;
}).getPdpSubgroups().add(new PdpSubGroup(pdpSubGroupSource));
@@ -107,8 +106,8 @@ public class PdpGroupsAnalyzer {
Map<String, PdpGroup> mapOfGroups =
this.pdpGroupsDeploymentPerPolicy.get(new ToscaConceptIdentifier(policyName, version));
if (mapOfGroups != null) {
- JsonObject policyPdpGroups = new JsonObject();
- JsonArray pdpGroupsArray = new JsonArray();
+ var policyPdpGroups = new JsonObject();
+ var pdpGroupsArray = new JsonArray();
policyPdpGroups.add(ASSIGNED_PDP_GROUPS_INFO, pdpGroupsArray);
pdpGroupsArray.add(JsonUtils.GSON
.toJsonTree(mapOfGroups));
@@ -133,8 +132,8 @@ public class PdpGroupsAnalyzer {
if (PdpState.TERMINATED.equals(pdpGroup.getPdpGroupState())) {
return null;
}
- JsonObject supportedPdpGroup = new JsonObject();
- JsonArray supportedSubgroups = new JsonArray();
+ var supportedPdpGroup = new JsonObject();
+ var supportedSubgroups = new JsonArray();
supportedPdpGroup.add(pdpGroup.getName(), supportedSubgroups);
pdpGroup.getPdpSubgroups().stream().forEach(pdpSubGroup -> {
if (pdpSubGroup.getSupportedPolicyTypes().stream().anyMatch(policyTypeIdentifier ->
@@ -155,8 +154,8 @@ public class PdpGroupsAnalyzer {
* @return It returns a JsonObject containing each pdpGroup and subgroups associated
*/
public static JsonObject getSupportedPdpGroupsForModelType(PdpGroups pdpGroups, String policyType, String version) {
- JsonObject supportedPdpGroups = new JsonObject();
- JsonArray pdpGroupsArray = new JsonArray();
+ var supportedPdpGroups = new JsonObject();
+ var pdpGroupsArray = new JsonArray();
supportedPdpGroups.add(SUPPORTED_PDP_GROUPS_INFO, pdpGroupsArray);
pdpGroups.getGroups().stream().map(pdpGroup -> PdpGroupsAnalyzer.getSupportedPdpSubgroupsForModelType(pdpGroup,
@@ -177,4 +176,4 @@ public class PdpGroupsAnalyzer {
.setPolicyPdpGroup(getSupportedPdpGroupsForModelType(pdpGroups, policyModel.getPolicyModelType(),
policyModel.getVersion())));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
index 4b01d6902..4f748d5dd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
@@ -188,8 +188,8 @@ public class Dictionary extends AuditEntity implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
index 557a2e96c..45d4d64b1 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
@@ -70,6 +70,8 @@ public class AuthorizationControllerItCase {
public static void setupBefore() {
sc.setAuthentication(new Authentication() {
+ private static final long serialVersionUID = -6282526745791629050L;
+
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return Arrays.asList(new SimpleGrantedAuthority(
@@ -121,7 +123,7 @@ public class AuthorizationControllerItCase {
@Test
public void testIsUserPermitted() {
- assertEquals(AuthorizationController.getPrincipalName(sc), "admin");
+ assertEquals("admin", AuthorizationController.getPrincipalName(sc));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "dev", "read")));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage", "dev", "DEPLOY")));
assertTrue(auth.isUserPermitted(
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
index 017881ba7..ad7efed36 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
@@ -67,11 +67,13 @@ public class RobotItCase {
public void robotTests() throws Exception {
File robotFolder = new File(getClass().getClassLoader().getResource("robotframework").getFile());
Volume testsVolume = new Volume("/opt/robotframework/tests");
- DockerClient client = DockerClientBuilder
- .getInstance()
- .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
- .build();
-
+ // @formatter:off
+ DockerClient client =
+ DockerClientBuilder
+ .getInstance()
+ .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
+ .build();
+ // @formatter:on
BuildImageResultCallback callback = new BuildImageResultCallback() {
@Override
@@ -82,14 +84,17 @@ public class RobotItCase {
};
String imageId = client.buildImageCmd(robotFolder).exec(callback).awaitImageId();
- CreateContainerResponse createContainerResponse = client.createContainerCmd(imageId)
+ // @formatter:off
+ CreateContainerResponse createContainerResponse =
+ client
+ .createContainerCmd(imageId)
.withVolumes(testsVolume)
- .withBinds(
- new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
+ .withBinds(new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
.withEnv("CLAMP_PORT=" + httpPort)
.withStopTimeout(TIMEOUT_S)
.withNetworkMode("host")
.exec();
+ // @formatter:on
String id = createContainerResponse.getId();
client.startContainerCmd(id).exec();
InspectContainerResponse exec;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
index 08e425abf..423876ede 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
@@ -55,7 +55,6 @@ public class CsarHandlerTest {
private static final String SERVICE_UUID = "serviceUUID";
private static final String RESOURCE1_UUID = "resource1UUID";
private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
- private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
private static final String BLUEPRINT2_NAME = "FOI.Simfoimap223S0112.event_proc_bp2.yaml";
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
index 6f6f5c104..9cf7cee6b 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
@@ -47,9 +47,10 @@ public class ArrayFieldTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
ArrayField arrayParser = new ArrayField((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
JsonArray toTest = arrayParser.deploy();
String reference = "[1,\"String\",5.5,true]";
assertEquals(reference, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
index 493ee992c..06a8bdac8 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
@@ -48,6 +48,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get value array.
*/
+ @SuppressWarnings("unchecked")
public void testGetValuesArray() {
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("timeout");
JsonTemplate jsonTemplate = jsonTemplateManager.getJsonSchemaTemplates().get("integer");
@@ -70,6 +71,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get Specific length.
*/
+ @SuppressWarnings("unchecked")
public void testGetSpecificLength() {
//Test for string type, same process for array
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("id");
@@ -88,6 +90,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get limit value.
*/
+ @SuppressWarnings("unchecked")
public void testGetLimitValue() {
//Test for array type, same process for string
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("description");
@@ -102,5 +105,4 @@ public class ConstraintTest extends TestCase {
toTest = resultProcess.get("maxItems").getAsInt();
assertEquals(7, toTest);
}
-
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
index 5652fa9cd..c43b84a66 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
@@ -50,6 +50,7 @@ public class ToscaElementPropertyTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
JsonArray toTest =
toscaElementProperty.parseArray((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
assertNotNull(toTest);
@@ -60,6 +61,7 @@ public class ToscaElementPropertyTest extends TestCase {
*
* @throws IOException In case of failure
*/
+ @SuppressWarnings("unchecked")
public void testAddConstraintsAsJson() throws IOException {
JsonTemplateManager jsonTemplateManager = new JsonTemplateManager(
ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
@@ -76,4 +78,4 @@ public class ToscaElementPropertyTest extends TestCase {
String test = "{\"enum\":[\"error\",\"timeout\",\"retries\",\"guard\",\"exception\"]}";
assertEquals(test, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
index ab6a41bca..4b93ed7be 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
@@ -132,7 +132,7 @@ public class LoggingUtilsTest {
assertEquals(targetServiceName, mdc.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME));
}
- private boolean checkMapKeys(Map map, String[] keys) {
+ private boolean checkMapKeys(Map<String, String> map, String[] keys) {
return Arrays.stream(keys).allMatch(key -> map.get(key) != null);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
index 622fd5999..1cc7e9032 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
@@ -24,7 +24,6 @@
package org.onap.policy.clamp.flow;
-import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -74,8 +73,8 @@ public class FlowLogOperationTest {
// then
String entity = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_ENTITY);
String serviceName = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME);
- assertEquals(entity, mockEntity);
- assertEquals(serviceName, mockServiceName);
+ assertThat(entity).isEqualTo(mockEntity);
+ assertThat(serviceName).isEqualTo(mockServiceName);
}
@Test
@@ -99,4 +98,4 @@ public class FlowLogOperationTest {
// then
assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
index 6728d292c..54ecaa639 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
@@ -104,8 +104,7 @@ public class LoopControllerTestItCase {
+ "\"success\":\"\",\"failure\":\"\",\"failure_timeout\":\"\",\"failure_retries\":\"\","
+ "\"failure_exception\":\"\",\"failure_guard\":\"\",\"target\":{\"type\":\"VNF\","
+ "\"resourceID\":\"vFW_PG_T1\"}}]}}}]";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonArray arr = ele.getAsJsonArray();
Loop loop = loopController.updateOperationalPolicies(EXAMPLE_LOOP_NAME, arr);
assertThat(loop.getOperationalPolicies()).hasSize(1);
@@ -126,8 +125,7 @@ public class LoopControllerTestItCase {
+ "\"cbs_host\":\"config-binding-service\",\"cbs_port\":\"10000\",\"external_port\":\"32012\","
+ "\"policy_model_id\":\"onap.policies.monitoring.cdap.tca.hi.lo.app\","
+ "\"policy_id\":\"tca_k8s_CLTCA_v1_0_vFW_PG_T10_k8s-tca-clamp-policy-05162019\"}}";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonObject obj = ele.getAsJsonObject();
loopController.updateGlobalPropertiesJson(EXAMPLE_LOOP_NAME, obj);
Loop loop = loopController.getLoop(EXAMPLE_LOOP_NAME);
@@ -170,6 +168,6 @@ public class LoopControllerTestItCase {
loopController.removeOperationalPolicy(EXAMPLE_LOOP_NAME, "testPolicyModel", "1.0.0");
Loop newLoop2 = loopController.getLoop(EXAMPLE_LOOP_NAME);
- assertThat(newLoop2.getOperationalPolicies().size()).isEqualTo(0);
+ assertThat(newLoop2.getOperationalPolicies().size()).isZero();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
index 7b0ab8614..ab256eafb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
@@ -47,7 +47,6 @@ public class LoopLogServiceTestItCase {
private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}";
private static final String CLAMP_COMPONENT = "CLAMP";
private static final String SAMPLE_LOG_MESSAGE = "Sample log";
- private static final String BLUEPRINT = "blueprint";
@Autowired
LoopService loopService;
@@ -93,4 +92,4 @@ public class LoopLogServiceTestItCase {
assertThat(log.getId()).isEqualTo(id);
Assertions.assertThat(log.getLoop()).isEqualTo(testLoop);
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
index 30d4ebe28..03cd89aeb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
@@ -26,7 +26,6 @@ package org.onap.policy.clamp.policy.pdpgroup;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.BeforeClass;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
index f3c3fc6cd..ce695ec6f 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
import org.junit.Test;
-import org.onap.policy.clamp.policy.pdpgroup.PdpGroupPayloadException;
import org.onap.policy.common.utils.test.ExceptionsTester;
public class PdpGroupPayloadExceptionTest extends ExceptionsTester {
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
index 34674e3ec..b07d3869c 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
@@ -70,6 +70,6 @@ public class PdpGroupPayloadTest {
JsonObject listOfOperations = new JsonObject();
listOfOperations.add(PdpGroupPayload.PDP_ACTIONS, operations);
- PdpGroupPayload pdpGroupPayload = new PdpGroupPayload(listOfOperations);
+ new PdpGroupPayload(listOfOperations);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
index be7a9d674..733e3734e 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
@@ -23,9 +23,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Arrays;
import org.junit.BeforeClass;