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.runners.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;
37 import java.util.Properties;
38 import java.util.UUID;
40 import static org.junit.Assert.assertEquals;
41 import static org.mockito.Mockito.when;
43 @RunWith(MockitoJUnitRunner.class)
44 public class ApplicationControllerClientV2Test {
47 ApplicationControllerSupport applicationControllerSupport;
50 ApplicationControllerConfiguration applicationControllerConfiguration;
53 ApplicationControllerClientV2 client;
58 when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
59 when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
60 when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
61 when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
62 when(applicationControllerConfiguration.getService()).thenReturn("ueb");
63 when(applicationControllerConfiguration.getPoolMembers()).thenReturn("localhost:3904,localhost:3904,localhost:3904");
64 when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
65 when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
66 //client.buildClient();
69 public static void beforeClass() {
70 System.setProperty("mso.config.path", "src/test/resources");
74 public void createRequest_CheckLock_RequestBuilt() {
75 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
76 actionIdentifiers.setVnfId("vnfId");
77 // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
78 CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null,
80 assertEquals(checkLockInput.getAction().name(), "CheckLock");
84 public void runCommand_liveAppc() {
85 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
86 //actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
87 actionIdentifiers.setVnfId("2d2bf10e-81a5-");
89 //when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
90 //when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
92 status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
93 } catch (ApplicationControllerOrchestratorException e) {
94 status = new Status();
95 status.setCode(e.getAppcCode());
96 status.setMessage(e.getMessage());
98 assertEquals("Status of run command is correct", status.getCode(), 306);
103 public void runCommand_CheckLock_RequestBuilt() {
104 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
105 actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
108 status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
109 } catch (ApplicationControllerOrchestratorException e) {
110 status = new Status();
111 status.setCode(e.getAppcCode());
112 status.setMessage(e.getMessage());
114 assertEquals("Status of run command is correct", status.getCode(), 309);
119 public void test_getLCMPropertiesHelper() {
120 Properties properties = client.getLCMProperties("");
121 assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
122 assertEquals(properties.get("topic.read.timeout"), "120000");
123 assertEquals(properties.get("client.response.timeout"), "120000");
124 assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
125 assertEquals(properties.get("poolMembers"),
126 "localhost:3904,localhost:3904,localhost:3904");
127 assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
128 assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");