2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.loop;
26 import static org.assertj.core.api.Assertions.assertThat;
28 import org.junit.Test;
29 import org.onap.clamp.loop.components.external.ExternalComponentState;
31 public class ExternalComponentStateTest {
32 private ExternalComponentState state = new ExternalComponentState("NOT_SENT",
33 "The policies defined have NOT yet been created on the policy engine", 90);
36 public void generalTest() {
37 assertThat(state.toString()).isEqualTo("NOT_SENT");
39 assertThat(state.getLevel()).isEqualTo(70);
43 public void equalsTest() {
44 assertThat(state.equals(null)).isEqualTo(false);
46 ExternalComponentState state2 = new ExternalComponentState("NOT_SENT",
47 "The policies defined have NOT yet been created on the policy engine", 90);
48 assertThat(state.equals(state2)).isEqualTo(true);
50 assertThat(state.equals(12)).isEqualTo(false);
53 assertThat(state.equals(state2)).isEqualTo(true);
55 ExternalComponentState state3 = new ExternalComponentState("SENT",
56 "The policies defined have NOT yet been created on the policy engine", 90);
57 assertThat(state.equals(state3)).isEqualTo(false);
59 ExternalComponentState state4 = new ExternalComponentState(null,
60 "The policies defined have NOT yet been created on the policy engine", 90);
61 ExternalComponentState state5 = new ExternalComponentState(null,
62 "The policies defined have NOT yet been", 50);
63 assertThat(state4.equals(state3)).isEqualTo(false);
64 assertThat(state4.equals(state5)).isEqualTo(true);
68 public void compareToTest() {
69 ExternalComponentState state2 = new ExternalComponentState("NOT_SENT",
70 "The policies defined have NOT yet been created on the policy engine", 90);
71 assertThat(state.compareTo(state2)).isEqualTo(0);
73 ExternalComponentState state3 = new ExternalComponentState("SENT",
74 "The policies defined have NOT yet been created on the policy engine", 50);
75 assertThat(state.compareTo(state3)).isEqualTo(1);
77 ExternalComponentState state4 = new ExternalComponentState(null,
78 "The policies defined have NOT yet been created on the policy engine", 100);
79 assertThat(state.compareTo(state4)).isEqualTo(-1);