2b082f1b8d837efc9b0b84f7e2144c546a83ca51
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / client / appc / ApplicationControllerClientTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.mso.client.appc;\r
22 \r
23 import static org.junit.Assert.assertEquals;\r
24 \r
25 import java.util.Properties;\r
26 import java.util.UUID;\r
27 \r
28 import org.junit.AfterClass;\r
29 import org.junit.BeforeClass;\r
30 import org.junit.Ignore;\r
31 import org.junit.Test;\r
32 \r
33 import org.openecomp.appc.client.lcm.model.Action;\r
34 import org.openecomp.appc.client.lcm.model.ActionIdentifiers;\r
35 import org.openecomp.appc.client.lcm.model.CheckLockInput;\r
36 import org.openecomp.appc.client.lcm.model.Flags;\r
37 import org.openecomp.appc.client.lcm.model.Status;\r
38 \r
39 public class ApplicationControllerClientTest {\r
40 \r
41         private static ApplicationControllerClient client;\r
42         private static ApplicationControllerSupport support;\r
43 \r
44         @BeforeClass\r
45         public static void beforeClass() {\r
46                 client = new ApplicationControllerClient();\r
47                 support = new ApplicationControllerSupport();\r
48                 client.appCSupport = support;\r
49                 System.setProperty("mso.config.path", "src/test/resources");\r
50 \r
51         }\r
52 \r
53         @AfterClass\r
54         public static void afterClass() throws Exception {\r
55                 client.shutdownclient();\r
56         }\r
57 \r
58         @Test\r
59         @Ignore // IGNORED FOR 1710 MERGE TO ONAP\r
60         public void createRequest_CheckLock_RequestBuilt() throws Exception {\r
61 \r
62                 org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage",\r
63                                 "org.openecomp.appc.client.lcm.model");\r
64                 Flags flags = new Flags();\r
65                 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();\r
66                 actionIdentifiers.setVnfId("vnfId");\r
67                 CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers,\r
68                                 flags, null, "requestId");\r
69                 assertEquals(checkLockInput.getAction().name(), "CheckLock");\r
70         }\r
71 \r
72         @Test\r
73         @Ignore // IGNORED FOR 1710 MERGE TO ONAP\r
74         public void runCommand_liveAppc() throws Exception {\r
75                 org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage",\r
76                                 "org.openecomp.appc.client.lcm.model");\r
77                 Flags flags = new Flags();\r
78                 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();\r
79                 actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");\r
80 \r
81                 // CheckLockInput checkLockInput = (CheckLockInput)\r
82                 // client.createRequest(Action.CheckLock,actionIdentifiers,flags,null,"requestId");\r
83                 Status status = client.runCommand(Action.Lock, actionIdentifiers, flags, null, UUID.randomUUID().toString());\r
84                 assertEquals("Status of run command is correct", status.getCode(), 306);\r
85         }\r
86 \r
87         @Test\r
88         @Ignore // IGNORED FOR 1710 MERGE TO ONAP\r
89         public void runCommand_CheckLock_RequestBuilt() throws Exception {\r
90                 org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage",\r
91                                 "org.openecomp.appc.client.lcm.model");\r
92                 Flags flags = new Flags();\r
93                 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();\r
94                 actionIdentifiers.setVnfId("fusion-vpp-vnf-001");\r
95                 Status status = client.runCommand(Action.CheckLock, actionIdentifiers, flags, null, "requestId");\r
96                 assertEquals("Status of run command is correct", status.getCode(), 400);\r
97         }\r
98 }\r