0e1da16b9e2db201134de9253fe4abd899d623a8
[so.git] / common / src / test / java / org / onap / so / utils / CheckResultsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.utils;
22
23 import static org.junit.Assert.*;
24
25 import java.util.List;
26
27 import org.junit.Test;
28
29 import org.onap.so.utils.CheckResults.CheckResult;
30
31 public class CheckResultsTest {
32
33     /**
34      * Test method for {@link org.onap.so.utils.CheckResults#getResults()}.
35      */
36     @Test
37     public final void testGetResults () {
38         CheckResults cr = new CheckResults ();
39         cr.addHostCheckResult ("host1", 0, "output");
40         cr.addHostCheckResult ("host2", 2, "output2");
41         cr.addServiceCheckResult ("host1", "service1", 0, "outputServ");
42         cr.addServiceCheckResult ("host1", "service2", 2, "outputServ2");
43         cr.addServiceCheckResult ("host2", "service1", 0, "output2Serv");
44         cr.addServiceCheckResult ("host2", "service2", 2, "output2Serv2");
45         List <CheckResult> res = cr.getResults ();
46         assertEquals(res.size (), 6);
47         assertEquals(res.get (0).getHostname (), "host1");
48         assertEquals(res.get (1).getHostname (), "host2");
49         assertEquals(res.get (2).getHostname (), "host1");
50         assertEquals(res.get (3).getHostname (), "host1");
51         assertEquals(res.get (4).getHostname (), "host2");
52         assertEquals(res.get (5).getHostname (), "host2");
53         assertEquals(res.get (0).getServicename (), null);
54         assertEquals(res.get (3).getServicename (), "service2");
55         assertEquals(res.get (5).getState (), 2);
56     }
57
58 }