Inherit from the policy integration parent + fix all checkstyle issues detected by policy checkstyle (google) config
Issue-ID: POLICY-2922
Change-Id: I616846bbda8bb0f6250a842c248836c40e1068cf
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
<name>clamp</name>
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>2.1.0</version>
- </parent>
+ <parent>
+ <groupId>org.onap.policy.parent</groupId>
+ <artifactId>integration</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ <relativePath />
+ </parent>
<description>
This is the MAVEN project that builds everything for ONAP CLAMP.
}
/**
- * Instantiate permission given type from concatenated string
+ * Instantiate permission given type from concatenated string.
*
* @param concatenatedString
* the string type|instance|action, less than 3 params can be
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import fj.data.Array;
import java.io.IOException;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import java.util.stream.Collector;
import java.util.stream.Collectors;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
import org.onap.clamp.authorization.SecureServicePermission;
import org.springframework.context.ApplicationContext;
import com.google.gson.JsonElement;\r
import com.google.gson.JsonObject;\r
import com.google.gson.JsonParser;\r
-\r
import java.util.Date;\r
import java.util.Map;\r
-\r
import org.apache.camel.CamelContext;\r
import org.apache.camel.Exchange;\r
import org.apache.camel.builder.ExchangeBuilder;\r
\r
import com.att.eelf.configuration.EELFLogger;\r
import com.att.eelf.configuration.EELFManager;\r
-\r
import java.io.IOException;\r
import java.util.Date;\r
-\r
import org.apache.camel.CamelContext;\r
import org.apache.camel.Exchange;\r
import org.apache.camel.builder.ExchangeBuilder;\r
package org.onap.clamp.clds.config;
import javax.servlet.Filter;
-
import org.onap.clamp.clds.filter.ClampCadiFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.util.Properties;
-
import javax.annotation.Resource;
-
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
-
import javax.annotation.PostConstruct;
-
import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
import org.onap.clamp.clds.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.sdc.SdcControllersConfiguration;
import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException;
package org.onap.clamp.clds.model.cds;
import com.google.gson.annotations.Expose;
-
import java.util.LinkedList;
import java.util.List;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.util.Date;
import java.util.Map.Entry;
import java.util.concurrent.ThreadLocalRandom;
-
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration;
import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-
import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import org.json.JSONObject;
import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException;
import org.yaml.snakeyaml.Yaml;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.springframework.stereotype.Component;
@Component
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import org.apache.commons.io.IOUtils;
import org.codehaus.plexus.util.StringUtils;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
if (getToscaElement((String) property.getValue().getItems().get("type")) != null) {
jsonSchema.add(property.getValue().getName(),
this.getJsonSchemaOfToscaElement((String) property.getValue().getItems().get("type")));
- }
- else {
+ } else {
jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue()));
}
}
String typeProperty = (String) toscaElementProperty.getItems().get("type");
if (typeProperty.toLowerCase().equals("list") || typeProperty.toLowerCase().equals("map")) {
currentPropertyJsonTemplate = templates.get("object");
- }
- else {
+ } else {
String propertyType = (String) toscaElementProperty.getItems().get("type");
currentPropertyJsonTemplate = templates.get(propertyType.toLowerCase());
}
break;
}
- }
- // Native cases
- else if (toscaElementProperty.getItems().get("type").equals("list")) {
+ } else if (toscaElementProperty.getItems().get("type").equals("list")) {
+ // Native cases
JsonObject itemContainer = new JsonObject();
String valueInEntrySchema =
this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema");
if (dictionaryService != null) {
return parseMetadataPossibleValues(toscaElementProperty.getItems(), dictionaryService, serviceModel,
toscaMetadataExecutor);
- }
- else {
+ } else {
return null;
}
}
if (dictionaryFullNames.size() > 0) {
if (childObject.get(JsonEditorSchemaConstants.ENUM) != null) {
childObject.get(JsonEditorSchemaConstants.ENUM).getAsJsonArray().add(dictionaryFullNames);
- }
- else {
+ } else {
childObject.add(JsonEditorSchemaConstants.ENUM, dictionaryFullNames);
}
// Add Enum titles for generated translated values during JSON instance
enumTitles.add(JsonEditorSchemaConstants.ENUM_TITLES, dictionaryNames);
if (childObject.get(JsonEditorSchemaConstants.OPTIONS) != null) {
childObject.get(JsonEditorSchemaConstants.OPTIONS).getAsJsonArray().add(enumTitles);
- }
- else {
+ } else {
childObject.add(JsonEditorSchemaConstants.OPTIONS, enumTitles);
}
- }
- else {
+ } else {
if (childObject.get(JsonEditorSchemaConstants.ENUM) != null) {
childObject.get(JsonEditorSchemaConstants.ENUM).getAsJsonArray().add(dictionaryNames);
- }
- else {
+ } else {
childObject.add(JsonEditorSchemaConstants.ENUM, dictionaryNames);
}
}
dictionaryReference.length()).split("#");
if (dictionaryKeyArray.length > 1) {
processComplexDictionaryElements(dictionaryKeyArray, childObject, dictionaryService);
- }
- else {
+ } else {
processSimpleDictionaryElements(dictionaryKeyArray, childObject, dictionaryService);
}
}
String jsonType = null;
if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)) {
jsonType = JsonEditorSchemaConstants.TYPE_INTEGER;
- }
- else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) {
+ } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) {
jsonType = JsonEditorSchemaConstants.TYPE_ARRAY;
- }
- else {
+ } else {
jsonType = JsonEditorSchemaConstants.TYPE_STRING;
}
return jsonType;
if (fieldStaticStatus(fieldName)) {
String defaultValue = (String) this.getSpecificField(fieldName).getValue();
jsonSchema.addProperty(fieldName, defaultValue);
- }
- else {
+ } else {
jsonSchema.addProperty(fieldName, value);
}
}
if (toscaYamlContent != null && !toscaYamlContent.isEmpty()) {
this.toscaElements = ToscaElementParser.searchAllToscaElements(toscaYamlContent, nativeToscaDatatypes);
this.jsonSchemaTemplates = initializeTemplates(jsonSchemaTemplates);
- }
- else {
+ } else {
toscaElements = null;
}
}
if (operation
&& !this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) {
this.jsonSchemaTemplates.get(nameTemplate).addField(jsonTemplateField);
- }
- // Operation = false && field is present => remove Field
- else if (!operation
+ } else if (!operation
&& this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) {
+ // Operation = false && field is present => remove Field
this.jsonSchemaTemplates.get(nameTemplate).removeField(jsonTemplateField);
}
}
* For a given policy type, get a corresponding JsonObject from the tosca model.
*
* @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
+ * @param toscaMetadataParser The MetadataParser class that must be used if metadata section are encountered,
+ * 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,
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.io.InputStream;
import java.util.Properties;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-
import java.time.Instant;
-
import org.onap.clamp.authorization.SecureServicePermission;
import org.onap.clamp.authorization.SecureServicePermissionDeserializer;
import org.onap.clamp.dao.model.gson.converter.InstantDeserializer;
return dateFormat;
}
- /*********************************************************************************************
+ /* *******************************************************************************************
* Method for ONAP Application Logging Specification v1.2
- ********************************************************************************************/
+ * *******************************************************************************************/
/**
* Report <tt>ENTERING</tt> marker.
/** MDC reporting outcome description. */
public static final String RESPONSE_DESCRIPTION = "ResponseDesc";
- /** MDC reporting severity */
+ /** MDC reporting severity. */
public static final String RESPONSE_SEVERITY = "Severity";
- /** MDC reporting response status code */
+ /** MDC reporting response status code. */
public static final String RESPONSE_STATUS_CODE = "StatusCode";
/** MDC recording error code. */
ASYNCHRONOUS("ASYNCHRONOUS", Markers.INVOKE_ASYNCHRONOUS);
/** Enum value. */
- private String mString;
+ private String enumValue;
/** Corresponding marker. */
- private Marker mMarker;
+ private Marker marker;
/**
* Construct enum.
*
- * @param s enum value.
- * @param m corresponding Marker.
+ * @param enumValue enum value.
+ * @param marker corresponding Marker.
*/
- InvocationMode(final String s, final Marker m) {
- this.mString = s;
- this.mMarker = m;
+ InvocationMode(final String enumValue, final Marker marker) {
+ this.enumValue = enumValue;
+ this.marker = marker;
}
/**
* @return Marker.
*/
public Marker getMarker() {
- return this.mMarker;
+ return this.marker;
}
/**
*/
@Override
public String toString() {
- return this.mString;
+ return this.enumValue;
}
}
package org.onap.clamp.configuration;
import com.google.gson.Gson;
-
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
-
import org.apache.camel.Exchange;
import org.apache.camel.spi.DataFormat;
import org.apache.camel.spi.DataFormatName;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-
import java.lang.reflect.Type;
import java.time.Instant;
import java.time.ZoneId;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
-
import java.lang.reflect.Type;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
-
import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions;
package org.onap.clamp.dao.model.jsontype;
import com.google.gson.JsonObject;
-
import java.io.Serializable;
-
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
package org.onap.clamp.dao.model.jsontype;
import com.google.gson.JsonObject;
-
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
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());
+ "Unable to find the policy specified in the blueprint " + blueprintArtifact
+ .getBlueprintArtifactName() + ") on the Policy Engine:"
+ + microService.getModelType() + "/" + microService.getModelVersion());
}
}
return newSet;
if (LoopElementModel.MICRO_SERVICE_TYPE.equals(element.getLoopElementModel().getLoopElementType())) {
this.addMicroServicePolicy((MicroServicePolicy) element.getLoopElementModel()
.createPolicyInstance(this, toscaConverter));
- }
- else if (LoopElementModel.OPERATIONAL_POLICY_TYPE
+ } else if (LoopElementModel.OPERATIONAL_POLICY_TYPE
.equals(element.getLoopElementModel().getLoopElementType())) {
this.addOperationalPolicy((OperationalPolicy) element.getLoopElementModel()
.createPolicyInstance(this, toscaConverter));
if (other.name != null) {
return false;
}
- }
- else if (!name.equals(other.name)) {
+ } else if (!name.equals(other.name)) {
return false;
}
return true;
package org.onap.clamp.loop;
import java.util.List;
-
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
resourcesPropByType.getAsJsonObject(nodeTemplate.getName())
.add(CONTROLLER_PROPERTIES, controllerProperties);
logger.info("Successfully installed the CDS data in Service");
- }
- else {
+ } else {
logger.warn("Skipping CDS data installation in Service, as sdnc_model_name and "
+ "sdnc_model_version are not provided in the CSAR");
}
public void setCreatedDate(Instant createdDate) {
if (createdDate != null) {
this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
- }
- else {
+ } else {
this.createdDate = null;
}
}
public void setUpdatedDate(Instant updatedDate) {
if (updatedDate != null) {
this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
- }
- else {
+ } else {
this.updatedDate = null;
}
}
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
-
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
-
import javax.persistence.Transient;
import org.apache.camel.Exchange;
import org.json.simple.JSONArray;
if (dcaeResponse == null) {
setState(BLUEPRINT_DEPLOYED);
- } else if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("succeeded")) {
- setState(MICROSERVICE_INSTALLED_SUCCESSFULLY);
- } else if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("processing")) {
- setState(PROCESSING_MICROSERVICE_INSTALLATION);
- } else if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("failed")) {
- setState(MICROSERVICE_INSTALLATION_FAILED);
- } else if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("succeeded")) {
- setState(MICROSERVICE_UNINSTALLED_SUCCESSFULLY);
- } else if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("processing")) {
- setState(PROCESSING_MICROSERVICE_UNINSTALLATION);
- } else if (dcaeResponse.getOperationType().equals("uninstall") && dcaeResponse.getStatus().equals("failed")) {
- setState(MICROSERVICE_UNINSTALLATION_FAILED);
} else {
- setState(IN_ERROR);
+ if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("succeeded")) {
+ setState(MICROSERVICE_INSTALLED_SUCCESSFULLY);
+ } else {
+ if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
+ .equals("processing")) {
+ setState(PROCESSING_MICROSERVICE_INSTALLATION);
+ } else {
+ if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
+ .equals("failed")) {
+ setState(MICROSERVICE_INSTALLATION_FAILED);
+ } else {
+ if (dcaeResponse.getOperationType().equals("uninstall")
+ && dcaeResponse.getStatus().equals("succeeded")) {
+ setState(MICROSERVICE_UNINSTALLED_SUCCESSFULLY);
+ } else {
+ if (dcaeResponse.getOperationType().equals("uninstall")
+ && dcaeResponse.getStatus().equals("processing")) {
+ setState(PROCESSING_MICROSERVICE_UNINSTALLATION);
+ } else {
+ if (dcaeResponse.getOperationType().equals("uninstall") && dcaeResponse.getStatus()
+ .equals("failed")) {
+ setState(MICROSERVICE_UNINSTALLATION_FAILED);
+ } else {
+ setState(IN_ERROR);
+ }
+ }
+ }
+ }
+ }
+ }
}
return this.getState();
}
package org.onap.clamp.loop.components.external;
import com.google.gson.annotations.Expose;
-
import org.apache.camel.Exchange;
/**
/**
* Generates the Json that must be sent to policy to add all policies to Active
* PDP group.
- * @param loop the loop object
+ *
+ * @param loop the loop object
* @param action POST (to add policy to group) or DELETE (to delete policy from group)
* @return The json, payload to send
*/
if (pdpGroupMap.get(pdpGroup) == null) {
pdpSubGroupMap = new HashMap<>();
policyList = new LinkedList<>();
- }
- else {
+ } else {
pdpSubGroupMap = pdpGroupMap.get(pdpGroup);
if (pdpSubGroupMap.get(pdpSubGroup) == null) {
policyList = new LinkedList<>();
- }
- else {
+ } else {
policyList = (List<JsonObject>) pdpSubGroupMap.get(pdpSubGroup);
}
}
ExternalComponentState newState = NOT_SENT;
if (found && deployed) {
newState = SENT_AND_DEPLOYED;
- }
- else if (found) {
- newState = SENT;
- }
- else if (deployed) {
- newState = IN_ERROR;
+ } else {
+ if (found) {
+ newState = SENT;
+ } else {
+ if (deployed) {
+ newState = IN_ERROR;
+ }
+ }
}
return newState;
}
Object defaultValue = ((Map<String, Object>) elem.getValue()).get("default");
if (defaultValue != null) {
addPropertyToNode(deployJsonBody, elem.getKey(), defaultValue);
- }
- else {
+ } else {
deployJsonBody.addProperty(elem.getKey(), "");
}
});
private static void addPropertyToNode(JsonObject node, String key, Object value) {
if (value instanceof String) {
node.addProperty(key, (String) value);
- }
- else if (value instanceof Number) {
+ } else if (value instanceof Number) {
node.addProperty(key, (Number) value);
- }
- else if (value instanceof Boolean) {
+ } else if (value instanceof Boolean) {
node.addProperty(key, (Boolean) value);
- }
- else if (value instanceof Character) {
+ } else if (value instanceof Character) {
node.addProperty(key, (Character) value);
- }
- else {
+ } else {
node.addProperty(key, JsonUtils.GSON.toJson(value));
}
}
generateDcaeDeployParameter(loop.getLoopTemplate().getBlueprint(),
((MicroServicePolicy) loop.getMicroServicePolicies().toArray()[0]).getName()));
- }
- else {
+ } else {
LinkedHashMap<String, JsonObject> deploymentParamMap = init(loop);
for (Map.Entry<String, JsonObject> mapElement : deploymentParamMap.entrySet()) {
deployParamJson.add(mapElement.getKey(), mapElement.getValue());
package org.onap.clamp.loop.log;
import com.google.gson.annotations.Expose;
-
import java.io.Serializable;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-
import org.onap.clamp.loop.Loop;
/**
if (other.serviceUuid != null) {
return false;
}
- }
- else if (!serviceUuid.equals(other.serviceUuid)) {
- return false;
+ } else {
+ if (!serviceUuid.equals(other.serviceUuid)) {
+ return false;
+ }
}
return true;
}
}
/**
- * @param shortName the shortName to set.
+ * * @param shortName the shortName to set.
*/
public void setShortName(String shortName) {
this.shortName = shortName;
public Policy createPolicyInstance(Loop loop, ToscaConverterWithDictionarySupport toscaConverter) {
if (LoopElementModel.MICRO_SERVICE_TYPE.equals(this.getLoopElementType())) {
return new MicroServicePolicy(loop, loop.getModelService(), this, toscaConverter);
- }
- else if (LoopElementModel.OPERATIONAL_POLICY_TYPE.equals(this.getLoopElementType())) {
+ } else if (LoopElementModel.OPERATIONAL_POLICY_TYPE.equals(this.getLoopElementType())) {
return new OperationalPolicy(loop, loop.getModelService(), this, toscaConverter);
- }
- else {
+ } else {
return null;
}
}
if (other.name != null) {
return false;
}
- }
- else if (!name.equals(other.name)) {
+ } else if (!name.equals(other.name)) {
return false;
}
return true;
* @param loopElementModel The loopElementModel to add
*/
public void addLoopElementModel(LoopElementModel loopElementModel) {
- this.addLoopElementModel(loopElementModel,this.loopElementModelsUsed.size());
+ this.addLoopElementModel(loopElementModel, this.loopElementModelsUsed.size());
}
/**
package org.onap.clamp.loop.template;
import com.google.gson.annotations.Expose;
-
import java.io.Serializable;
-
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
package org.onap.clamp.loop.template;
import java.util.List;
-
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
package org.onap.clamp.loop.template;
import com.google.gson.annotations.Expose;
-
import java.io.Serializable;
public class PolicyModelId implements Serializable {
package org.onap.clamp.loop.template;
import java.util.List;
-
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public PolicyModel savePolicyModelInNewTransaction(PolicyModel policyModel) {
- return policyModelsRepository.saveAndFlush(policyModel);
+ return policyModelsRepository.saveAndFlush(policyModel);
}
/**
import java.util.List;
import java.util.Set;
-
import org.onap.clamp.loop.Loop;
public interface PolicyService<T extends Policy> {
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import java.time.Instant;
-
import org.json.simple.parser.ParseException;
import org.onap.clamp.clds.client.PolicyEngineServices;
import org.onap.clamp.loop.template.PolicyModelsRepository;
if (other.name != null) {
return false;
}
- }
- else if (!name.equals(other.name)) {
+ } else if (!name.equals(other.name)) {
return false;
}
return true;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtils;
import org.onap.clamp.loop.service.Service;
public static final String TYPE_ARRAY = "array";
private OperationalPolicyRepresentationBuilder() {
- throw new IllegalStateException("This is Utility class, not supposed to be initiated.");
+ throw new IllegalStateException("This is Utility class, not supposed to be initiated.");
}
/**
jsonObject.add("artifact_version", createSchemaProperty(
"artifact version", STRING, artifactVersion, "True", null));
jsonObject.add("mode", createCdsInputProperty(
- "mode", STRING, "async" ,null));
+ "mode", STRING, "async", null));
jsonObject.add("data", createDataProperty(inputs, workFlowName));
return jsonObject;
}
dataObj, workFlowName);
} else {
dataObj.add(entry.getKey(),
- createCdsInputProperty(key, inputProperty.get(TYPE).getAsString(),null,
+ createCdsInputProperty(key, inputProperty.get(TYPE).getAsString(), null,
entry.getValue().getAsJsonObject()));
}
}
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
-
import java.util.List;
/**
package org.onap.clamp.policy.pdpgroup;
import com.google.gson.annotations.Expose;
-
import java.io.Serializable;
public class PolicyModelKey implements Serializable {
public class SdcSingleControllerConfigurationTest {
/**
- * @param fileName file for sdc controller configuration.
+ * This method loads the SDC controller configuration from a file located in the resource folder.
+ *
+ * @param fileName file for sdc controller configuration.
* @param sdcControllerName sdc controller name.
* @return instance of SdcSingleControllerConfiguration.
*/
public static SdcSingleControllerConfiguration loadControllerConfiguration(String fileName,
- String sdcControllerName) {
+ String sdcControllerName) {
InputStreamReader streamReader = new InputStreamReader(ResourceFileUtils.getResourceAsStream(fileName),
- StandardCharsets.UTF_8);
+ StandardCharsets.UTF_8);
JsonObject jsonNode = JsonUtils.GSON.fromJson(streamReader, JsonObject.class);
return new SdcSingleControllerConfiguration(jsonNode, sdcControllerName);
@Test
public final void testTheInit() throws SdcParametersException, IOException {
SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
- "sdc-controller1");
+ "sdc-controller1");
assertEquals("User", sdcConfig.getUser());
assertEquals("ThePassword", sdcConfig.getPassword());
assertEquals("consumerGroup", sdcConfig.getConsumerGroup());
assertEquals(30, sdcConfig.getPollingTimeout());
assertThat(SdcSingleControllerConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST)
- .hasSameSizeAs(sdcConfig.getRelevantArtifactTypes());
+ .hasSameSizeAs(sdcConfig.getRelevantArtifactTypes());
assertEquals("ThePassword", sdcConfig.getKeyStorePassword());
assertTrue(sdcConfig.activateServerTLSAuth());
assertThat(sdcConfig.getMsgBusAddress()).contains("localhost");
@Test(expected = SdcParametersException.class)
public final void testAllRequiredParameters() throws IOException {
SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
- "sdc-controller1");
+ "sdc-controller1");
// No exception should be raised
sdcConfig.testAllRequiredParameters();
sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-bad.json", "sdc-controller1");
@Test
public final void testAllRequiredParametersEmptyEncrypted() throws IOException {
SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration(
- "clds/sdc-controller-config-empty-encrypted.json", "sdc-controller1");
+ "clds/sdc-controller-config-empty-encrypted.json", "sdc-controller1");
sdcConfig.testAllRequiredParameters();
assertNull(sdcConfig.getKeyStorePassword());
}
@Test
public final void testConsumerGroupWithNull() throws IOException {
SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-NULL.json",
- "sdc-controller1");
+ "sdc-controller1");
assertTrue(sdcConfig.getConsumerGroup() == null);
}
}
@Test
public void testIsUserPermitted() {
- assertEquals(AuthorizationController.getPrincipalName(sc),"admin");
+ assertEquals(AuthorizationController.getPrincipalName(sc), "admin");
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "dev", "read")));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage", "dev", "DEPLOY")));
assertTrue(auth.isUserPermitted(
import static org.junit.Assert.fail;
import com.google.gson.JsonSyntaxException;
-
import java.io.IOException;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.clamp.clds.config.sdc.SdcControllersConfiguration;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-@ActiveProfiles({"clamp-default","clamp-default-user","clamp-sdc-controller"})
+@ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"})
public class SdcControllersConfigurationItCase {
@Autowired
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
@RunWith(SpringRunner.class)
@SpringBootTest
-@ActiveProfiles({"clamp-default","clamp-default-user","clamp-sdc-controller"})
+@ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"})
public class SdcSingleControllerItCase {
private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar";
import java.util.HashSet;
import java.util.Set;
-
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.ExchangeBuilder;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.TreeSet;
-
import org.junit.Test;
public class DcaeInventoryResponseTest {
import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.JsonObject;
-
import org.hibernate.HibernateException;
import org.junit.Test;
import org.onap.clamp.dao.model.jsontype.JsonTypeDescriptor;
@Test
public void testFromString() {
JsonObject object = new JsonObject();
- object.addProperty("one","oneValue");
+ object.addProperty("one", "oneValue");
JsonObject child = new JsonObject();
- child.addProperty("two","twoValue");
- object.add("child",child);
+ child.addProperty("two", "twoValue");
+ object.add("child", child);
JsonObject jsonResult = descriptor.fromString("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}");
assertThat(res1).isNull();
JsonObject object = new JsonObject();
- object.addProperty("one","oneValue");
+ object.addProperty("one", "oneValue");
JsonObject child = new JsonObject();
- child.addProperty("two","twoValue");
- object.add("child",child);
+ child.addProperty("two", "twoValue");
+ object.add("child", child);
String res2 = descriptor.unwrap(object, String.class, null);
assertThat(res2.replace("\n", "").replace(" ", ""))
.isEqualTo("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}");
@Test(expected = HibernateException.class)
public void testUnwrapExpectationThrown() {
JsonObject object = new JsonObject();
- object.addProperty("one","oneValue");
+ object.addProperty("one", "oneValue");
descriptor.unwrap(object, Integer.class, null);
}
assertThat(res1).isNull();
JsonObject object = new JsonObject();
- object.addProperty("one","oneValue");
+ object.addProperty("one", "oneValue");
JsonObject child = new JsonObject();
- child.addProperty("two","twoValue");
- object.add("child",child);
+ child.addProperty("two", "twoValue");
+ object.add("child", child);
JsonObject res2 = descriptor.wrap("{\"one\":\"oneValue\",\"child\":{\"two\":\"twoValue\"}}", null);
assertThat(res2).isEqualTo(object);
}
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.junit.Assert;
import org.junit.Test;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mockito.Mockito;
* Test fieldsEqual method.
*/
public void testFieldsEqualsMethod() {
- assertFalse(JsonTemplateField.fieldsEquals(field1,field3));
- assertFalse(JsonTemplateField.fieldsEquals(field1,field4));
- assertFalse(JsonTemplateField.fieldsEquals(field1,field5));
- assertTrue(JsonTemplateField.fieldsEquals(field1,field6));
+ assertFalse(JsonTemplateField.fieldsEquals(field1, field3));
+ assertFalse(JsonTemplateField.fieldsEquals(field1, field4));
+ assertFalse(JsonTemplateField.fieldsEquals(field1, field5));
+ assertTrue(JsonTemplateField.fieldsEquals(field1, field6));
}
/**
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
-@ActiveProfiles({"clamp-default","clamp-default-user","default-dictionary-elements"})
+@ActiveProfiles({"clamp-default", "clamp-default-user", "default-dictionary-elements"})
public class ToscaConverterWithDictionarySupportItCase {
@Autowired
import static org.mockito.ArgumentMatchers.eq;
import java.security.InvalidKeyException;
-
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
-
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
-
import org.junit.Test;
public class JsonUtilsTest {
Mockito.when(notificationData.getServiceArtifacts()).thenReturn(serviceArtifactsList);
CsarHandler csarHandler = new CsarHandler(notificationData, "", "");
- csarHandler
- .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME_CDS).
- getFile());
+ csarHandler.setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME_CDS)
+ .getFile());
Assert.assertEquals(csarHandler.getPolicyModelYaml(), Optional
.ofNullable(ResourceFileUtils.getResourceAsString("example/sdc/expected-result/policy-data.yaml")));
}
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNotNull;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
package org.onap.clamp.loop;
+import static org.assertj.core.api.Assertions.assertThat;
+
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.IOException;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
-import static org.assertj.core.api.Assertions.assertThat;
-
public class PolicyComponentTest {
/**
import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.JsonObject;
-
import org.junit.Test;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.service.Service;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
-@ActiveProfiles({"clamp-default","clamp-policy-controller"})
+@ActiveProfiles({"clamp-default", "clamp-policy-controller"})
public class PolicyEngineControllerTestItCase {
@Autowired
public void testPayloadConstruction() throws IOException {
MicroServicePolicy policy = new MicroServicePolicy("testPolicy", new PolicyModel(
"onap.policies.monitoring.cdap.tca.hi.lo.app",
- ResourceFileUtils.getResourceAsString("tosca/tosca_example.yaml"),"1.0.0"), false,null,null, null,null);
+ ResourceFileUtils.getResourceAsString("tosca/tosca_example.yaml"), "1.0.0"), false, null, null, null,
+ null);
policy.setConfigurationsJson(JsonUtils.GSON.fromJson(
- ResourceFileUtils.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class));
+ ResourceFileUtils.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class));
JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/micro-service-policy-payload.json"),
- policy.createPolicyPayload(), false);
+ policy.createPolicyPayload(), false);
}
}
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
-
import org.junit.Test;
public class PdpGroupTest {
@Test
public void testEqualsMethod() throws IOException {
- PolicyModelKey key1 = new PolicyModelKey("name1","1.0.0");
- PolicyModelKey key2 = new PolicyModelKey(null,"1.0.0");
- PolicyModelKey key3 = new PolicyModelKey("name1",null);
+ PolicyModelKey key1 = new PolicyModelKey("name1", "1.0.0");
+ PolicyModelKey key2 = new PolicyModelKey(null, "1.0.0");
+ PolicyModelKey key3 = new PolicyModelKey("name1", null);
assertThat(key1.equals(null)).isFalse();
assertThat(key1.equals("key2")).isFalse();
assertThat(key2.equals(key1)).isFalse();
assertThat(key3.equals(key1)).isFalse();
- PolicyModelKey key4 = new PolicyModelKey("name2","1.0.0");
- PolicyModelKey key5 = new PolicyModelKey("name1","2.0.0");
+ PolicyModelKey key4 = new PolicyModelKey("name2", "1.0.0");
+ PolicyModelKey key5 = new PolicyModelKey("name1", "2.0.0");
assertThat(key1.equals(key4)).isFalse();
assertThat(key1.equals(key5)).isFalse();
- PolicyModelKey key6 = new PolicyModelKey("name(.*)","1.0.0");
- PolicyModelKey key7 = new PolicyModelKey("name1","1.0.0");
+ PolicyModelKey key6 = new PolicyModelKey("name(.*)", "1.0.0");
+ PolicyModelKey key7 = new PolicyModelKey("name1", "1.0.0");
assertThat(key1.equals(key6)).isTrue();
assertThat(key1.equals(key7)).isTrue();
}