2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019-2020 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.core.protocols.engdep.messages;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotEquals;
26 import static org.junit.Assert.assertNotNull;
28 import java.util.ArrayList;
29 import java.util.List;
30 import org.junit.Test;
31 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
34 * Test the start engine message.
36 public class EngineServiceInfoResponseTest {
40 AxArtifactKey targetKey = new AxArtifactKey("Target:0.0.1");
41 GetEngineServiceInfo request = new GetEngineServiceInfo(targetKey);
43 EngineServiceInfoResponse response = new EngineServiceInfoResponse(targetKey, true, request);
44 assertNotNull(response);
45 response = new EngineServiceInfoResponse(targetKey, true, "Response Data", request);
46 assertNotNull(response);
47 assertEquals("Response Data", response.getMessageData());
49 AxArtifactKey apexModelKey = new AxArtifactKey("Model:0.0.1");
50 response.setApexModelKey(apexModelKey);
51 assertEquals(apexModelKey, response.getApexModelKey());
53 AxArtifactKey engineServiceKey = new AxArtifactKey("EngineService:0.0.1");
54 response.setEngineServiceKey(engineServiceKey);;
55 assertEquals(engineServiceKey, response.getEngineServiceKey());
57 List<AxArtifactKey> engineKeyArrayList = new ArrayList<>();
58 AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
59 engineKeyArrayList.add(engineKey);
60 response.setEngineKeyArray(engineKeyArrayList);
61 assertEquals(engineKeyArrayList.get(0), response.getEngineKeyArray()[0]);
63 response = new EngineServiceInfoResponse(null, false, null);
64 assertNotEquals(0, response.hashCode());
65 response.setApexModelKey(apexModelKey);
66 assertNotEquals(0, response.hashCode());
67 response.setApexModelKey(null);
68 response.setEngineServiceKey(engineServiceKey);;
69 assertNotEquals(0, response.hashCode());
70 response.setEngineServiceKey(null);
71 response.setEngineKeyArray(engineKeyArrayList);
72 assertNotEquals(0, response.hashCode());
73 response.setEngineKeyArray(null);
74 // disabling sonar because this code tests the equals() method
75 assertEquals(response, response); // NOSONAR
76 assertNotNull(response);
77 assertNotEquals(response, (Object) new StartEngine(new AxArtifactKey()));
79 response = new EngineServiceInfoResponse(null, false, null);
80 EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null);
82 response.setApexModelKey(apexModelKey);
83 assertNotEquals(response, otherResponse);
84 otherResponse.setApexModelKey(apexModelKey);
85 assertEquals(response, otherResponse);
86 response.setApexModelKey(null);
87 assertNotEquals(response, otherResponse);
88 otherResponse.setApexModelKey(null);
89 assertEquals(response, otherResponse);
91 response.setEngineServiceKey(engineServiceKey);
92 assertNotEquals(response, otherResponse);
93 otherResponse.setEngineServiceKey(engineServiceKey);
94 assertEquals(response, otherResponse);
95 response.setEngineServiceKey(null);
96 assertNotEquals(response, otherResponse);
97 otherResponse.setEngineServiceKey(null);
98 assertEquals(response, otherResponse);
100 response.setEngineKeyArray(engineKeyArrayList);
101 assertNotEquals(response, otherResponse);
102 otherResponse.setEngineKeyArray(engineKeyArrayList);
103 assertEquals(response, otherResponse);
104 response.setEngineKeyArray(null);
105 assertNotEquals(response, otherResponse);
106 otherResponse.setEngineKeyArray(null);
107 assertEquals(response, otherResponse);