2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.models.acm.persistence.concepts;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
26 import static org.junit.jupiter.api.Assertions.assertEquals;
27 import static org.junit.jupiter.api.Assertions.assertNotEquals;
29 import java.util.UUID;
30 import org.junit.jupiter.api.Test;
31 import org.onap.policy.clamp.models.acm.concepts.ParticipantReplica;
32 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
33 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
35 class JpaParticipantReplicaTest {
38 void testJpaParticipantReplicaConstructor() {
39 assertThatThrownBy(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), null))
40 .hasMessageMatching("participantId is marked .*ull but is null");
42 assertThatThrownBy(() -> new JpaParticipantReplica(null, UUID.randomUUID().toString()))
43 .hasMessageMatching("replicaId is marked .*ull but is null");
45 assertDoesNotThrow(() -> new JpaParticipantReplica());
46 assertDoesNotThrow(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
50 void testJpaParticipantReplica() {
51 var p0 = new JpaParticipantReplica();
53 assertThat(p0.toString()).contains("JpaParticipantReplica(");
54 assertThat(p0.hashCode()).isNotZero();
55 assertNotEquals(null, p0);
57 var p1 = new JpaParticipantReplica();
58 p1.setParticipantState(ParticipantState.ON_LINE);
60 assertThat(p1.toString()).contains("ParticipantReplica(");
61 assertNotEquals(0, p1.hashCode());
62 assertNotEquals(p1, p0);
63 assertNotEquals(null, p1);
65 var p2 = new JpaParticipantReplica();
66 p2.setReplicaId(p0.getReplicaId());
67 p2.setParticipantId(p0.getParticipantId());
68 p2.setLastMsg(p0.getLastMsg());
69 p2.setParticipantState(p0.getParticipantState());