2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 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.controlloop.models.controlloop.concepts;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertNotNull;
29 import org.junit.jupiter.api.Test;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
32 class ParticipantTest {
34 void testParticipant() {
36 Participant p0 = new Participant();
37 p0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
38 assertEquals("dfName", p0.getType());
39 assertEquals("1.2.3", p0.getTypeVersion());
41 Participant p1 = new Participant(p0);
44 assertEquals(0, p0.compareTo(p1));
48 void testParticipantLombok() {
49 assertNotNull(new Participant());
50 Participant p0 = new Participant();
52 assertThat(p0.toString()).contains("Participant(");
53 assertThat(p0.hashCode()).isNotZero();
54 assertEquals(true, p0.equals(p0));
55 assertEquals(false, p0.equals(null));
58 Participant p1 = new Participant();
60 p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
61 p1.setDescription("Description");
62 p1.setHealthStatus(ParticipantHealthStatus.HEALTHY);
64 p1.setParticipantState(ParticipantState.ACTIVE);
65 p1.setVersion("0.0.1");
67 assertThat(p1.toString()).contains("Participant(");
68 assertEquals(false, p1.hashCode() == 0);
69 assertEquals(false, p1.equals(p0));
70 assertEquals(false, p1.equals(null));
72 assertNotEquals(p1, p0);
74 Participant p2 = new Participant();
77 assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class);
78 assertThatThrownBy(() -> p2.setHealthStatus(null)). isInstanceOf(NullPointerException.class);
79 assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class);