aboutsummaryrefslogtreecommitdiffstats
path: root/models
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 /models
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 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java12
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java10
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java6
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java31
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java14
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java15
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java5
10 files changed, 44 insertions, 59 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
index cac405abd..2a2cde2ae 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
@@ -76,11 +75,8 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
// @formatter:off
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
// @formatter:on
@@ -158,7 +154,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
@Override
public ControlLoop toAuthorative() {
- ControlLoop controlLoop = new ControlLoop();
+ var controlLoop = new ControlLoop();
controlLoop.setName(getKey().getName());
controlLoop.setVersion(getKey().getVersion());
@@ -184,7 +180,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
this.elements = new LinkedHashMap<>(controlLoop.getElements().size());
for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) {
- JpaControlLoopElement jpaControlLoopElement = new JpaControlLoopElement();
+ var jpaControlLoopElement = new JpaControlLoopElement();
jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString()));
jpaControlLoopElement.fromAuthorative(elementEntry.getValue());
this.elements.put(elementEntry.getKey(), jpaControlLoopElement);
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
index 69b565266..4d49683bf 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept
import java.io.Serializable;
import java.util.List;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@@ -66,11 +65,8 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
// @formatter:off
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
// @formatter:on
@@ -142,7 +138,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
@Override
public Participant toAuthorative() {
- Participant participant = new Participant();
+ var participant = new Participant();
participant.setName(key.getName());
participant.setVersion(key.getVersion());
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
index 00eab8f69..f8f1f4145 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
@@ -121,10 +121,12 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* Get filtered clElement statistics.
*
* @param name the clElement name for the statistics to get
+ * @param version the clElement version for the statistics to get
* @param startTimeStamp startTimeStamp to filter statistics
* @param endTimeStamp endTimeStamp to filter statistics
* @param sortOrder sortOrder to query database
* @param getRecordNum Total query count from database
+ * @param filterMap the filters to apply to the get operation
* @return the clElement statistics found
* @throws PfModelException on errors getting policies
*/
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
index 5317bb31d..7c34a6654 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
@@ -162,13 +162,13 @@ public class ControlLoopProvider extends AbstractModelsProvider {
* @param name the name of the control loop to delete
* @param version the version of the control loop to delete
* @return the control loop deleted
- * @throws PfModelException on errors deleting the control loop
+ * @throws PfModelRuntimeException on errors deleting the control loop
*/
public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) {
var controlLoopKey = new PfConceptKey(name, version);
- JpaControlLoop jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey);
+ var jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey);
if (jpaDeleteControlLoop == null) {
String errorMessage =
@@ -210,6 +210,8 @@ public class ControlLoopProvider extends AbstractModelsProvider {
/**
* Convert JPA control loop list to an authorative control loop list.
*
+ * @param <T> the type of TOSCA entity
+ * @param <J> the type of JPA TOSCA entity
* @param jpaEntityList the list to convert
* @return the authorative list
*/
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
index c569cadd8..2ccc5d3c1 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
@@ -133,7 +133,7 @@ public class ParticipantProvider extends AbstractModelsProvider {
* @param name the name of the participant to delete
* @param version the version of the participant to get
* @return the participant deleted
- * @throws PfModelException on errors deleting participants
+ * @throws PfModelRuntimeException on errors deleting participants
*/
public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) {
@@ -155,7 +155,7 @@ public class ParticipantProvider extends AbstractModelsProvider {
/**
* Convert JPA participant list to an authorative participant list.
*
- * @param foundParticipants the list to convert
+ * @param jpaParticipantList the list to convert
* @return the authorative list
*/
private List<Participant> asParticipantList(List<JpaParticipant> jpaParticipantList) {
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
index 137af3a5e..a7216ed7f 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -54,6 +54,8 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* Get Participant statistics.
*
* @param name the name of the participant statistics to get, null to get all stats
+ * @param version the version of the participant statistics to get, null to get all stats for a name
+ * @param timestamp the time stamp for the stats to get
* @return the participant statistics found
* @throws PfModelException on errors getting participant statistics
*/
@@ -77,10 +79,12 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* Get filtered participant statistics.
*
* @param name the participant name for the statistics to get
+ * @param version the participant version for the statistics to get
* @param startTimeStamp startTimeStamp to filter statistics
* @param endTimeStamp endTimeStamp to filter statistics
* @param sortOrder sortOrder to query database
* @param getRecordNum Total query count from database
+ * @param filterMap the filters to apply to the get operation
* @return the participant statistics found
* @throws PfModelException on errors getting policies
*/
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
index f5d094f9e..eb6a02898 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
@@ -41,8 +41,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class ClElementStatisticsProviderTest {
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
private static final Coder CODER = new StandardCoder();
- private static final String CL_ELEMENT_STATS_JSON =
- "src/test/resources/providers/TestClElementStatistics.json";
+ private static final String CL_ELEMENT_STATS_JSON = "src/test/resources/providers/TestClElementStatistics.json";
private static AtomicInteger dbNameCounter = new AtomicInteger();
@@ -53,9 +52,11 @@ public class ClElementStatisticsProviderTest {
/**
* Set up test ClElement statistics provider.
+ *
+ * @throws Exception on errors
*/
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -82,8 +83,8 @@ public class ClElementStatisticsProviderTest {
}).hasMessageMatching(LIST_IS_NULL);
ClElementStatisticsList createdClElementStats = new ClElementStatisticsList();
- createdClElementStats.setClElementStatistics(clElementStatisticsProvider
- .createClElementStatistics(inputClElementStats.getClElementStatistics()));
+ createdClElementStats.setClElementStatistics(
+ clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics()));
assertEquals(inputClElementStats.toString().replaceAll("\\s+", ""),
createdClElementStats.toString().replaceAll("\\s+", ""));
@@ -94,22 +95,18 @@ public class ClElementStatisticsProviderTest {
List<ClElementStatistics> getResponse;
- //Return empty list when no data present in db
- getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null,
- null);
+ // Return empty list when no data present in db
+ getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null, null);
assertThat(getResponse).isEmpty();
- clElementStatisticsProvider.createClElementStatistics(inputClElementStats
- .getClElementStatistics());
- ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0)
- .getParticipantId();
+ clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics());
+ ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0).getParticipantId();
Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
String id = inputClElementStats.getClElementStatistics().get(0).getId().toString();
- assertEquals(1, clElementStatisticsProvider.getClElementStatistics(identifier.getName(),
- identifier.getVersion(), id, instant).size());
+ assertEquals(1, clElementStatisticsProvider
+ .getClElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size());
- assertEquals(1, clElementStatisticsProvider.getFilteredClElementStatistics("name2",
- "1.0.1", null, null, null,
- "DESC", 1).size());
+ assertEquals(1, clElementStatisticsProvider
+ .getFilteredClElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
index 96b63a23d..d362c2718 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
@@ -56,11 +56,8 @@ public class ControlLoopProviderTest {
private String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON);
private String updateClJson = ResourceUtils.getResourceAsString(UPDATE_CL_JSON);
- /**
- * Set up test control loop provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -90,7 +87,7 @@ public class ControlLoopProviderTest {
ControlLoops createdControlLoops = new ControlLoops();
createdControlLoops
- .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
assertEquals(inputControlLoops, createdControlLoops);
}
@@ -120,11 +117,10 @@ public class ControlLoopProviderTest {
}).hasMessageMatching("filter is marked .*ull but is null");
final ToscaTypedEntityFilter<ControlLoop> filter = ToscaTypedEntityFilter.<ControlLoop>builder()
- .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
assertEquals(2, controlLoopProvider.getFilteredControlLoops(filter).size());
}
-
@Test
public void testUpdateControlLoops() throws Exception {
assertThatThrownBy(() -> {
@@ -133,7 +129,7 @@ public class ControlLoopProviderTest {
ControlLoops existingControlLoops = new ControlLoops();
existingControlLoops
- .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
ControlLoop updateResponse = new ControlLoop();
updateResponse = controlLoopProvider.updateControlLoop(updateControlLoops.getControlLoopList().get(0));
@@ -156,5 +152,3 @@ public class ControlLoopProviderTest {
}
}
-
-
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
index 7a86a49dc..41c106577 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
@@ -42,7 +42,7 @@ public class ParticipantProviderTest {
private static final Coder CODER = new StandardCoder();
private static final String PARTICIPANT_JSON =
- "src/test/resources/providers/TestParticipant.json";
+ "src/test/resources/providers/TestParticipant.json";
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
private static AtomicInteger dbNameCounter = new AtomicInteger();
@@ -53,11 +53,8 @@ public class ParticipantProviderTest {
private Participant updateParticipants;
private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON);
- /**
- * Set up test Participant provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -86,10 +83,10 @@ public class ParticipantProviderTest {
List<Participant> createdParticipants = new ArrayList<>();
createdParticipants.addAll(participantProvider
- .createParticipants(inputParticipants));
+ .createParticipants(inputParticipants));
assertEquals(createdParticipants.get(0),
- inputParticipants.get(0));
+ inputParticipants.get(0));
}
@@ -108,14 +105,14 @@ public class ParticipantProviderTest {
assertEquals(1, participantProvider.getParticipants(name, version).size());
assertThat(participantProvider.getParticipants("invalid_name",
- "1.0.1")).isEmpty();
+ "1.0.1")).isEmpty();
assertThatThrownBy(() -> {
participantProvider.getFilteredParticipants(null);
}).hasMessageMatching("filter is marked .*ull but is null");
final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
- .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
index d4bc9777a..0fd3693c0 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
@@ -51,11 +51,8 @@ public class ParticipantStatisticsProviderTest {
private ParticipantStatisticsList inputParticipantStatistics;
private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON);
- /**
- * Set up test Participant statistics provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");