AT&T 1712 and 1802 release code
[so.git] / common / src / test / java / org / openecomp / mso / client / policy / PolicyClientImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.client.policy;
22
23 import static org.junit.Assert.assertEquals;
24
25 import org.junit.Ignore;
26 import org.junit.Test;
27 import org.openecomp.mso.client.defaultproperties.PolicyRestPropertiesImpl;
28 import org.openecomp.mso.client.policy.entities.Bbid;
29 import org.openecomp.mso.client.policy.entities.DictionaryData;
30 import org.openecomp.mso.client.policy.entities.PolicyDecision;
31 import org.openecomp.mso.client.policy.entities.PolicyServiceType;
32 import org.openecomp.mso.client.policy.entities.Workstep;
33
34 public class PolicyClientImplTest {
35         
36         @Test
37         public void successReadProperties() {
38                 PolicyRestClient client = new PolicyRestClient(new PolicyRestPropertiesImpl(), PolicyServiceType.GET_DECISION);
39                 client.initializeHeaderMap(client.headerMap);
40                 
41                 assertEquals("Found expected Client Auth", client.headerMap.get("ClientAuth"), "Basic bTAzNzQzOnBvbGljeVIwY2sk");
42                 assertEquals("Found expected Authorization", client.headerMap.get("Authorization"), "Basic dGVzdHBkcDphbHBoYTEyMw==");
43                 assertEquals("Found expected Environment", client.headerMap.get("Environment"), "TEST");
44                 assertEquals("Has X-ECOMP-RequestID", client.headerMap.containsKey("X-ECOMP-RequestID"), true);
45         }
46         
47         @Test
48         @Ignore
49         public void getDecisionTest() {
50                 PolicyClient client = new PolicyClientImpl();
51                 PolicyDecision decision = client.getDecision("S", "V", "BB1", "1", "123");
52                 assertEquals("Decision is correct", decision.getDecision(), "PERMIT");
53                 assertEquals("Decision details is correct", decision.getDetails(), "Retry");
54         }
55         
56         @Test
57         @Ignore
58         public void getAllowedTreatmentsTest(){
59                 PolicyClient client = new PolicyClientImpl();
60                 DictionaryData dictClient = client.getAllowedTreatments("BB1", "1");
61                 final String dictBbidString = dictClient.getBbid().getString();
62                 final String dictWorkStepString = dictClient.getWorkstep().getString();
63                 assertEquals("DictionaryData matches a response Bbid", dictBbidString, "BB1");
64                 assertEquals("DicitonaryData matches a response WorkStep", dictWorkStepString, "1");
65         }
66         /*
67         @Test
68         public void getAllowedTreatmentsTest() {
69                 PolicyClient client = new PolicyClientImpl();
70                 AllowedTreatments allowedTreatments = client.getAllowedTreatments("BB1", "1");
71                 int expectedSizeOfList = 4;
72                 int sizeOfList = allowedTreatments.getAllowedTreatments().size();
73                 assertEquals("Decision is correct", sizeOfList, expectedSizeOfList);
74         }*/
75 }