aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java/org
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-10-28 10:10:33 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2022-11-01 08:17:40 +0000
commitcbf36339b5740bfe2dc3f23a26d31d5d5c56eedb (patch)
treedcc7bb4c3052788588c5b03bb6b4afa784b370a7 /models/src/test/java/org
parentc4a0dae11f166b79969fa2813ce6aba72dbd1560 (diff)
Remove old implementation of statistics in ACM models
The old implementation of statistics in ACM can be removed due the Prometheus metrics support. Issue-ID: POLICY-4422 Change-Id: Ia2681b9a3ca59d532cd5c0d1ce4edd3e8f9f98e3 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/test/java/org')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java66
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java46
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java65
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java20
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java28
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java190
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java192
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java115
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java107
10 files changed, 0 insertions, 857 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java
deleted file mode 100644
index 070fa8dc8..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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 java.time.Instant;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class AcElementStatisticsTest {
- @Test
- void testAcElementStatisticsLombok() {
- assertNotNull(new AcElementStatistics());
- AcElementStatistics aces0 = new AcElementStatistics();
-
- assertThat(aces0.toString()).contains("AcElementStatistics(");
- assertThat(aces0.hashCode()).isNotZero();
- assertEquals(aces0, aces0);
- assertNotEquals(null, aces0);
-
- AcElementStatistics aces1 = new AcElementStatistics();
- aces1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- aces1.setTimeStamp(Instant.now());
-
- assertThat(aces1.toString()).contains("AcElementStatistics(");
- assertNotEquals(0, aces1.hashCode());
- assertNotEquals(aces1, aces0);
- assertNotEquals(null, aces1);
-
- assertNotEquals(aces1, aces0);
-
- AcElementStatistics aces2 = new AcElementStatistics();
- aces2.setId(UUID.randomUUID());
-
- // @formatter:off
- assertThatThrownBy(() -> aces2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> aces2.setTimeStamp(null)).isInstanceOf(NullPointerException.class);
- // @formatter:on
-
- assertNotEquals(aces2, aces0);
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java
index 49953f1af..aaa8368d7 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java
@@ -27,9 +27,7 @@ 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 java.time.Instant;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.models.base.PfKey;
@@ -104,43 +102,6 @@ class AutomationCompositionTest {
}
- @Test
- void testAutomationCompositionElementStatisticsList() {
- var ac = new AutomationComposition();
- List<AcElementStatistics> emptylist = ac.getAutomationCompositionElementStatisticsList(ac);
- assertEquals(List.of(), emptylist);
-
- var ac1 = getAutomationCompositionTest();
- List<AcElementStatistics> list = ac1.getAutomationCompositionElementStatisticsList(ac1);
- assertNotNull(list);
- assertEquals(2, list.size());
- assertEquals(AutomationCompositionState.UNINITIALISED, list.get(0).getState());
- }
-
- private AutomationComposition getAutomationCompositionTest() {
- var ac = new AutomationComposition();
- ac.setDefinition(new ToscaConceptIdentifier("defName", "1.2.3"));
- ac.setDescription("Description");
- ac.setElements(new LinkedHashMap<>());
- ac.setName("Name");
- ac.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- ac.setState(AutomationCompositionState.UNINITIALISED);
- ac.setVersion("0.0.1");
-
- var uuid = UUID.randomUUID();
- var id = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1");
- var acElement = getAutomationCompositionElementTest(uuid, id);
-
- var uuid2 = UUID.randomUUID();
- var id2 = new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipantIntermediary",
- "0.0.1");
- var acElement2 = getAutomationCompositionElementTest(uuid2, id2);
-
- ac.getElements().put(uuid, acElement);
- ac.getElements().put(uuid2, acElement2);
- return ac;
- }
-
private AutomationCompositionElement getAutomationCompositionElementTest(UUID uuid, ToscaConceptIdentifier id) {
var acElement = new AutomationCompositionElement();
acElement.setId(uuid);
@@ -148,13 +109,6 @@ class AutomationCompositionTest {
acElement.setDefinition(id);
acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- var acElementStatistics = new AcElementStatistics();
- acElementStatistics.setParticipantId(id);
- acElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
- acElementStatistics.setTimeStamp(Instant.now());
-
- acElement.setAcElementStatistics(acElementStatistics);
-
return acElement;
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java
deleted file mode 100644
index 727ab7033..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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 java.time.Instant;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ParticipantStatisticsTest {
- @Test
- void testParticipantStatisticsLombok() {
- assertNotNull(new ParticipantStatistics());
- ParticipantStatistics ps0 = new ParticipantStatistics();
-
- assertThat(ps0.toString()).contains("ParticipantStatistics(");
- assertThat(ps0.hashCode()).isNotZero();
- assertEquals(ps0, ps0);
- assertNotEquals(null, ps0);
-
-
- ParticipantStatistics ps1 = new ParticipantStatistics();
- ps1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- ps1.setTimeStamp(Instant.now());
-
- assertThat(ps1.toString()).contains("ParticipantStatistics(");
- assertNotEquals(0, ps1.hashCode());
- assertNotEquals(ps1, ps0);
- assertNotEquals(null, ps1);
-
- assertNotEquals(ps1, ps0);
-
- ParticipantStatistics ps2 = new ParticipantStatistics();
-
- // @formatter:off
- assertThatThrownBy(() -> ps2.setParticipantId(null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> ps2.setTimeStamp(null)). isInstanceOf(NullPointerException.class);
- // @formatter:on
-
- assertEquals(ps2, ps0);
- }
-}
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 37cde2549..eeb8ba3dd 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
@@ -30,12 +30,9 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
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.AutomationCompositionStatistics;
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;
@@ -88,23 +85,6 @@ class ParticipantStatusTest {
acInfo.setState(AutomationCompositionState.PASSIVE2RUNNING);
acInfo.setAutomationCompositionId(id);
- AutomationCompositionStatistics acStatistics = new AutomationCompositionStatistics();
- acStatistics.setAutomationCompositionId(id);
- acStatistics.setAverageExecutionTime(12345);
- acStatistics.setEventCount(12345);
- acStatistics.setLastEnterTime(12345);
- acStatistics.setLastExecutionTime(12345);
- acStatistics.setLastStart(12345);
- acStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
- acStatistics.setUpTime(12345);
- AcElementStatisticsList acElementStatisticsList = new AcElementStatisticsList();
- AcElementStatistics acElementStatistics = new AcElementStatistics();
- acElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- acElementStatistics.setTimeStamp(Instant.now());
- acElementStatisticsList.setAcElementStatistics(List.of(acElementStatistics));
- acStatistics.setAcElementStatisticsList(acElementStatisticsList);
-
- acInfo.setAutomationCompositionStatistics(acStatistics);
return acInfo;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java
deleted file mode 100644
index ebbaf1d42..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaAcElementStatisticsChild.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.concepts;
-
-/**
- * Test class for {@link JpaAcElementStatistics} comparisons.
- */
-class DummyJpaAcElementStatisticsChild extends JpaAcElementStatistics {
- private static final long serialVersionUID = -5101743610779424064L;
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java
deleted file mode 100644
index 95082cac7..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/DummyJpaParticipantStatisticsChild.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.concepts;
-
-/**
- * Test class for {@link JpaParticipantStatistics} comparisons.
- */
-class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics {
- private static final long serialVersionUID = -5101743610779424064L;
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java
deleted file mode 100644
index d00d98ae0..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatisticsTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.time.Instant;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfReferenceTimestampKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Test the {@link JpaAcElementStatistics} class.
- */
-class JpaAcElementStatisticsTest {
-
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
-
- @Test
- void testJpaAcElementStatisticsConstructor() {
- assertThatThrownBy(() -> {
- new JpaAcElementStatistics((JpaAcElementStatistics) null);
- }).hasMessageMatching("copyConcept is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaAcElementStatistics((PfReferenceTimestampKey) null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAcElementStatistics(null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAcElementStatistics(null, new PfConceptKey());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAcElementStatistics(new PfReferenceTimestampKey(), null);
- }).hasMessageMatching("participantId is marked .*ull but is null");
-
- assertNotNull(new JpaAcElementStatistics());
- assertNotNull(new JpaAcElementStatistics((new PfReferenceTimestampKey())));
- assertNotNull(new JpaAcElementStatistics(new PfReferenceTimestampKey(), new PfConceptKey()));
- }
-
- @Test
- void testJpaAcElementStatistics() {
- JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
-
- AcElementStatistics aces = createAcElementStatisticsInstance();
- assertEquals(aces, testJpaAcElementStatistics.toAuthorative());
-
- assertThatThrownBy(() -> {
- testJpaAcElementStatistics.fromAuthorative(null);
- }).hasMessageMatching("acElementStatistics is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaAcElementStatistics((JpaAcElementStatistics) null))
- .isInstanceOf(NullPointerException.class);
-
- JpaAcElementStatistics testJpaAcElementStatisticsFa = new JpaAcElementStatistics();
- testJpaAcElementStatisticsFa.setKey(null);
- testJpaAcElementStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
- testJpaAcElementStatisticsFa.setKey(PfReferenceTimestampKey.getNullKey());
- testJpaAcElementStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
- testJpaAcElementStatisticsFa.setKey(new PfReferenceTimestampKey("elementName", "0.0.1",
- "a95757ba-b34a-4049-a2a8-46773abcbe5e", Instant.ofEpochSecond(123456L)));
- testJpaAcElementStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
-
- testJpaAcElementStatisticsFa = new JpaAcElementStatistics(aces);
- assertEquals(testJpaAcElementStatistics, testJpaAcElementStatisticsFa);
-
- assertEquals(1, testJpaAcElementStatistics.getKeys().size());
-
- assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName());
-
- testJpaAcElementStatistics.clean();
- assertEquals("elementName", testJpaAcElementStatistics.getKey().getReferenceKey().getParentKeyName());
-
- JpaAcElementStatistics testJpaAcElementStatistics2 = new JpaAcElementStatistics(testJpaAcElementStatistics);
- assertEquals(testJpaAcElementStatistics, testJpaAcElementStatistics2);
- }
-
- @Test
- void testJpaAcElementStatisticsValidation() {
- JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
-
- assertThatThrownBy(() -> {
- testJpaAcElementStatistics.validate(null);
- }).hasMessageMatching("fieldName is marked .*ull but is null");
-
- assertTrue(testJpaAcElementStatistics.validate("").isValid());
- }
-
- @Test
- void testJpaAcElementStatisticsCompareTo() {
- JpaAcElementStatistics testJpaAcElementStatistics = createJpaAcElementStatisticsInstance();
-
- JpaAcElementStatistics otherJpaAcElementStatistics = new JpaAcElementStatistics(testJpaAcElementStatistics);
- assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
- assertEquals(-1, testJpaAcElementStatistics.compareTo(null));
- assertEquals(0, testJpaAcElementStatistics.compareTo(testJpaAcElementStatistics));
- assertNotEquals(0, testJpaAcElementStatistics.compareTo(new DummyJpaAcElementStatisticsChild()));
-
- testJpaAcElementStatistics.setState(AutomationCompositionState.PASSIVE);
- assertNotEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
- testJpaAcElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
- assertEquals(0, testJpaAcElementStatistics.compareTo(otherJpaAcElementStatistics));
-
- assertEquals(testJpaAcElementStatistics, new JpaAcElementStatistics(testJpaAcElementStatistics));
- }
-
- @Test
- void testJpaAcElementStatisticsLombok() {
- assertNotNull(new Participant());
- JpaAcElementStatistics aces0 = new JpaAcElementStatistics();
-
- assertThat(aces0.toString()).contains("JpaAcElementStatistics(");
- assertThat(aces0.hashCode()).isNotZero();
- assertEquals(aces0, aces0);
- assertNotEquals(null, aces0);
-
-
- JpaAcElementStatistics aces11 = new JpaAcElementStatistics();
-
- aces11.setState(AutomationCompositionState.UNINITIALISED);
-
- assertThat(aces11.toString()).contains("JpaAcElementStatistics(");
- assertNotEquals(0, aces11.hashCode());
- assertNotEquals(aces11, aces0);
- assertNotEquals(null, aces11);
-
- assertNotEquals(aces11, aces0);
-
- JpaAcElementStatistics aces2 = new JpaAcElementStatistics();
- assertEquals(aces2, aces0);
- }
-
- private JpaAcElementStatistics createJpaAcElementStatisticsInstance() {
- AcElementStatistics testAces = createAcElementStatisticsInstance();
- JpaAcElementStatistics testJpaAcElementStatistics = new JpaAcElementStatistics();
- testJpaAcElementStatistics.setKey(null);
- testJpaAcElementStatistics.fromAuthorative(testAces);
- testJpaAcElementStatistics.setKey(PfReferenceTimestampKey.getNullKey());
- testJpaAcElementStatistics.fromAuthorative(testAces);
-
- return testJpaAcElementStatistics;
- }
-
- private AcElementStatistics createAcElementStatisticsInstance() {
- AcElementStatistics acElementStatistics = new AcElementStatistics();
- acElementStatistics.setParticipantId(new ToscaConceptIdentifier("elementName", "0.0.1"));
- acElementStatistics.setId(UUID.fromString("a95757ba-b34a-4049-a2a8-46773abcbe5e"));
- acElementStatistics.setTimeStamp(Instant.ofEpochSecond(123456L));
- acElementStatistics.setState(AutomationCompositionState.UNINITIALISED);
-
- return acElementStatistics;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java
deleted file mode 100644
index 921f9b2b0..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatisticsTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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.assertTrue;
-
-import java.time.Instant;
-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.clamp.models.acm.concepts.ParticipantStatistics;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfTimestampKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Test the {@link JpaParticipantStatistics} class.
- */
-class JpaParticipantStatisticsTest {
-
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
-
- @Test
- void testJpaParticipantStatisticsConstructor() {
- assertThatThrownBy(() -> {
- new JpaParticipantStatistics((JpaParticipantStatistics) null);
- }).hasMessageMatching("copyConcept is marked .*ull but is null");
-
- assertThatThrownBy(() -> {
- new JpaParticipantStatistics((PfTimestampKey) null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaParticipantStatistics(null, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaParticipantStatistics(null, new PfConceptKey());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaParticipantStatistics(new PfTimestampKey(), null);
- }).hasMessageMatching("participantId is marked .*ull but is null");
-
- assertNotNull(new JpaParticipantStatistics());
- assertNotNull(new JpaParticipantStatistics((new PfTimestampKey())));
- assertNotNull(new JpaParticipantStatistics(new PfTimestampKey(), new PfConceptKey()));
- }
-
- @Test
- void testJpaParticipantStatistics() {
- JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
-
- ParticipantStatistics aces = createParticipantStatisticsInstance();
- assertEquals(aces, testJpaParticipantStatistics.toAuthorative());
-
- assertThatThrownBy(() -> {
- testJpaParticipantStatistics.fromAuthorative(null);
- }).hasMessageMatching("participantStatistics is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaParticipantStatistics((JpaParticipantStatistics) null))
- .isInstanceOf(NullPointerException.class);
-
- JpaParticipantStatistics testJpaParticipantStatisticsFa = new JpaParticipantStatistics();
- testJpaParticipantStatisticsFa.setKey(null);
- testJpaParticipantStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
- testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey());
- testJpaParticipantStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
- testJpaParticipantStatisticsFa
- .setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L)));
- testJpaParticipantStatisticsFa.fromAuthorative(aces);
- assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
-
- testJpaParticipantStatisticsFa = new JpaParticipantStatistics(aces);
- assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
-
- assertEquals(2, testJpaParticipantStatistics.getKeys().size());
-
- assertEquals("participantName", testJpaParticipantStatistics.getKey().getName());
-
- testJpaParticipantStatistics.clean();
- assertEquals("participantName", testJpaParticipantStatistics.getKey().getName());
-
- JpaParticipantStatistics testJpaParticipantStatistics2 =
- new JpaParticipantStatistics(testJpaParticipantStatistics);
- assertEquals(testJpaParticipantStatistics, testJpaParticipantStatistics2);
- }
-
- @Test
- void testJpaParticipantStatisticsValidation() {
- JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
-
- assertThatThrownBy(() -> {
- testJpaParticipantStatistics.validate(null);
- }).hasMessageMatching("fieldName is marked .*ull but is null");
-
- BeanValidationResult validationResult = testJpaParticipantStatistics.validate("");
- assertTrue(validationResult.isValid());
- }
-
- @Test
- void testJpaParticipantStatisticsConmpareTo() {
- JpaParticipantStatistics testJpaParticipantStatistics = createJpaParticipantStatisticsInstance();
-
- JpaParticipantStatistics otherJpaParticipantStatistics =
- new JpaParticipantStatistics(testJpaParticipantStatistics);
- assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
- assertEquals(-1, testJpaParticipantStatistics.compareTo(null));
- assertEquals(0, testJpaParticipantStatistics.compareTo(testJpaParticipantStatistics));
- assertNotEquals(0, testJpaParticipantStatistics.compareTo(new DummyJpaParticipantStatisticsChild()));
-
- testJpaParticipantStatistics.setState(ParticipantState.UNKNOWN);
- assertNotEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
- testJpaParticipantStatistics.setState(ParticipantState.PASSIVE);
- assertEquals(0, testJpaParticipantStatistics.compareTo(otherJpaParticipantStatistics));
-
- assertEquals(testJpaParticipantStatistics, new JpaParticipantStatistics(testJpaParticipantStatistics));
- }
-
- @Test
- void testJpaParticipantStatisticsLombok() {
- assertNotNull(new Participant());
- JpaParticipantStatistics ps0 = new JpaParticipantStatistics();
-
- assertThat(ps0.toString()).contains("JpaParticipantStatistics(");
- assertThat(ps0.hashCode()).isNotZero();
- assertEquals(ps0, ps0);
- assertNotEquals(null, ps0);
-
- JpaParticipantStatistics ps1 = new JpaParticipantStatistics();
-
- ps1.setState(ParticipantState.UNKNOWN);
-
- assertThat(ps1.toString()).contains("JpaParticipantStatistics(");
- assertNotEquals(0, ps1.hashCode());
- assertNotEquals(ps1, ps0);
- assertNotEquals(null, ps1);
-
- assertNotEquals(ps1, ps0);
-
- JpaParticipantStatistics ps2 = new JpaParticipantStatistics();
- assertEquals(ps2, ps0);
- }
-
- private JpaParticipantStatistics createJpaParticipantStatisticsInstance() {
- ParticipantStatistics testAces = createParticipantStatisticsInstance();
- JpaParticipantStatistics testJpaParticipantStatistics = new JpaParticipantStatistics();
- testJpaParticipantStatistics.setKey(null);
- testJpaParticipantStatistics.fromAuthorative(testAces);
- testJpaParticipantStatistics.setKey(PfTimestampKey.getNullKey());
- testJpaParticipantStatistics.fromAuthorative(testAces);
-
- return testJpaParticipantStatistics;
- }
-
- private ParticipantStatistics createParticipantStatisticsInstance() {
- ParticipantStatistics participantStatistics = new ParticipantStatistics();
- participantStatistics.setParticipantId(new ToscaConceptIdentifier("participantName", "0.0.1"));
- participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L));
- participantStatistics.setState(ParticipantState.PASSIVE);
- participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY);
-
- return participantStatistics;
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java
deleted file mode 100644
index 7daf3fbcf..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProviderTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.provider;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.time.Instant;
-import java.util.List;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
-import org.onap.policy.clamp.models.acm.concepts.AcElementStatisticsList;
-import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics;
-import org.onap.policy.clamp.models.acm.persistence.repository.AcElementStatisticsRepository;
-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.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class AcElementStatisticsProviderTest {
- private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
- private static final Coder CODER = new StandardCoder();
- private static final String AC_ELEMENT_STATS_JSON = "src/test/resources/providers/TestAcElementStatistics.json";
-
- private AcElementStatisticsProvider acElementStatisticsProvider;
- private AcElementStatisticsList inputAcElementStats;
- private final String originalJson = ResourceUtils.getResourceAsString(AC_ELEMENT_STATS_JSON);
-
- /**
- * Set up test AcElement statistics provider.
- *
- * @throws Exception on errors
- */
- @BeforeEach
- void beforeSetupDao() throws Exception {
-
- inputAcElementStats = CODER.decode(originalJson, AcElementStatisticsList.class);
- var acElementStatisticsRepository = mock(AcElementStatisticsRepository.class);
-
- var jpaAcElementStatisticsList =
- ProviderUtils.getJpaAndValidateList(inputAcElementStats.getAcElementStatistics(),
- JpaAcElementStatistics::new, "automation composition element statistics");
-
- for (var acElementStat : jpaAcElementStatisticsList) {
- when(acElementStatisticsRepository.getById(eq(acElementStat.getKey()))).thenReturn(acElementStat);
- when(acElementStatisticsRepository.findAllById(eq(List.of(acElementStat.getKey()))))
- .thenReturn(List.of(acElementStat));
- }
-
- when(acElementStatisticsRepository.saveAll(anyList())).thenReturn(jpaAcElementStatisticsList);
-
- when(acElementStatisticsRepository.getFiltered(eq(JpaAcElementStatistics.class), any()))
- .thenReturn(List.of(jpaAcElementStatisticsList.get(0)));
-
- acElementStatisticsProvider = new AcElementStatisticsProvider(acElementStatisticsRepository);
- }
-
- @Test
- void testAcElementStatisticsCreate() throws Exception {
- assertThatThrownBy(() -> acElementStatisticsProvider.createAcElementStatistics(null))
- .hasMessageMatching(LIST_IS_NULL);
-
- AcElementStatisticsList createdAcElementStats = new AcElementStatisticsList();
- createdAcElementStats.setAcElementStatistics(
- acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics()));
-
- assertEquals(inputAcElementStats.toString().replaceAll("\\s+", ""),
- createdAcElementStats.toString().replaceAll("\\s+", ""));
- }
-
- @Test
- void testGetAcElementStatistics() throws Exception {
-
- List<AcElementStatistics> getResponse;
-
- // Return empty list when no data present in db
- getResponse = acElementStatisticsProvider.getAcElementStatistics(null, null, null, null);
- assertThat(getResponse).isEmpty();
-
- acElementStatisticsProvider.createAcElementStatistics(inputAcElementStats.getAcElementStatistics());
- ToscaConceptIdentifier identifier = inputAcElementStats.getAcElementStatistics().get(0).getParticipantId();
- Instant instant = inputAcElementStats.getAcElementStatistics().get(0).getTimeStamp();
- String id = inputAcElementStats.getAcElementStatistics().get(0).getId().toString();
- assertEquals(1, acElementStatisticsProvider
- .getAcElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size());
-
- assertEquals(1, acElementStatisticsProvider
- .getFilteredAcElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java
deleted file mode 100644
index 839c14e83..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProviderTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.persistence.provider;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.time.Instant;
-import java.util.List;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantStatisticsList;
-import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics;
-import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantStatisticsRepository;
-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.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ParticipantStatisticsProviderTest {
-
- private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
- private static final Coder CODER = new StandardCoder();
- private static final String PARTICIPANT_STATS_JSON = "src/test/resources/providers/TestParticipantStatistics.json";
-
- private ParticipantStatisticsProvider participantStatisticsProvider;
- private ParticipantStatisticsList inputParticipantStatistics;
- private final String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON);
-
- @BeforeEach
- void beforeSetupDao() throws Exception {
- var participantStatisticsRepository = mock(ParticipantStatisticsRepository.class);
- participantStatisticsProvider = new ParticipantStatisticsProvider(participantStatisticsRepository);
- inputParticipantStatistics = CODER.decode(originalJson, ParticipantStatisticsList.class);
-
- var jpaParticipantStatisticsList =
- ProviderUtils.getJpaAndValidateList(inputParticipantStatistics.getStatisticsList(),
- JpaParticipantStatistics::new, "Participant Statistics");
-
- for (var participantStat : jpaParticipantStatisticsList) {
- when(participantStatisticsRepository.getById(eq(participantStat.getKey()))).thenReturn(participantStat);
- when(participantStatisticsRepository.findAllById(eq(List.of(participantStat.getKey()))))
- .thenReturn(List.of(participantStat));
- }
-
- when(participantStatisticsRepository.getFiltered(eq(JpaParticipantStatistics.class), any()))
- .thenReturn(List.of(jpaParticipantStatisticsList.get(0)));
-
- when(participantStatisticsRepository.saveAll(anyList())).thenReturn(jpaParticipantStatisticsList);
- }
-
- @Test
- void testParticipantStatisticsCreate() throws Exception {
- assertThatThrownBy(() -> {
- participantStatisticsProvider.createParticipantStatistics(null);
- }).hasMessageMatching(LIST_IS_NULL);
-
- ParticipantStatisticsList createdStatsList = new ParticipantStatisticsList();
- createdStatsList.setStatisticsList(participantStatisticsProvider
- .createParticipantStatistics(inputParticipantStatistics.getStatisticsList()));
-
- assertEquals(inputParticipantStatistics.toString().replaceAll("\\s+", ""),
- createdStatsList.toString().replaceAll("\\s+", ""));
- }
-
- @Test
- void testGetAutomationCompositions() throws Exception {
- // Return empty list when no data present in db
- List<ParticipantStatistics> getResponse =
- participantStatisticsProvider.getParticipantStatistics(null, null, null);
- assertThat(getResponse).isEmpty();
-
- participantStatisticsProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
- ToscaConceptIdentifier identifier = inputParticipantStatistics.getStatisticsList().get(0).getParticipantId();
- Instant instant = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp();
- assertEquals(1, participantStatisticsProvider
- .getParticipantStatistics(identifier.getName(), identifier.getVersion(), instant).size());
-
- assertEquals(1, participantStatisticsProvider
- .getFilteredParticipantStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
- }
-}