Changes for checkstyle 8.32
[policy/apex-pdp.git] / core / core-protocols / src / test / java / org / onap / policy / apex / core / protocols / engdep / messages / EngineServiceInfoResponseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2019 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * 
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * 
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.core.protocols.engdep.messages;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28
29 import java.util.ArrayList;
30 import java.util.List;
31 import org.junit.Test;
32 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
33
34 /**
35  * Test the start engine message.
36  */
37 public class EngineServiceInfoResponseTest {
38
39     @Test
40     public void test() {
41         AxArtifactKey targetKey = new AxArtifactKey("Target:0.0.1");
42         GetEngineServiceInfo request = new GetEngineServiceInfo(targetKey);
43         
44         EngineServiceInfoResponse response = new EngineServiceInfoResponse(targetKey, true, request);
45         assertNotNull(response);
46         response = new EngineServiceInfoResponse(targetKey, true, "Response Data", request);
47         assertNotNull(response);
48         assertEquals("Response Data", response.getMessageData());
49         
50         AxArtifactKey apexModelKey = new AxArtifactKey("Model:0.0.1");
51         response.setApexModelKey(apexModelKey);
52         assertEquals(apexModelKey, response.getApexModelKey());
53         
54         AxArtifactKey engineServiceKey = new AxArtifactKey("EngineService:0.0.1");
55         response.setEngineServiceKey(engineServiceKey);;
56         assertEquals(engineServiceKey, response.getEngineServiceKey());
57         
58         List<AxArtifactKey> engineKeyArrayList = new ArrayList<>();
59         AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
60         engineKeyArrayList.add(engineKey);
61         response.setEngineKeyArray(engineKeyArrayList);
62         assertEquals(engineKeyArrayList.get(0), response.getEngineKeyArray()[0]);
63         
64         response = new EngineServiceInfoResponse(null, false, null);
65         assertTrue(response.hashCode() != 0);
66         response.setApexModelKey(apexModelKey);
67         assertTrue(response.hashCode() != 0);
68         response.setApexModelKey(null);
69         response.setEngineServiceKey(engineServiceKey);;
70         assertTrue(response.hashCode() != 0);
71         response.setEngineServiceKey(null);
72         response.setEngineKeyArray(engineKeyArrayList);
73         assertTrue(response.hashCode() != 0);
74         response.setEngineKeyArray(null);
75         
76         assertTrue(response.equals(response));
77         assertFalse(response.equals(null));
78         assertFalse(response.equals((Object) new StartEngine(new AxArtifactKey())));
79
80         response = new EngineServiceInfoResponse(null, false, null);
81         EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null);
82
83         response.setApexModelKey(apexModelKey);
84         assertFalse(response.equals(otherResponse));
85         otherResponse.setApexModelKey(apexModelKey);
86         assertTrue(response.equals(otherResponse));
87         response.setApexModelKey(null);
88         assertFalse(response.equals(otherResponse));
89         otherResponse.setApexModelKey(null);
90         assertTrue(response.equals(otherResponse));
91
92         response.setEngineServiceKey(engineServiceKey);
93         assertFalse(response.equals(otherResponse));
94         otherResponse.setEngineServiceKey(engineServiceKey);
95         assertTrue(response.equals(otherResponse));
96         response.setEngineServiceKey(null);
97         assertFalse(response.equals(otherResponse));
98         otherResponse.setEngineServiceKey(null);
99         assertTrue(response.equals(otherResponse));
100
101         response.setEngineKeyArray(engineKeyArrayList);
102         assertFalse(response.equals(otherResponse));
103         otherResponse.setEngineKeyArray(engineKeyArrayList);
104         assertTrue(response.equals(otherResponse));
105         response.setEngineKeyArray(null);
106         assertFalse(response.equals(otherResponse));
107         otherResponse.setEngineKeyArray(null);
108         assertTrue(response.equals(otherResponse));
109
110     }
111 }