0b6cbcf228361f7c0dfc2532207692350526b6ac
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * appc
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.policy.appclcm;
22
23 import static org.junit.Assert.*;
24
25 import org.junit.Test;
26
27 public class TestLCMResponseStatus {
28
29         @Test
30         public void testResonseStatus() {
31                 LCMResponseStatus status = new LCMResponseStatus();
32                 assertNotNull(status);
33                 assertNotEquals(0, status.hashCode());
34                 
35                 status.setCode(1234);
36                 assertEquals(1234, status.getCode());
37                 
38                 status.setMessage("The wonderful land of Oz");
39                 assertEquals("The wonderful land of Oz", status.getMessage());
40                 
41                 assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0,  47));
42                 
43         LCMResponseStatus copiedStatus = new LCMResponseStatus();
44         copiedStatus.setCode(status.getCode());
45         copiedStatus.setMessage(status.getMessage());
46
47         assertTrue(status.equals(status));
48         assertTrue(status.equals(copiedStatus));
49         assertFalse(status.equals(null));
50         assertFalse(status.equals("Hello"));
51         
52         status.setCode(-1);
53         assertFalse(status.equals(copiedStatus));
54         copiedStatus.setCode(-1);
55         assertTrue(status.equals(copiedStatus));
56         status.setCode(1234);
57         assertFalse(status.equals(copiedStatus));
58         copiedStatus.setCode(1234);
59         assertTrue(status.equals(copiedStatus));
60         
61         status.setMessage(null);
62         assertFalse(status.equals(copiedStatus));
63         copiedStatus.setMessage(null);
64         assertTrue(status.equals(copiedStatus));
65         status.setMessage("The wonderful land of Oz");
66         assertFalse(status.equals(copiedStatus));
67         copiedStatus.setMessage("The wonderful land of Oz");
68         assertTrue(status.equals(copiedStatus));
69         }
70 }