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