diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-07-24 09:56:46 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-07-24 09:06:26 +0000 |
commit | a2f6493f89eff78a78d8ba2aa34f6080d6ab8830 (patch) | |
tree | 62acfbf410ce9986d9d3b2d7d3115fd073bf1d5b /models/src/test/java | |
parent | b2bc0f63a484abe5b77b1e921d820ae80481602b (diff) |
Fix sonar issue for ACM
Issue-ID: POLICY-5065
Change-Id: Id95e8dbd4be14db36eb2fa4ddfc852d37572f25a
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/test/java')
2 files changed, 16 insertions, 17 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantAckMessageTest.java index 72e4efb49..2535c375a 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantAckMessageTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantAckMessageTest.java @@ -32,7 +32,6 @@ import org.onap.policy.clamp.models.acm.utils.CommonTestData; import org.onap.policy.common.utils.coder.CoderException; class ParticipantAckMessageTest { - private ParticipantAckMessage message; @Test void testCopyConstructor() throws CoderException { @@ -40,8 +39,8 @@ class ParticipantAckMessageTest { .isInstanceOf(NullPointerException.class); // verify with null values - message = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); - ParticipantAckMessage newmsg = new ParticipantAckMessage(message); + var message = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + var newmsg = new ParticipantAckMessage(message); newmsg.setResponseTo(message.getResponseTo()); assertEquals(message.toString(), newmsg.toString()); @@ -56,14 +55,15 @@ class ParticipantAckMessageTest { @Test void testAppliesTo_NullParticipantId() { - message = makeMessage(); - assertThatThrownBy(() -> message.appliesTo(UUID.randomUUID(), null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(null, UUID.randomUUID())).isInstanceOf(NullPointerException.class); + var message = makeMessage(); + var participantId = CommonTestData.getRndParticipantId(); + assertThatThrownBy(() -> message.appliesTo(participantId, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class); } @Test void testAppliesTo_ParticipantIdMatches() { - message = makeMessage(); + var message = makeMessage(); // ParticipantId matches assertTrue(message.appliesTo(CommonTestData.getParticipantId(), CommonTestData.getReplicaId())); @@ -72,7 +72,7 @@ class ParticipantAckMessageTest { @Test void testAppliesTo_ParticipantIdNoMatch() { - message = makeMessage(); + var message = makeMessage(); // ParticipantId does not match assertFalse(message.appliesTo(CommonTestData.getRndParticipantId(), CommonTestData.getReplicaId())); @@ -80,7 +80,7 @@ class ParticipantAckMessageTest { } private ParticipantAckMessage makeMessage() { - ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + var msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); msg.setParticipantId(CommonTestData.getParticipantId()); msg.setMessage("Successfull Ack"); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageTest.java index db31d0f01..c6386a571 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageTest.java @@ -33,7 +33,6 @@ import org.onap.policy.clamp.models.acm.utils.CommonTestData; import org.onap.policy.common.utils.coder.CoderException; class ParticipantMessageTest { - private ParticipantMessage message; @Test void testCopyConstructor() throws CoderException { @@ -41,7 +40,7 @@ class ParticipantMessageTest { .isInstanceOf(NullPointerException.class); // verify with null values - message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + var message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); var newmsg = new ParticipantMessage(message); newmsg.setMessageId(message.getMessageId()); newmsg.setTimestamp(message.getTimestamp()); @@ -59,15 +58,15 @@ class ParticipantMessageTest { @Test void testAppliesTo_NullParticipantId() { - message = makeMessage(); - - assertThatThrownBy(() -> message.appliesTo(UUID.randomUUID(), null)).isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> message.appliesTo(null, UUID.randomUUID())).isInstanceOf(NullPointerException.class); + var message = makeMessage(); + var participantId = CommonTestData.getParticipantId(); + assertThatThrownBy(() -> message.appliesTo(participantId, null)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class); } @Test void testAppliesTo_ParticipantIdMatches() { - message = makeMessage(); + var message = makeMessage(); // ParticipantId matches assertTrue(message.appliesTo(CommonTestData.getParticipantId(), CommonTestData.getReplicaId())); @@ -76,7 +75,7 @@ class ParticipantMessageTest { @Test void testAppliesTo_ParticipantIdNoMatch() { - message = makeMessage(); + var message = makeMessage(); assertFalse(message.appliesTo(CommonTestData.getRndParticipantId(), CommonTestData.getReplicaId())); assertTrue(message.appliesTo(CommonTestData.getParticipantId(), CommonTestData.getReplicaId())); } |