aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'models/src/test')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java54
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java45
-rw-r--r--models/src/test/resources/providers/TestAcElementStatistics.json24
-rw-r--r--models/src/test/resources/providers/TestParticipant.json3
-rw-r--r--models/src/test/resources/providers/TestParticipantStatistics.json32
7 files changed, 34 insertions, 136 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
index f50bf36bc..f6eb3e0ff 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,9 +59,8 @@ class ParticipantTest {
p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
p1.setDescription("Description");
- p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
p1.setName("Name");
- p1.setParticipantState(ParticipantState.ACTIVE);
+ p1.setParticipantState(ParticipantState.ON_LINE);
p1.setVersion("0.0.1");
assertThat(p1.toString()).contains("Participant(");
@@ -75,7 +74,6 @@ class ParticipantTest {
// @formatter:off
assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> p2.setHealthStatus(null)). isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class);
// @formatter:on
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
index 7bf439e3f..51331b4bb 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDef
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -59,8 +58,7 @@ class ParticipantStatusTest {
ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4");
orig.setParticipantType(type);
orig.setMessageId(UUID.randomUUID());
- orig.setState(ParticipantState.ACTIVE);
- orig.setHealthStatus(ParticipantHealthStatus.HEALTHY);
+ orig.setState(ParticipantState.ON_LINE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
var acInfo = getAutomationCompositionInfo(automationCompositionId);
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
index 3ff614918..9d1d7ff99 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -48,58 +47,52 @@ class JpaParticipantTest {
assertThatThrownBy(() -> new JpaParticipant((PfConceptKey) null)).hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, null, null, null)).hasMessageMatching(NULL_KEY_ERROR);
+ assertThatThrownBy(() -> new JpaParticipant(null, null, null)).hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, null, null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, null, null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, null, ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, null, ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(
- () -> new JpaParticipant(null, null, ParticipantState.ACTIVE, ParticipantHealthStatus.HEALTHY))
+ () -> new JpaParticipant(null, null, ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ACTIVE,
- ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), ParticipantState.ON_LINE))
.hasMessageMatching(NULL_KEY_ERROR);
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null))
.hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null, ParticipantHealthStatus.HEALTHY))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, null))
.hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ON_LINE))
.hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ACTIVE,
- ParticipantHealthStatus.HEALTHY)).hasMessageMatching("definition is marked .*ull but is null");
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), null, ParticipantState.ON_LINE
+ )).hasMessageMatching("definition is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null))
.hasMessageMatching("participantState is marked .*ull but is null");
assertThatThrownBy(
- () -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null, ParticipantHealthStatus.HEALTHY))
+ () -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), null))
.hasMessageMatching("participantState is marked .*ull but is null");
- assertThatThrownBy(
- () -> new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE, null))
- .hasMessageMatching("healthStatus is marked .*ull but is null");
-
assertNotNull(new JpaParticipant());
assertNotNull(new JpaParticipant((new PfConceptKey())));
- assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ACTIVE,
- ParticipantHealthStatus.HEALTHY));
+ assertNotNull(new JpaParticipant(new PfConceptKey(), new PfConceptKey(), ParticipantState.ON_LINE));
}
@Test
@@ -171,16 +164,10 @@ class JpaParticipantTest {
testJpaParticipant.setDefinition(new PfConceptKey("participantDefinitionName", "0.0.1"));
assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setParticipantState(ParticipantState.PASSIVE);
- assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setParticipantState(ParticipantState.UNKNOWN);
- assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
-
- testJpaParticipant.setHealthStatus(ParticipantHealthStatus.NOT_HEALTHY);
+ testJpaParticipant.setParticipantState(ParticipantState.OFF_LINE);
assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setHealthStatus(ParticipantHealthStatus.UNKNOWN);
+ testJpaParticipant.setParticipantState(ParticipantState.ON_LINE);
assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
-
assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant));
}
@@ -199,9 +186,8 @@ class JpaParticipantTest {
p1.setDefinition(new PfConceptKey("defName", "0.0.1"));
p1.setDescription("Description");
- p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
p1.setKey(new PfConceptKey("participant", "0.0.1"));
- p1.setParticipantState(ParticipantState.ACTIVE);
+ p1.setParticipantState(ParticipantState.ON_LINE);
assertThat(p1.toString()).contains("Participant(");
assertNotEquals(0, p1.hashCode());
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
index c7355f002..e11541988 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,13 +40,14 @@ import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantProviderTest {
private static final Coder CODER = new StandardCoder();
private static final String PARTICIPANT_JSON = "src/test/resources/providers/TestParticipant.json";
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+ private static final ToscaConceptIdentifier INVALID_ID = new ToscaConceptIdentifier("invalid_name", "1.0.1");
private final List<Participant> inputParticipants = new ArrayList<>();
private List<JpaParticipant> jpaParticipantList;
@@ -67,18 +68,12 @@ class ParticipantProviderTest {
}
var participantProvider = new ParticipantProvider(participantRepository);
- assertThatThrownBy(() -> participantProvider.saveParticipant(null))
- .hasMessageMatching(LIST_IS_NULL);
+ assertThatThrownBy(() -> participantProvider.saveParticipant(null)).hasMessageMatching(LIST_IS_NULL);
when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0));
Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0));
assertEquals(savedParticipant, inputParticipants.get(0));
-
- when(participantRepository.save(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> participantProvider.saveParticipant(inputParticipants.get(0)))
- .hasMessageMatching("Error in save Participant");
}
@Test
@@ -98,26 +93,10 @@ class ParticipantProviderTest {
assertThat(participantProvider.getParticipants("invalid_name", "1.0.1")).isEmpty();
- assertThat(participantProvider.findParticipant("invalid_name", "1.0.1")).isEmpty();
+ assertThat(participantProvider.findParticipant(INVALID_ID)).isEmpty();
when(participantRepository.findAll()).thenReturn(jpaParticipantList);
assertThat(participantProvider.getParticipants()).hasSize(inputParticipants.size());
-
- when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> participantProvider.findParticipant("notValid", "notValid"))
- .hasMessageMatching("Error in find Participant");
-
- assertThatThrownBy(() -> participantProvider.getFilteredParticipants(null))
- .hasMessageMatching("filter is marked .*ull but is null");
-
- when(participantRepository.getFiltered((JpaParticipant.class), (null), (null)))
- .thenReturn(jpaParticipantList);
-
- final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
- .type("org.onap.domain.pmsh.PMSHAutomationCompositionDefinition").build();
- assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
-
}
@Test
@@ -125,19 +104,13 @@ class ParticipantProviderTest {
var participantRepository = mock(ParticipantRepository.class);
var participantProvider = new ParticipantProvider(participantRepository);
- assertThatThrownBy(() -> participantProvider.deleteParticipant("Invalid_name", "1.0.1"))
- .hasMessageMatching(".*.failed, participant does not exist");
-
- String name = inputParticipants.get(0).getName();
- String version = inputParticipants.get(0).getVersion();
+ assertThatThrownBy(() -> participantProvider.deleteParticipant(INVALID_ID))
+ .hasMessageMatching(".*.failed, participant does not exist");
when(participantRepository.findById(any())).thenReturn(Optional.of(jpaParticipantList.get(0)));
- Participant deletedParticipant = participantProvider.deleteParticipant(name, version);
+ Participant deletedParticipant =
+ participantProvider.deleteParticipant(inputParticipants.get(0).getDefinition());
assertEquals(inputParticipants.get(0), deletedParticipant);
-
- when(participantRepository.findById(any())).thenThrow(IllegalArgumentException.class);
- assertThatThrownBy(() -> participantProvider.deleteParticipant(name, version))
- .hasMessageMatching("Error in delete Participant");
}
}
diff --git a/models/src/test/resources/providers/TestAcElementStatistics.json b/models/src/test/resources/providers/TestAcElementStatistics.json
deleted file mode 100644
index cceb91d14..000000000
--- a/models/src/test/resources/providers/TestAcElementStatistics.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "acElementStatistics":[
- {
- "participantId":{
- "name":"name1",
- "version":"1.001"
- },
- "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
- "timeStamp": "2021-01-10T13:45:00.000Z",
- "state": "UNINITIALISED",
- "acElementUptime":250
- },
- {
- "participantId":{
- "name":"name2",
- "version":"1.001"
- },
- "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
- "timeStamp": "2021-01-10T14:25:00.000Z",
- "state": "UNINITIALISED",
- "acElementUptime":330
- }
- ]
-}
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
index 7e4f9540f..5d8a7ea09 100644
--- a/models/src/test/resources/providers/TestParticipant.json
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -5,8 +5,7 @@
"name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition",
"version": "1.0.0"
},
- "participantState": "PASSIVE",
- "healthStatus": "HEALTHY",
+ "participantState": "ON_LINE",
"description": "A dummy PMSH participant1",
"participantType":{
"name": "org.onap.domain.pmsh.PolicyAutomationCompositionDefinition",
diff --git a/models/src/test/resources/providers/TestParticipantStatistics.json b/models/src/test/resources/providers/TestParticipantStatistics.json
deleted file mode 100644
index 5cf626816..000000000
--- a/models/src/test/resources/providers/TestParticipantStatistics.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "statisticsList":[
- {
- "participantId":{
- "name":"name1",
- "version":"1.001"
- },
- "timeStamp": "2021-01-10T13:45:00.000Z",
- "state": "PASSIVE",
- "healthStatus": "HEALTHY",
- "eventCount":250,
- "lastExecutionTime":100,
- "averageExecutionTime":90,
- "upTime":1000,
- "lastStart":3000
- },
- {
- "participantId":{
- "name":"name2",
- "version":"1.001"
- },
- "timeStamp": "2021-01-27T14:25:00.000Z",
- "state": "PASSIVE",
- "healthStatus": "HEALTHY",
- "eventCount":245,
- "lastExecutionTime":1020,
- "averageExecutionTime":85,
- "upTime":1050,
- "lastStart":3100
- }
- ]
-}