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.openecomp.mso.client.policy;
23 import static org.junit.Assert.assertEquals;
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;
34 public class PolicyClientImplTest {
37 public void successReadProperties() {
38 PolicyRestClient client = new PolicyRestClient(new PolicyRestPropertiesImpl(), PolicyServiceType.GET_DECISION);
39 client.initializeHeaderMap(client.headerMap);
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);
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");
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");
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);