2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.client.appc;
23 import org.junit.Before;
24 import org.junit.BeforeClass;
25 import org.junit.Ignore;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mock;
30 import org.mockito.junit.MockitoJUnitRunner;
31 import org.onap.appc.client.lcm.model.Action;
32 import org.onap.appc.client.lcm.model.ActionIdentifiers;
33 import org.onap.appc.client.lcm.model.CheckLockInput;
34 import org.onap.appc.client.lcm.model.Status;
35 import org.onap.so.BaseTest;
36 import java.util.Properties;
37 import java.util.UUID;
38 import static org.junit.Assert.assertEquals;
39 import static org.mockito.Mockito.when;
41 @RunWith(MockitoJUnitRunner.class)
42 public class ApplicationControllerClientV2Test {
45 ApplicationControllerSupport applicationControllerSupport;
48 ApplicationControllerConfiguration applicationControllerConfiguration;
51 ApplicationControllerClientV2 client;
56 when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
57 when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
58 when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
59 when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
60 when(applicationControllerConfiguration.getService()).thenReturn("ueb");
61 when(applicationControllerConfiguration.getPoolMembers())
62 .thenReturn("localhost:3904,localhost:3904,localhost:3904");
63 when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
64 when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
65 // client.buildClient();
69 public static void beforeClass() {
70 System.setProperty("mso.config.path", "src/test/resources");
75 public void createRequest_CheckLock_RequestBuilt() {
76 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
77 actionIdentifiers.setVnfId("vnfId");
78 // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
79 CheckLockInput checkLockInput =
80 (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, "requestId");
81 assertEquals(checkLockInput.getAction().name(), "CheckLock");
86 public void runCommand_liveAppc() {
87 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
88 // actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
89 actionIdentifiers.setVnfId("2d2bf10e-81a5-");
91 // when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
92 // when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
94 status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
95 } catch (ApplicationControllerOrchestratorException e) {
96 status = new Status();
97 status.setCode(e.getAppcCode());
98 status.setMessage(e.getMessage());
100 assertEquals("Status of run command is correct", status.getCode(), 306);
105 public void runCommand_CheckLock_RequestBuilt() {
106 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
107 actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
110 status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
111 } catch (ApplicationControllerOrchestratorException e) {
112 status = new Status();
113 status.setCode(e.getAppcCode());
114 status.setMessage(e.getMessage());
116 assertEquals("Status of run command is correct", status.getCode(), 309);
121 public void test_getLCMPropertiesHelper() {
122 Properties properties = client.getLCMProperties("");
123 assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
124 assertEquals(properties.get("topic.read.timeout"), "120000");
125 assertEquals(properties.get("client.response.timeout"), "120000");
126 assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
127 assertEquals(properties.get("poolMembers"), "localhost:3904,localhost:3904,localhost:3904");
128 assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
129 assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");