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.ParticipantState;
33 class JpaParticipantReplicaTest {
36 void testJpaParticipantReplicaConstructor() {
37 assertThatThrownBy(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), null))
38 .hasMessageMatching("participantId is marked .*ull but is null");
40 assertThatThrownBy(() -> new JpaParticipantReplica(null, UUID.randomUUID().toString()))
41 .hasMessageMatching("replicaId is marked .*ull but is null");
43 assertDoesNotThrow(() -> new JpaParticipantReplica());
44 assertDoesNotThrow(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
48 void testJpaParticipantReplica() {
49 var p0 = new JpaParticipantReplica();
51 assertThat(p0.toString()).contains("JpaParticipantReplica(");
52 assertThat(p0.hashCode()).isNotZero();
53 assertNotEquals(null, p0);
55 var p1 = new JpaParticipantReplica();
56 p1.setParticipantState(ParticipantState.ON_LINE);
58 assertThat(p1.toString()).contains("ParticipantReplica(");
59 assertNotEquals(0, p1.hashCode());
60 assertNotEquals(p1, p0);
61 assertNotEquals(null, p1);
63 var p2 = new JpaParticipantReplica();
64 p2.setReplicaId(p0.getReplicaId());
65 p2.setParticipantId(p0.getParticipantId());
66 p2.setLastMsg(p0.getLastMsg());
67 p2.setParticipantState(p0.getParticipantState());