From e1d67de22d0bf9fe50c16ee6bc1e50310e74d4fa Mon Sep 17 00:00:00 2001 From: Taka Cho Date: Tue, 24 Aug 2021 13:03:02 -0400 Subject: clamp sonar fix on test code and the rest - rename files to "...ItTestCase" to comply SONAR and checkstyle - surefire plugin include *Test.java files - failsafe plugin include *ItTestCase.java files - use assertEquals etc. - replace to "var" - remove unused import Issue-ID: POLICY-3452 Change-Id: I2e6e829726c4585f5f8bc985f4e8f2b88d17aef1 Signed-off-by: Taka Cho --- .../onap/policy/clamp/authorization/AuthorizationController.java | 1 - runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java | 2 -- .../main/java/org/onap/policy/clamp/clds/client/CdsServices.java | 1 - .../java/org/onap/policy/clamp/clds/config/ClampProperties.java | 1 - .../java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java | 1 - .../onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java | 5 +---- .../policy/clamp/clds/sdc/controller/installer/CsarHandler.java | 3 --- .../onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java | 6 +++--- .../src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java | 4 ++-- runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java | 2 -- .../org/onap/policy/clamp/loop/service/CsarServiceInstaller.java | 2 +- .../src/main/java/org/onap/policy/clamp/loop/service/Service.java | 1 - .../java/org/onap/policy/clamp/loop/template/LoopElementModel.java | 4 ++-- .../main/java/org/onap/policy/clamp/loop/template/PolicyModel.java | 1 - .../onap/policy/clamp/policy/microservice/MicroServicePolicy.java | 1 - .../org/onap/policy/clamp/policy/operational/OperationalPolicy.java | 1 - .../policy/clamp/policy/operational/OperationalPolicyService.java | 2 -- 17 files changed, 9 insertions(+), 29 deletions(-) (limited to 'runtime/src/main') diff --git a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java index 62614e729..cf639a35d 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java +++ b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java @@ -35,7 +35,6 @@ import org.onap.policy.common.utils.logging.LoggerUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java index 0e520dec1..1e5b003f1 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java @@ -26,7 +26,6 @@ package org.onap.policy.clamp.clds; import java.io.IOException; -import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -48,7 +47,6 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; -import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; public class ClampServlet extends CamelHttpTransportServlet { diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java index 27f706d77..8f492c761 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java @@ -34,7 +34,6 @@ import java.util.Date; import java.util.Map; 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.exception.cds.CdsParametersException; import org.onap.policy.clamp.clds.model.cds.CdsBpWorkFlowListResponse; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java index 34f0662c7..0ac58fc80 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java @@ -24,7 +24,6 @@ package org.onap.policy.clamp.clds.config; import java.io.IOException; -import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java index eb9de056c..7224493b5 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java @@ -26,7 +26,6 @@ package org.onap.policy.clamp.clds.filter; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.StandardCopyOption; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java index 9f5300a9f..9862728df 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java @@ -1,13 +1,10 @@ - /*- * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Modifications Copyright (c) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java index 89046afd1..2ca463ede 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java @@ -24,11 +24,8 @@ package org.onap.policy.clamp.clds.sdc.controller.installer; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Enumeration; import java.util.HashMap; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java index 5c96f2c4a..8e619969d 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -148,9 +148,9 @@ public class JsonTemplate { * @return a boolean */ public boolean checkFields(JsonTemplate jsonTemplate) { - boolean duplicateFields = false; + var duplicateFields = false; if (jsonTemplate.getJsonTemplateFields().size() == this.getJsonTemplateFields().size()) { - int countMatchingFields = 0; + var countMatchingFields = 0; //loop each component of first for (JsonTemplateField jsonTemplateFieldToCheck : jsonTemplate.getJsonTemplateFields()) { for (JsonTemplateField jsonTemplateField : this.getJsonTemplateFields()) { diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java index 5d09c065a..fcd375ad3 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java @@ -292,7 +292,7 @@ public class LoggingUtils { * @param targetServiceName The target service name */ public void invoke(String targetEntity, String targetServiceName) { - final String invocationId = UUID.randomUUID().toString(); + final var invocationId = UUID.randomUUID().toString(); invokeContext(targetEntity, targetServiceName, invocationId); @@ -396,7 +396,7 @@ public class LoggingUtils { private T invokeGeneric(final T con, String targetEntity, String targetServiceName) { - final String invocationId = UUID.randomUUID().toString(); + final var invocationId = UUID.randomUUID().toString(); // Set standard HTTP headers on (southbound request) builder. con.setRequestProperty(OnapLogConstants.Headers.REQUEST_ID, diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java index 946edd767..9449c25eb 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java @@ -26,13 +26,11 @@ package org.onap.policy.clamp.loop; import com.google.gson.JsonObject; -import java.io.IOException; import java.util.List; import java.util.Set; import javax.persistence.EntityNotFoundException; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.loop.template.LoopTemplatesService; -import org.onap.policy.clamp.loop.template.PolicyModel; import org.onap.policy.clamp.loop.template.PolicyModelsService; import org.onap.policy.clamp.policy.microservice.MicroServicePolicy; import org.onap.policy.clamp.policy.microservice.MicroServicePolicyService; diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java index 53365806b..10d98e362 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java @@ -120,7 +120,7 @@ public class CsarServiceInstaller { * @throws SdcArtifactInstallerException The SdcArtifactInstallerException */ public boolean isServiceAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException { - boolean alreadyInstalled = true; + var alreadyInstalled = true; var serviceDetails = JsonUtils.GSON.fromJson( JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class); alreadyInstalled = serviceRepository.existsById(serviceDetails.get("UUID").getAsString()); diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java index cc4e4c2fc..c955d2696 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java @@ -33,7 +33,6 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.util.JsonUtils; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.slf4j.Logger; diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java index 7477ae31f..e15731fc7 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java @@ -163,8 +163,8 @@ public class LoopElementModel 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/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java index 0d57caada..741530e99 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java @@ -37,7 +37,6 @@ import javax.persistence.ManyToMany; import javax.persistence.Table; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.common.AuditEntity; import org.onap.policy.clamp.util.SemanticVersioning; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java index 96edfa190..3f0f4e7b9 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java @@ -37,7 +37,6 @@ import javax.persistence.ManyToMany; import javax.persistence.Table; import org.apache.commons.lang3.RandomStringUtils; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.Loop; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java index c7d67bd4e..203f2771e 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java @@ -40,7 +40,6 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.apache.commons.lang3.RandomStringUtils; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.Loop; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java index 63df3a7b0..84bf72b62 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java @@ -32,8 +32,6 @@ import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySuppo import org.onap.policy.clamp.loop.Loop; import org.onap.policy.clamp.loop.template.PolicyModelsRepository; import org.onap.policy.clamp.policy.PolicyService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -- cgit 1.2.3-korg