Remove legacy operational Policy
[clamp.git] / src / test / java / org / onap / clamp / loop / ExternalComponentStateTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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  * ===================================================================
21  *
22  */
23
24 package org.onap.clamp.loop;
25
26 import static org.assertj.core.api.Assertions.assertThat;
27
28 import org.junit.Test;
29 import org.onap.clamp.loop.components.external.ExternalComponentState;
30
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);
34
35     @Test
36     public void generalTest() {
37         assertThat(state.toString()).isEqualTo("NOT_SENT");
38         state.setLevel(70);
39         assertThat(state.getLevel()).isEqualTo(70);
40     }
41
42     @Test
43     public void equalsTest() {
44         assertThat(state.equals(null)).isEqualTo(false);
45
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);
49
50         assertThat(state.equals(12)).isEqualTo(false);
51
52         state2.setLevel(70);
53         assertThat(state.equals(state2)).isEqualTo(true);
54
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);
58
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);
65     }
66
67     @Test
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);
72
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);
76
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);
80
81     }
82 }