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
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.assertFalse;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import java.util.ArrayList;
30 import java.util.List;
32 import org.junit.Test;
33 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
36 * Test the start engine message.
38 public class EngineServiceInfoResponseTest {
42 AxArtifactKey targetKey = new AxArtifactKey("Target:0.0.1");
43 GetEngineServiceInfo request = new GetEngineServiceInfo(targetKey);
45 EngineServiceInfoResponse response = new EngineServiceInfoResponse(targetKey, true, request);
46 assertNotNull(response);
47 response = new EngineServiceInfoResponse(targetKey, true, "Response Data", request);
48 assertNotNull(response);
49 assertEquals("Response Data", response.getMessageData());
51 AxArtifactKey apexModelKey = new AxArtifactKey("Model:0.0.1");
52 response.setApexModelKey(apexModelKey);
53 assertEquals(apexModelKey, response.getApexModelKey());
55 AxArtifactKey engineServiceKey = new AxArtifactKey("EngineService:0.0.1");
56 response.setEngineServiceKey(engineServiceKey);;
57 assertEquals(engineServiceKey, response.getEngineServiceKey());
59 List<AxArtifactKey> engineKeyArrayList = new ArrayList<>();
60 AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
61 engineKeyArrayList.add(engineKey);
62 response.setEngineKeyArray(engineKeyArrayList);
63 assertEquals(engineKeyArrayList.get(0), response.getEngineKeyArray()[0]);
65 response = new EngineServiceInfoResponse(null, false, null);
66 assertTrue(response.hashCode() != 0);
67 response.setApexModelKey(apexModelKey);
68 assertTrue(response.hashCode() != 0);
69 response.setApexModelKey(null);
70 response.setEngineServiceKey(engineServiceKey);;
71 assertTrue(response.hashCode() != 0);
72 response.setEngineServiceKey(null);
73 response.setEngineKeyArray(engineKeyArrayList);
74 assertTrue(response.hashCode() != 0);
75 response.setEngineKeyArray(null);
77 assertTrue(response.equals(response));
78 assertFalse(response.equals(null));
79 assertFalse(response.equals((Object)new StartEngine(new AxArtifactKey())));
81 response = new EngineServiceInfoResponse(null, false, null);
82 EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null);
84 response.setApexModelKey(apexModelKey);
85 assertFalse(response.equals(otherResponse));
86 otherResponse.setApexModelKey(apexModelKey);
87 assertTrue(response.equals(otherResponse));
88 response.setApexModelKey(null);
89 assertFalse(response.equals(otherResponse));
90 otherResponse.setApexModelKey(null);
91 assertTrue(response.equals(otherResponse));
93 response.setEngineServiceKey(engineServiceKey);
94 assertFalse(response.equals(otherResponse));
95 otherResponse.setEngineServiceKey(engineServiceKey);
96 assertTrue(response.equals(otherResponse));
97 response.setEngineServiceKey(null);
98 assertFalse(response.equals(otherResponse));
99 otherResponse.setEngineServiceKey(null);
100 assertTrue(response.equals(otherResponse));
102 response.setEngineKeyArray(engineKeyArrayList);
103 assertFalse(response.equals(otherResponse));
104 otherResponse.setEngineKeyArray(engineKeyArrayList);
105 assertTrue(response.equals(otherResponse));
106 response.setEngineKeyArray(null);
107 assertFalse(response.equals(otherResponse));
108 otherResponse.setEngineKeyArray(null);
109 assertTrue(response.equals(otherResponse));