aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java8
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java52
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java34
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java21
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java82
-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
13 files changed, 68 insertions, 304 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
index 1a8fbc409..6a523fa75 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 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.
@@ -39,10 +39,7 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
- private ParticipantState participantState = ParticipantState.UNKNOWN;
-
- @NonNull
- private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN;
+ private ParticipantState participantState = ParticipantState.ON_LINE;
@NonNull
private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
@@ -71,7 +68,6 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
super(otherParticipant);
this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
this.participantState = otherParticipant.participantState;
- this.healthStatus = otherParticipant.healthStatus;
this.participantType = otherParticipant.participantType;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java
deleted file mode 100644
index f8cc0a852..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java
+++ /dev/null
@@ -1,52 +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.concepts;
-
-/**
- * Class to hold the possible values for health status of Participant.
- */
-public enum ParticipantHealthStatus {
-
- /**
- * Participant is healthy and working fine.
- */
- HEALTHY,
-
- /**
- * Participant is not healthy.
- */
- NOT_HEALTHY,
-
- /**
- * Participant is currently under test state and performing tests.
- */
- TEST_IN_PROGRESS,
-
- /**
- * The health status of the Participant is unknown.
- */
- UNKNOWN,
-
- /**
- * The health status of the Participant is off line.
- */
- OFF_LINE
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
index 4ab42c697..30dc69a06 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 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.
@@ -25,36 +25,12 @@ package org.onap.policy.clamp.models.acm.concepts;
*/
public enum ParticipantState {
/**
- * Participant state is unknown.
+ * Participant state is online.
*/
- UNKNOWN,
+ ON_LINE,
/**
- * Participant is passive, automation composition element execution is always rejected.
+ * Participant is offline, automation composition element execution is always rejected.
*/
- PASSIVE,
-
- /**
- * Automation composition element execution execution proceeds, but changes to domain state or context are not
- * carried out. The participant returns an indication that it is running in SAFE mode together with the action it
- * would have performed if it was operating in ACTIVE mode.
- */
- SAFE,
-
- /**
- * Automation composition element execution execution proceeds and changes to domain and state are carried out in a
- * test environment. The participant returns an indication that it is running in TEST mode together with the action
- * it has performed on the test environment.
- */
- TEST,
-
- /**
- * Automation composition element execution is executed in the live environment by the participant.
- */
- ACTIVE,
-
- /**
- * Automation composition element execution has been terminated.
- */
- TERMINATED
+ OFF_LINE
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
index 1d57c24e8..31a42c548 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.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.
@@ -27,7 +27,6 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
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.models.base.PfUtils;
@@ -41,7 +40,6 @@ public class ParticipantStatus extends ParticipantMessage {
// State and health status of the participant
private ParticipantState state;
- private ParticipantHealthStatus healthStatus;
// A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only
private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
@@ -66,7 +64,6 @@ public class ParticipantStatus extends ParticipantMessage {
super(source);
this.state = source.state;
- this.healthStatus = source.healthStatus;
this.participantDefinitionUpdates =
PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
this.automationCompositionInfoList =
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
index 143499c0d..aec2d32d3 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 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.
@@ -34,7 +34,6 @@ import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
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.common.parameters.annotations.NotNull;
import org.onap.policy.models.base.PfAuthorative;
@@ -80,10 +79,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
private ParticipantState participantState;
@Column
- @NotNull
- private ParticipantHealthStatus healthStatus;
-
- @Column
private String description;
/**
@@ -99,7 +94,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
* @param key the key
*/
public JpaParticipant(@NonNull final PfConceptKey key) {
- this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.UNKNOWN);
+ this(key, new PfConceptKey(), ParticipantState.ON_LINE);
}
/**
@@ -108,14 +103,12 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
* @param key the key
* @param definition the TOSCA definition of the participant
* @param participantState the state of the participant
- * @param healthStatus the health state of the participant
*/
public JpaParticipant(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition,
- @NonNull final ParticipantState participantState, @NonNull ParticipantHealthStatus healthStatus) {
+ @NonNull final ParticipantState participantState) {
this.key = key;
this.definition = definition;
this.participantState = participantState;
- this.healthStatus = healthStatus;
}
/**
@@ -128,7 +121,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.key = new PfConceptKey(copyConcept.key);
this.definition = new PfConceptKey(copyConcept.definition);
this.participantState = copyConcept.participantState;
- this.healthStatus = copyConcept.healthStatus;
this.description = copyConcept.description;
this.participantType = copyConcept.participantType;
}
@@ -150,7 +142,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
participant.setVersion(key.getVersion());
participant.setDefinition(new ToscaConceptIdentifier(definition));
participant.setParticipantState(participantState);
- participant.setHealthStatus(healthStatus);
participant.setDescription(description);
participant.setParticipantType(new ToscaConceptIdentifier(participantType));
@@ -165,7 +156,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.definition = participant.getDefinition().asConceptKey();
this.setParticipantState(participant.getParticipantState());
- this.setHealthStatus(participant.getHealthStatus());
this.setDescription(participant.getDescription());
this.participantType = participant.getParticipantType().asConceptKey();
}
@@ -216,11 +206,6 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
return result;
}
- result = ObjectUtils.compare(healthStatus, other.healthStatus);
- if (result != 0) {
- return result;
- }
-
result = ObjectUtils.compare(participantType, other.participantType);
if (result != 0) {
return result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
index 6e3b56d56..3f7e297a4 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.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.
@@ -23,15 +23,13 @@ package org.onap.policy.clamp.models.acm.persistence.provider;
import java.util.List;
import java.util.Optional;
import javax.ws.rs.core.Response.Status;
-import lombok.AllArgsConstructor;
import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant;
import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,10 +38,10 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
-@AllArgsConstructor
+@RequiredArgsConstructor
public class ParticipantProvider {
- private ParticipantRepository participantRepository;
+ private final ParticipantRepository participantRepository;
/**
* Get participants.
@@ -71,32 +69,12 @@ public class ParticipantProvider {
/**
* Get participant.
*
- * @param name the name of the participant to get
- * @param version the version of the participant to get
+ * @param participantId the Id of the participant to get
* @return the participant found
- * @throws PfModelException on errors getting participant
*/
@Transactional(readOnly = true)
- public Optional<Participant> findParticipant(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
- try {
- return participantRepository.findById(new PfConceptKey(name, version)).map(JpaParticipant::toAuthorative);
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in find Participant", e);
- }
- }
-
- /**
- * Get filtered participants.
- *
- * @param filter the filter for the participants to get
- * @return the participants found
- */
- @Transactional(readOnly = true)
- public List<Participant> getFilteredParticipants(@NonNull final ToscaTypedEntityFilter<Participant> filter) {
-
- return filter.filter(ProviderUtils.asEntityList(
- participantRepository.getFiltered(JpaParticipant.class, filter.getName(), filter.getVersion())));
+ public Optional<Participant> findParticipant(@NonNull final ToscaConceptIdentifier participantId) {
+ return participantRepository.findById(participantId.asConceptKey()).map(JpaParticipant::toAuthorative);
}
/**
@@ -104,45 +82,31 @@ public class ParticipantProvider {
*
* @param participant participant to save
* @return the participant created
- * @throws PfModelException on errors creating participants
*/
- public Participant saveParticipant(@NonNull final Participant participant) throws PfModelException {
- try {
- var result = participantRepository
- .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
+ public Participant saveParticipant(@NonNull final Participant participant) {
+ var result = participantRepository
+ .save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
- // Return the saved participant
- return result.toAuthorative();
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in save Participant", e);
- }
+ // Return the saved participant
+ return result.toAuthorative();
}
/**
* Delete a participant.
*
- * @param name the name of the participant to delete
- * @param version the version of the participant to get
+ * @param participantId the Id of the participant to delete
* @return the participant deleted
- * @throws PfModelRuntimeException on errors deleting participants
*/
- public Participant deleteParticipant(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
- try {
- var participantKey = new PfConceptKey(name, version);
+ public Participant deleteParticipant(@NonNull final ToscaConceptIdentifier participantId) {
+ var jpaDeleteParticipantOpt = participantRepository.findById(participantId.asConceptKey());
- var jpaDeleteParticipantOpt = participantRepository.findById(participantKey);
-
- if (jpaDeleteParticipantOpt.isEmpty()) {
- String errorMessage =
- "delete of participant \"" + participantKey.getId() + "\" failed, participant does not exist";
- throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage);
- }
- participantRepository.delete(jpaDeleteParticipantOpt.get());
-
- return jpaDeleteParticipantOpt.get().toAuthorative();
- } catch (IllegalArgumentException e) {
- throw new PfModelException(Status.BAD_REQUEST, "Error in delete Participant", e);
+ if (jpaDeleteParticipantOpt.isEmpty()) {
+ String errorMessage =
+ "delete of participant \"" + participantId + "\" failed, participant does not exist";
+ throw new PfModelRuntimeException(Status.BAD_REQUEST, errorMessage);
}
+ participantRepository.delete(jpaDeleteParticipantOpt.get());
+
+ return jpaDeleteParticipantOpt.get().toAuthorative();
}
}
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
- }
- ]
-}