aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test/java
diff options
context:
space:
mode:
authorRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2024-06-04 08:57:28 +0000
committerGerrit Code Review <gerrit@onap.org>2024-06-04 08:57:28 +0000
commit74101c625cfaa5592c9219782f5919c02bd4bbb7 (patch)
treeddd36193848f4d748248ec836fe0c03ee8145f72 /runtime-acm/src/test/java
parent66cfd4c9006b84ce1f3751da3b9dae2b4fff78e8 (diff)
parentf2ed4877b7cfba7bcf224cbe9d7e739ec637a055 (diff)
Merge "Remove Map in ACM-R for timeout Participant"
Diffstat (limited to 'runtime-acm/src/test/java')
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java15
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java11
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java17
3 files changed, 8 insertions, 35 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
index 35dedb7ca..f78344bcb 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
@@ -26,8 +26,6 @@ import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
-import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantStatus;
class SupervisionAspectTest {
@@ -52,17 +50,4 @@ class SupervisionAspectTest {
verify(supervisionScanner, timeout(500).times(2)).run();
}
}
-
- @Test
- void testHandleParticipantStatus() throws Exception {
- var participantStatusMessage = new ParticipantStatus();
- participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
-
- var supervisionScanner = mock(SupervisionScanner.class);
- var partecipantScanner = mock(SupervisionPartecipantScanner.class);
- try (var supervisionAspect = new SupervisionAspect(supervisionScanner, partecipantScanner)) {
- supervisionAspect.handleParticipantStatus(participantStatusMessage);
- verify(partecipantScanner, timeout(500)).handleParticipantStatus(CommonTestData.getParticipantId());
- }
- }
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
index 4bab85bf5..3c9f91785 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,26 +31,25 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.models.base.PfModelException;
class SupervisionParticipantScannerTest {
@Test
- void testScanParticipant() throws PfModelException {
+ void testScanParticipant() {
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanParticipant");
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
- participant.setParticipantState(ParticipantState.OFF_LINE);
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
var supervisionScanner = new SupervisionPartecipantScanner(participantProvider, acRuntimeParameterGroup);
- supervisionScanner.handleParticipantStatus(participant.getParticipantId());
+ participant.setParticipantState(ParticipantState.OFF_LINE);
supervisionScanner.run();
- verify(participantProvider, times(0)).saveParticipant(any());
+ verify(participantProvider, times(0)).updateParticipant(any());
+ participant.setParticipantState(ParticipantState.ON_LINE);
supervisionScanner.run();
verify(participantProvider, times(1)).updateParticipant(any());
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
index 8329d050b..431a1ba55 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation.
+ * Copyright (C) 2021-2024 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,7 +21,6 @@
package org.onap.policy.clamp.acm.runtime.util;
import jakarta.ws.rs.core.Response.Status;
-import java.util.List;
import java.util.UUID;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters;
@@ -32,6 +31,7 @@ import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
+import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -80,18 +80,6 @@ public class CommonTestData {
}
/**
- * Create a List of Participants.
- *
- * @return a List of Participants
- */
- public static List<Participant> createParticipants() {
- var participant1 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02"));
- var participant2 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c01"));
- var participant3 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03"));
- return List.of(participant1, participant2, participant3);
- }
-
- /**
* Create a new Participant.
*
* @param participantId the participant id
@@ -101,6 +89,7 @@ public class CommonTestData {
var participant = new Participant();
participant.setParticipantId(participantId);
participant.setParticipantState(ParticipantState.ON_LINE);
+ participant.setLastMsg(TimestampHelper.now());
return participant;
}