aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2022-03-21 12:38:52 +0000
committerAdheli Tavares <adheli.tavares@est.tech>2022-03-22 13:04:37 +0000
commit0a78930e107a44c3b4119a321c680692154f90f5 (patch)
treeb3cd4d3850d092001e5b3f179ff41bc2eb465ab3 /participant/participant-intermediary/src
parente5a316e5c8aeaae1ba4aead0a71b6baf2f8cc5c1 (diff)
Clean up unit tests
- use the unified test reference folder - fix some sonar lint issues Issue-ID: POLICY-3945 Change-Id: I33e30332d911f02c32937316bac6d2d331ac6346 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src')
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java37
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java12
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java6
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java12
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java9
7 files changed, 44 insertions, 52 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index 5d9675606..a8116c078 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.time.Instant;
import java.util.UUID;
@@ -43,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantIntermediaryApiImplTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java
index 26dddc9ba..f8db70cc9 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collections;
@@ -40,7 +40,7 @@ import org.onap.policy.common.utils.coder.CoderException;
class ParticipantCommTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void participantReqTest() throws CoderException {
@@ -73,32 +73,25 @@ class ParticipantCommTest {
var participantMessagePublisher = new ParticipantMessagePublisher();
var participantStatus = Mockito.mock(ParticipantStatus.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantStatus(participantStatus);
- });
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendHeartbeat(participantStatus);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantStatus(participantStatus));
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendHeartbeat(participantStatus));
var participantRegister = Mockito.mock(ParticipantRegister.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantRegister(participantRegister);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantRegister(participantRegister));
var participantDeregister = Mockito.mock(ParticipantDeregister.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantDeregister(participantDeregister);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantDeregister(participantDeregister));
var automationCompositionAck = Mockito.mock(AutomationCompositionAck.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck));
List<TopicSink> emptyList = Collections.emptyList();
- assertThrows(IllegalArgumentException.class, () -> {
- participantMessagePublisher.active(emptyList);
- });
+ assertThrows(IllegalArgumentException.class, () -> participantMessagePublisher.active(emptyList));
participantMessagePublisher.stop();
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
index 5585e5190..c8432f230 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import java.time.Instant;
@@ -51,7 +51,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
class AutomationCompositionHandlerTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void automationCompositionHandlerTest() {
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
index 9ecf59ba4..6f4730a9c 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ class IntermediaryActivatorTest {
assertTrue(activator.isAlive());
// repeat start - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertThatIllegalStateException().isThrownBy(activator::start);
assertTrue(activator.isAlive());
verify(publisherFirst, times(1)).active(anyList());
verify(publisherSecond, times(1)).active(anyList());
@@ -93,7 +93,7 @@ class IntermediaryActivatorTest {
assertFalse(activator.isAlive());
// repeat stop - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.stop());
+ assertThatIllegalStateException().isThrownBy(activator::stop);
assertFalse(activator.isAlive());
assertDoesNotThrow(() -> activator.handleContextRefreshEvent(mock(ContextRefreshedEvent.class)));
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
index 8e22784db..04742d8b3 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
import java.util.ArrayList;
@@ -47,7 +47,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantHandlerTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index ad54d402c..a5aa2f48a 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ package org.onap.policy.clamp.acm.participant.intermediary.main.parameters;
import java.io.File;
import java.time.Instant;
-import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -56,7 +55,7 @@ public class CommonTestData {
public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
private static final Object lockit = new Object();
@@ -141,7 +140,7 @@ public class CommonTestData {
final var topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
@@ -186,8 +185,7 @@ public class CommonTestData {
var automationCompositionHandler = getMockAutomationCompositionHandler();
var publisher = new ParticipantMessagePublisher();
publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler);
- return participantHandler;
+ return new ParticipantHandler(parameters, publisher, automationCompositionHandler);
}
/**
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
index cc2b110f3..2cbe15797 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +28,12 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
/**
- * Class to perform unit test of {@link ParticipantParameterGroup}.
+ * Class to perform unit test of
+ * {@link org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters}.
*/
class TestParticipantIntermediaryParameters {
- private CommonTestData commonTestData = new CommonTestData();
- private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+ private final CommonTestData commonTestData = new CommonTestData();
+ private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantIntermediaryParameterGroup() {