summaryrefslogtreecommitdiffstats
path: root/ms/vlantag-api/src/test
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dt5972@att.com>2018-08-22 10:10:11 -0400
committerTimoney, Dan (dt5972) <dt5972@att.com>2018-08-22 10:28:30 -0400
commit653f403e13d4014b3f80fc8bf5302866110e2202 (patch)
treef409c944dfd527fe08686389e81b24dc0b3b3f79 /ms/vlantag-api/src/test
parent5f42348ebe74480176214266548173388e7fe8cb (diff)
Revert "Add VlantagApi Functional Component"
This reverts commit 822c98964b0a4f7b4da5dbe79669e54011a0778d. This contains no jUnit test cases, bringing code coverage from 71% to 37%. Change-Id: If748dd23e9b4eddd227f01e0b33d2aa9bcb88102 Issue-ID: CCSDK-475 Signed-off-by: Timoney, Dan (dt5972) <dt5972@att.com>
Diffstat (limited to 'ms/vlantag-api/src/test')
-rw-r--r--ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/service/TestVlantagApiServiceImpl.java931
-rw-r--r--ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/util/MockResourceAllocator.java50
2 files changed, 0 insertions, 981 deletions
diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/service/TestVlantagApiServiceImpl.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/service/TestVlantagApiServiceImpl.java
deleted file mode 100644
index c4c9f35f..00000000
--- a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/service/TestVlantagApiServiceImpl.java
+++ /dev/null
@@ -1,931 +0,0 @@
-/*******************************************************************************
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-
-package org.onap.ccsdk.apps.ms.vlantagapi.core.service;
-
-import static org.mockito.ArgumentMatchers.any;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mockito;
-import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.exception.VlantagApiException;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.extinf.pm.model.AllowedRanges;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.extinf.pm.model.Elements;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.extinf.pm.model.PolicyEngineResponse;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.extinf.pm.model.ResourceModel;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.AssignVlanTagRequest;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.AssignVlanTagRequestInput;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.AssignVlanTagResponse;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.PingResponse;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.UnassignVlanTagRequest;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.UnassignVlanTagRequestInput;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.model.UnassignVlanTagResponse;
-import org.onap.ccsdk.apps.ms.vlantagapi.core.service.VlantagApiServiceImpl;
-import org.onap.ccsdk.apps.ms.vlantagapi.extinf.pm.PolicyManagerClient;
-import org.onap.ccsdk.apps.ms.vlantagapi.util.MockResourceAllocator;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
-import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class TestVlantagApiServiceImpl {
-private static final Logger log = LoggerFactory.getLogger(TestVlantagApiServiceImpl.class);
-
- VlantagApiServiceImpl service;
- @InjectMocks
- VlantagApiServiceImpl serviceSpy;
-
- @Spy
- private PolicyManagerClient policyEngineSpy;
-
- @Spy
- protected static MockResourceAllocator mockRA2;
-
-
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Before
- public void setup() throws Exception {
- service = new VlantagApiServiceImpl();
-
- PolicyEngineResponse peResponse = new PolicyEngineResponse();
- peResponse.setConfig("{\"riskLevel\":\"4\",\"riskType\":\"test\",\"policyName\":\"Internet_VlanTag_1810_US_VPE\",\"service\":\"vlantagResourceModel\",\"guard\":\"False\",\"description\":\"Internet_VlanTag_1810_US_VPE\",\"templateVersion\":\"1607\",\"priority\":\"4\",\"version\":\"20180709\",\"content\":{\"policy-instance-name\":\"Internet_VlanTag_1810_US_VPE\",\"resource-models\":[{\"data-store\":\"FALSE\",\"elements\":[{\"allowed-range\":[{\"min\":\"3553\",\"max\":\"3562\"}],\"recycle-vlantag-range\":\"TRUE\",\"overwrite\":\"FALSE\",\"vlantag-name\":\"VPE-Cust\"}],\"scope\":\"SITE\",\"vlan-type\":\"vlan-id-outer\",\"resource-resolution-recipe\":\"#BSB# VPE-Cust #ESB#\",\"resource-vlan-role\":\"outer-tag\"},{\"data-store\":\"TRUE\",\"elements\":[{\"allowed-range\":[{\"min\":\"3503\",\"max\":\"3503\"}],\"element-vlan-role\":\"outer-tag\",\"recycle-vlantag-range\":\"TRUE\",\"overwrite\":\"FALSE\",\"vlantag-name\":\"VPE-Cust-Outer\"},{\"allowed-range\":[{\"min\":\"4001\",\"max\":\"4012\"}],\"element-vlan-role\":\"outer-tag\",\"recycle-vlantag-range\":\"TRUE\",\"overwrite\":\"FALSE\",\"vlantag-name\":\"VPE-Core1\"},{\"allowed-range\":[{\"min\":\"4001\",\"max\":\"4012\"}],\"element-vlan-role\":\"outer-tag\",\"recycle-vlantag-range\":\"TRUE\",\"overwrite\":\"FALSE\",\"vlantag-name\":\"VPE-Core2\"}],\"scope\":\"SITE\",\"vlan-type\":\"vlan-id-filter\",\"resource-resolution-recipe\":\"#BSB# VPE-Cust-Outer, VPE-Core1, VPE-Core2 #ESB#\"}]}}");
- PolicyEngineResponse[] peResponses = new PolicyEngineResponse[1];
- peResponses[0] = peResponse;
-
- Mockito.doReturn(peResponses).when(policyEngineSpy).getConfigUsingPost(any());
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_assign_sucess_001() throws Exception {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
- input.setScopeId("some-scope-id");
- input.setKey("some-key");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
- request.setInput(inputs);
-
- //PowerMockito.doReturn(mockStatus.Success).when(mockRA).reserve(any(), any(), any(), any());
- AssignVlanTagResponse response = serviceSpy.assignVlanTag(request);
-
- StrUtil.info(log, response);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_unassign_sucess_001() throws Exception {
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
- input.setKey("some-key");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- List<UnassignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
- request.setInput(inputs);
-
- //Mockito.doReturn(AllocationStatus.Success).when(mockRA).release(any(), any());
-
-
- UnassignVlanTagResponse response = serviceSpy.unassignVlanTag(request);
-
- StrUtil.info(log, response);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_ping_sucess_001() throws Exception {
- PingResponse response = serviceSpy.getPing("Vlantag API Service");
-
- StrUtil.info(log, response);
- Assert.assertTrue(response.getMessage().contains("Ping response : Vlantag API Service Time : "));
- }
-
-
- @Test
- public void test_resolveRecipe_001() {
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, #BSB# VPE-Core2 #ESB#, VPE-Core3 #ESB#");
- //model.setResourceResolutionRecipe("[ VPE-Core1, [ VPE-Core2 ], VPE-Core3 ]");
-
- List<ResourceResponse> rl = new ArrayList<>();
- ResourceResponse response = new ResourceResponse();
- response.endPointPosition = "VPE-Core1";
- response.resourceAllocated="3901";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core2";
- response.resourceAllocated="3902";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core3";
- response.resourceAllocated="3903";
-
- rl.add(response);
-
- service.resolveRecipe(model, rl);
-
- }
-
- @Test
- public void test_resolveResourceElementValue_001() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123, 123, 234 ]");
- input.setScopeId("scope-id");
- input.setVlanType("vlan-type");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- //model.setResourceResolutionRecipe("[ VPE-Core1, [ VPE-Core2 ], VPE-Core3 ]");
-
- List<ResourceResponse> rl = new ArrayList<>();
- ResourceResponse response = new ResourceResponse();
- response.endPointPosition = "VPE-Core1";
- response.resourceAllocated="3901";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core2";
- response.resourceAllocated="3902";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core3";
- response.resourceAllocated="3903";
-
- rl.add(response);
-
- String resourceValue = service.resolveResourceElementValue(input, model, element);
-
- Assert.assertTrue(resourceValue.equals("123"));
- }
-
- @Test(expected = VlantagApiException.class)
- public void test_resolveResourceElementValue_002() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
- input.setVlanType("vlan-type");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- //model.setResourceResolutionRecipe("[ VPE-Core1, [ VPE-Core2 ], VPE-Core3 ]");
-
- List<ResourceResponse> rl = new ArrayList<>();
- ResourceResponse response = new ResourceResponse();
- response.endPointPosition = "VPE-Core1";
- response.resourceAllocated="3901";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core2";
- response.resourceAllocated="3902";
-
- rl.add(response);
-
- response = new ResourceResponse();
- response.endPointPosition = "VPE-Core3";
- response.resourceAllocated="3903";
-
- rl.add(response);
-
- service.resolveResourceElementValue(input, model, element);
- }
-
-
- @Test
- public void test_validateElements_assign_vlantagName_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Vlantag Name missing for Element in Resource Model Policy for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123, 123, 234 ]");
- input.setScopeId("scope-id");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- service.validateElements(elements, input);
-
- }
-
- @Test
- public void test_validateElements_assign_allowedRanges_002() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Allowed Ranges missing for Element in Resource Model Policy for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123, 123, 234 ]");
- input.setScopeId("scope-id");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- service.validateElements(elements, input);
-
- }
-
- @Test
- public void test_validateElements_assign_vlantagElements_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Vlantag Elements found in Resource Model Policy for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123, 123, 234 ]");
- input.setScopeId("scope-id");
-
- List<Elements> elements = new ArrayList<>();
-
- service.validateElements(elements, input);
-
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateElements_assign_Success_004() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123, 123, 234 ]");
- input.setScopeId("scope-id");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- service.validateElements(elements, input);
-
- }
-
- @Test
- public void test_validateElements_unassign_vlantagName_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Vlantag Name missing for Element in Resource Model Policy for Vlan Type : vlan-id-outer");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- service.validateElements(elements, input);
-
- }
-
- @Test
- public void test_validateElements_unassign_vlantagElements_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Vlantag Elements found in Resource Model Policy for Vlan Type : vlan-id-outer");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
-
- List<Elements> elements = new ArrayList<>();
-
- service.validateElements(elements, input);
-
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateElements_unassign_Success_004() throws VlantagApiException {
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- service.validateElements(elements, input);
-
- }
-
- @Test
- public void test_validateModel_assign_resourceModel_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Matching Policy Resource Model found for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
-
- service.validateModel(null, input);
- }
-
- @Test
- public void test_validateModel_assign_resolutionRecipe_002() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Resource Resolution Recipe is null in Resource Model for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
-
- service.validateModel(model, input);
- }
-
- @Test
- public void test_validateModel_assign_scope_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Scope is null in Resource Model for Vlan Type : vlan-id-outer");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
-
- service.validateModel(model, input);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateModel_assign_success_004() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- model.setScope("VPE");
- model.setElements(elements);
-
- service.validateModel(model, input);
- }
-
- @Test
- public void test_validateModel_unassign_resourceModel_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Matching Policy Resource Model found for Vlan Type : vlan-id-outer");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- service.validateModel(null, input);
- }
-
- @Test
- public void test_validateModel_unassign_resolutionRecipe_002() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Resource Resolution Recipe is null in Resource Model for Vlan Type : vlan-id-outer");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
-
- service.validateModel(model, input);
- }
-
- @Test
- public void test_validateModel_unassign_scope_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("Scope is null in Resource Model for Vlan Type : vlan-id-outer");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
-
- service.validateModel(model, input);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateModel_unassign_success_004() throws VlantagApiException {
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance-name");
- input.setVlanType("vlan-id-outer");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-inner");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- model.setScope("VPE");
- model.setElements(elements);
-
- service.validateModel(model, input);
- }
-
- @Test
- public void test_validateRequest_assign_request_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request is null.");
-
- AssignVlanTagRequest request = null;
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_assign_requestInput_002() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request Input is null or empty.");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_assign_policyInstanceName_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request policy-instance-name is null.");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
- input.setVlanType("vlan-type");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_assign_resourceName_004() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request vlan-type is null.");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance");
- input.setResourceValue("[ 123]");
- input.setScopeId("scope-id");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_assign_scopeId_005() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request scope-id is null.");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
- input.setResourceValue("[ 123]");
- input.setVlanType("vlan-type");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_assign_resourceKey_006() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Assign Request key is null.");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
- input.setScopeId("scope-id");
- input.setResourceValue("[ 123]");
- input.setVlanType("vlan-type");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateRequest_assign_success_007() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
- input.setScopeId("scope-id");
- input.setResourceValue("[ 123]");
- input.setVlanType("vlan-type");
- input.setKey("some-key");
-
- AssignVlanTagRequest request = new AssignVlanTagRequest();
- List<AssignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
-
- @Test
- public void test_validateRequest_unassign_request_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Unassign Request is null.");
-
- UnassignVlanTagRequest request = null;
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_unassign_requestInput_002() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Unassign Request Input is null or empty.");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_unassign_policyInstanceName_003() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Unassign Request policy-instance-name is null.");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setVlanType("vlan-id-outer");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- List<UnassignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validateRequest_unassign_resourceName_004() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Unassign Request resource-name is null.");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- List<UnassignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
-
- @Test
- public void test_validateRequest_unassign_resourceKey_005() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("VlanTag Unassign Request key is null.");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- List<UnassignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validateRequest_unassign_success_006() throws VlantagApiException {
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setKey("some-key");
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- UnassignVlanTagRequest request = new UnassignVlanTagRequest();
- List<UnassignVlanTagRequestInput> inputs = new ArrayList<>();
- inputs.add(input);
-
- request.setInput(inputs);
-
- service.validateRequest(request);
- }
-
- @Test
- public void test_validate_assign_failure_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Resource Models available in Policy Manager for Policy Instance Name : some-policy-instance");
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- List<ResourceModel> resourceModels = new ArrayList<>();
-
- service.validate(resourceModels, input);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validate_assign_sucess_002() throws VlantagApiException {
-
- AssignVlanTagRequestInput input = new AssignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-outer");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- model.setScope("VPE");
- model.setElements(elements);
-
- List<ResourceModel> resourceModels = new ArrayList<>();
- resourceModels.add(model);
-
-
- service.validate(resourceModels, input);
- }
-
- @Test
- public void test_validate_unassign_failure_001() throws VlantagApiException {
-
- expectedEx.expect(VlantagApiException.class);
- expectedEx.expectMessage("No Resource Models available in Policy Manager for Policy Instance Name : some-policy-instance");
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- List<ResourceModel> resourceModels = new ArrayList<>();
-
- service.validate(resourceModels, input);
- }
-
- @Test(expected = Test.None.class /* no exception expected */)
- public void test_validate_unassign_sucess_002() throws VlantagApiException {
-
- UnassignVlanTagRequestInput input = new UnassignVlanTagRequestInput();
- input.setPolicyInstanceName("some-policy-instance");
- input.setVlanType("vlan-id-outer");
-
- Elements element = new Elements();
- element.setElementVlanRole("element-vlan-role");
- element.setOverwrite("FALSE");
- element.setRecycleVlantagRange("TRUE");
- element.setVlantagName("VPE-Core2");
-
- List<AllowedRanges> allowedRanges = new ArrayList<>();
- AllowedRanges range = new AllowedRanges();
- range.setMin("200");
- range.setMax("300");
- allowedRanges.add(range );
- element.setAllowedRanges(allowedRanges);
-
- List<Elements> elements = new ArrayList<>();
- elements.add(element);
-
- ResourceModel model = new ResourceModel();
- model.setVlanType("vlan-id-outer");
- model.setResourceResolutionRecipe("#BSB# VPE-Core1, VPE-Core2, VPE-Core3 #ESB#");
- model.setScope("VPE");
- model.setElements(elements);
-
- List<ResourceModel> resourceModels = new ArrayList<>();
- resourceModels.add(model);
-
-
- service.validate(resourceModels, input);
- }
-
- @Test(expected = VlantagApiException.class)
- public void testGetPolicyFromPDPFailure() throws Exception {
- Mockito.doThrow(new VlantagApiException()).when(policyEngineSpy).getConfigUsingPost(any());
- policyEngineSpy.getPolicyFromPDP("sonme_random_policy_name");
- }
-}
diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/util/MockResourceAllocator.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/util/MockResourceAllocator.java
deleted file mode 100644
index 25ef60f1..00000000
--- a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/util/MockResourceAllocator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-
-package org.onap.ccsdk.apps.ms.vlantagapi.util;
-
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MockResourceAllocator extends ResourceAllocator{
- protected static final Logger logger = LoggerFactory.getLogger(MockResourceAllocator.class);
-
- public AllocationStatus reserve(ResourceEntity sd, ResourceTarget rt, ResourceRequest rr,
- List<ResourceResponse> rsList) throws Exception {
-
-
- ResourceResponse rres = new ResourceResponse();
- rres.endPointPosition = "VPE-Core1";
- rres.resourceAllocated = "2001";
- rres.resourceName="vlan-id-outer";
-
- rsList.add(rres);
-
- return AllocationStatus.Success;
- }
-
- public AllocationStatus release(ResourceEntity sd, ResourceRequest rr) throws Exception {
- return AllocationStatus.Success;
- }
-}