aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2025-02-11 16:22:22 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2025-02-11 16:47:23 +0000
commite3c94609eba45f2c4e10ab52024709bd9a216aca (patch)
treea36ac2bdf866636b36eb6c6e51bef6af1b4b6ab1 /models
parenta3bd73b57f83cd11d58a33f81a13139462d64563 (diff)
Add consumer producer messages support in ACM-r model
Issue-ID: POLICY-5276 Change-Id: I7f11cec08de46996d5e3f487566f7cc37f441a31 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocMessage.java87
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessage.java109
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJob.java75
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessage.java57
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageJobRepository.java32
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageRepository.java30
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJobTest.java50
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageTest.java90
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessageTest.java60
9 files changed, 590 insertions, 0 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocMessage.java
new file mode 100644
index 000000000..05d031498
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocMessage.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.document.concepts;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Data
+@EqualsAndHashCode
+@NoArgsConstructor
+public class DocMessage {
+ private String messageId;
+
+ private ParticipantMessageType messageType;
+ private UUID participantId;
+ private UUID replicaId;
+
+ private UUID compositionId;
+ private AcTypeState compositionState;
+ private StateChangeResult stateChangeResult;
+
+ private UUID instanceId;
+ private UUID instanceElementId;
+ private DeployState deployState;
+ private LockState lockState;
+ private String message;
+ private Integer stage;
+
+ private ToscaConceptIdentifier acElementDefinitionId;
+ private Map<String, Object> outProperties = new LinkedHashMap<>();
+ private String operationalState;
+ private String useState;
+
+ /**
+ * Constructor.
+ *
+ * @param copy copy Constructor
+ */
+ public DocMessage(DocMessage copy) {
+ this.messageId = copy.messageId;
+ this.messageType = copy.messageType;
+ this.participantId = copy.participantId;
+ this.replicaId = copy.replicaId;
+ this.compositionId = copy.compositionId;
+ this.compositionState = copy.compositionState;
+ this.stateChangeResult = copy.stateChangeResult;
+ this.instanceId = copy.instanceId;
+ this.instanceElementId = copy.instanceElementId;
+ this.deployState = copy.deployState;
+ this.lockState = copy.lockState;
+ this.message = copy.message;
+ this.stage = copy.stage;
+ this.acElementDefinitionId = copy.acElementDefinitionId;
+ this.outProperties = AcmUtils.cloneMap(copy.outProperties);
+ this.operationalState = copy.operationalState;
+ this.useState = copy.useState;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessage.java
new file mode 100644
index 000000000..ac23d52a2
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessage.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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 jakarta.persistence.Column;
+import jakarta.persistence.Convert;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Index;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.Lob;
+import jakarta.persistence.Table;
+import java.sql.Timestamp;
+import java.util.UUID;
+import lombok.Data;
+import lombok.NonNull;
+import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
+import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.Validated;
+
+@Entity
+@Table(name = "Message", indexes = {@Index(name = "m_identificationId", columnList = "identificationId")})
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+public class JpaMessage extends Validated implements PfAuthorative<DocMessage> {
+
+ @Id
+ @NotNull
+ private String messageId = UUID.randomUUID().toString();
+
+ @Column
+ @NotNull
+ // instanceId or compositionId
+ private String identificationId;
+
+ @Column
+ @NotNull
+ private Timestamp lastMsg = TimestampHelper.nowTimestamp();
+
+ @Lob
+ @Column(length = 100000)
+ @Convert(converter = StringToDocMessage.class)
+ @NotNull
+ private DocMessage docMessage;
+
+ public JpaMessage() {
+ this(UUID.randomUUID().toString(), new DocMessage());
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaMessage(@NonNull final JpaMessage copyConcept) {
+ this.messageId = copyConcept.messageId;
+ this.identificationId = copyConcept.identificationId;
+ this.lastMsg = copyConcept.lastMsg;
+ fromAuthorative(copyConcept.docMessage);
+ }
+
+ public JpaMessage(@NonNull final String identificationId, @NonNull final DocMessage docMessage) {
+ this.identificationId = identificationId;
+ fromAuthorative(docMessage);
+ }
+
+ @Override
+ public BeanValidationResult validate(@NonNull String fieldName) {
+ var result = super.validate(fieldName);
+ if (!result.isValid()) {
+ return result;
+ }
+
+ return result;
+ }
+
+ @Override
+ public DocMessage toAuthorative() {
+ return new DocMessage(this.docMessage);
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull final DocMessage docMessage) {
+ this.docMessage = new DocMessage(docMessage);
+ this.docMessage.setMessageId(messageId);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJob.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJob.java
new file mode 100644
index 000000000..95a62161b
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJob.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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 jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.Table;
+import java.sql.Timestamp;
+import java.util.UUID;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.Validated;
+
+@Entity
+@Table(name = "MessageJob")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class JpaMessageJob extends Validated {
+
+ @Id
+ @NotNull
+ private String jobId = UUID.randomUUID().toString();
+
+ @Column(unique = true)
+ @NotNull
+ private String identificationId;
+
+ @Column
+ @NotNull
+ private Timestamp jobStarted = TimestampHelper.nowTimestamp();
+
+ public JpaMessageJob() {
+ this(UUID.randomUUID().toString());
+ }
+
+ public JpaMessageJob(@NonNull final String identificationId) {
+ this.identificationId = identificationId;
+ }
+
+ @Override
+ public BeanValidationResult validate(@NonNull String fieldName) {
+ var result = super.validate(fieldName);
+ if (!result.isValid()) {
+ return result;
+ }
+
+ return result;
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessage.java
new file mode 100644
index 000000000..78eaed245
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessage.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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 jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
+import jakarta.ws.rs.core.Response;
+import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+@Converter(autoApply = true)
+public class StringToDocMessage implements AttributeConverter<DocMessage, String> {
+
+ private static final Coder coder = new StandardCoder();
+
+ @Override
+ public String convertToDatabaseColumn(DocMessage docMessage) {
+ try {
+ return docMessage == null ? null : coder.encode(docMessage);
+ } catch (CoderException e) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public DocMessage convertToEntityAttribute(String message) {
+ if (message == null) {
+ return new DocMessage();
+ }
+ try {
+ return coder.decode(message, DocMessage.class);
+ } catch (CoderException e) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e);
+ }
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageJobRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageJobRepository.java
new file mode 100644
index 000000000..0a9b88ebc
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageJobRepository.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.repository;
+
+import java.util.Optional;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaMessageJob;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MessageJobRepository extends JpaRepository<JpaMessageJob, String> {
+
+ Optional<JpaMessageJob> findByIdentificationId(String identificationId);
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageRepository.java
new file mode 100644
index 000000000..be3561e94
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/MessageRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.repository;
+
+import java.util.List;
+import org.onap.policy.clamp.models.acm.persistence.concepts.JpaMessage;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface MessageRepository extends JpaRepository<JpaMessage, String> {
+
+ List<JpaMessage> findByIdentificationIdOrderByLastMsgDesc(String identificationId);
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJobTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJobTest.java
new file mode 100644
index 000000000..bf673bed5
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJobTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+
+class JpaMessageJobTest {
+
+ @Test
+ void testJpaMessageJobConstructor() {
+ assertThatThrownBy(() -> new JpaMessageJob(null))
+ .hasMessageMatching("identificationId is marked .*ull but is null");
+ }
+
+ @Test
+ void testJpaMessageValidation() {
+ var jpaMessageJob = new JpaMessageJob();
+
+ assertThatThrownBy(() -> jpaMessageJob.validate(null))
+ .hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(jpaMessageJob.validate("").isValid());
+
+ jpaMessageJob.setJobStarted(null);
+ assertFalse(jpaMessageJob.validate("").isValid());
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageTest.java
new file mode 100644
index 000000000..f9a19c408
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
+import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
+
+class JpaMessageTest {
+
+ @Test
+ void testJpaMessageConstructor() {
+ assertThatThrownBy(() -> new JpaMessage(null, new DocMessage()))
+ .hasMessageMatching("identificationId is marked .*ull but is null");
+ assertThatThrownBy(() -> new JpaMessage(UUID.randomUUID().toString(), null))
+ .hasMessageMatching("docMessage is marked .*ull but is null");
+ }
+
+ @Test
+ void testJpaMessageValidation() {
+ var docMessage = createDocMessage();
+ var jpaMessage = new JpaMessage(docMessage.getInstanceId().toString(), docMessage);
+
+ assertThatThrownBy(() -> jpaMessage.validate(null))
+ .hasMessageMatching("fieldName is marked .*ull but is null");
+
+ assertTrue(jpaMessage.validate("").isValid());
+
+ jpaMessage.setLastMsg(null);
+ assertFalse(jpaMessage.validate("").isValid());
+ }
+
+ @Test
+ void testJpaMessage() {
+ var docMessage = createDocMessage();
+ var jpaMessage = new JpaMessage(docMessage.getInstanceId().toString(), docMessage);
+ docMessage.setMessageId(jpaMessage.getMessageId());
+
+ assertEquals(docMessage, jpaMessage.toAuthorative());
+
+ assertThatThrownBy(() -> jpaMessage.fromAuthorative(null))
+ .hasMessageMatching("docMessage is marked .*ull but is null");
+
+ assertThatThrownBy(() -> new JpaMessage((JpaMessage) null)).isInstanceOf(NullPointerException.class);
+
+ var jpaMessageFa = new JpaMessage();
+ jpaMessageFa.setIdentificationId(docMessage.getInstanceId().toString());
+ jpaMessageFa.setLastMsg(jpaMessage.getLastMsg());
+ jpaMessageFa.setMessageId(jpaMessage.getMessageId());
+ jpaMessageFa.fromAuthorative(docMessage);
+ assertEquals(jpaMessage, jpaMessageFa);
+
+ var jpaMessage2 = new JpaMessage(jpaMessage);
+ assertEquals(jpaMessage, jpaMessage2);
+ }
+
+ private DocMessage createDocMessage() {
+ var docMessage = new DocMessage();
+ docMessage.setMessageType(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK);
+ docMessage.setCompositionId(UUID.randomUUID());
+ docMessage.setInstanceId(UUID.randomUUID());
+ docMessage.setDeployState(DeployState.DEPLOYED);
+ return docMessage;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessageTest.java
new file mode 100644
index 000000000..84dc3409d
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/StringToDocMessageTest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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 java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
+import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
+import org.onap.policy.models.base.PfModelRuntimeException;
+
+class StringToDocMessageTest {
+
+ @Test
+ void testConvert() {
+ var stringToDocMessage = new StringToDocMessage();
+ var docMessage = new DocMessage();
+ docMessage.setMessageId(UUID.randomUUID().toString());
+ docMessage.setInstanceId(UUID.randomUUID());
+ docMessage.setCompositionId(UUID.randomUUID());
+ docMessage.setStage(0);
+ docMessage.setMessageType(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK);
+ var dbData = stringToDocMessage.convertToDatabaseColumn(docMessage);
+ var result = stringToDocMessage.convertToEntityAttribute(dbData);
+ assertEquals(docMessage, result);
+ }
+
+ @Test
+ void testNull() {
+ var stringToDocMessage = new StringToDocMessage();
+ var dbData = stringToDocMessage.convertToDatabaseColumn(null);
+ assertThat(dbData).isNull();
+ var map = stringToDocMessage.convertToEntityAttribute(null);
+ assertThat(map).isNotNull();
+ assertThatThrownBy(() -> stringToDocMessage.convertToEntityAttribute("1"))
+ .isInstanceOf(PfModelRuntimeException.class);
+ }
+
+}