Remove Camunda auto conf for Junit
[clamp.git] / src / test / java / org / onap / clamp / clds / client / req / SdcPolicyReqTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.client.req;
25
26 import static org.junit.Assert.assertTrue;
27
28 import java.lang.reflect.InvocationTargetException;
29 import java.lang.reflect.Method;
30 import java.util.ArrayList;
31 import java.util.List;
32
33 import org.junit.Test;
34 import org.onap.policy.asdc.Resource;
35 import org.onap.policy.asdc.ResourceType;
36 import org.onap.policy.controlloop.policy.PolicyResult;
37
38 public class SdcPolicyReqTest {
39
40     @Test
41     public void convertToResourceTest() throws NoSuchMethodException, SecurityException, IllegalAccessException,
42             IllegalArgumentException, InvocationTargetException {
43         Method method = OperationalPolicyReq.class.getDeclaredMethod("convertToResource", List.class,
44                 ResourceType.class);
45         method.setAccessible(true);
46         // return method.invoke(targetObject, argObjects);
47         OperationalPolicyReq policyReq = new OperationalPolicyReq();
48         List<String> stringList = new ArrayList<>();
49         stringList.add("test1");
50         stringList.add("test2");
51         stringList.add("test3");
52         stringList.add("test4");
53         Resource resources[] = (Resource[]) method.invoke(policyReq, stringList, ResourceType.VF);
54
55         assertTrue(resources.length == 4);
56         assertTrue("test1".equals(resources[0].getResourceName()));
57         assertTrue("test2".equals(resources[1].getResourceName()));
58         assertTrue("test3".equals(resources[2].getResourceName()));
59         assertTrue("test4".equals(resources[3].getResourceName()));
60     }
61
62     @Test
63     public void convertToPolicyResultTest() throws NoSuchMethodException, SecurityException, IllegalAccessException,
64             IllegalArgumentException, InvocationTargetException {
65         Method method = OperationalPolicyReq.class.getDeclaredMethod("convertToPolicyResult", List.class);
66         method.setAccessible(true);
67         // return method.invoke(targetObject, argObjects);
68         OperationalPolicyReq policyReq = new OperationalPolicyReq();
69         List<String> stringList = new ArrayList<>();
70         stringList.add("FAILURE");
71         stringList.add("SUCCESS");
72         stringList.add("FAILURE_GUARD");
73         stringList.add("FAILURE_TIMEOUT");
74         PolicyResult policyResult[] = (PolicyResult[]) method.invoke(policyReq, stringList);
75
76         assertTrue(policyResult.length == 4);
77         assertTrue(policyResult[0].equals(PolicyResult.FAILURE));
78         assertTrue(policyResult[1].equals(PolicyResult.SUCCESS));
79         assertTrue(policyResult[2].equals(PolicyResult.FAILURE_GUARD));
80         assertTrue(policyResult[3].equals(PolicyResult.FAILURE_TIMEOUT));
81     }
82 }