Search in sources :

Example 1 with ExternalVirtualLink

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink in project so by onap.

the class UserParamInputParametersProviderTest method testGetInputParameter_ValidUserParams_NotEmptyInputParameter.

@Test
public void testGetInputParameter_ValidUserParams_NotEmptyInputParameter() throws Exception {
    final InputParametersProvider<Map<String, Object>> objUnderTest = new UserParamInputParametersProvider();
    final InputParameter actual = objUnderTest.getInputParameter(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINKS_VALUE));
    assertNotNull(actual);
    final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
    assertEquals(3, actualAdditionalParams.size());
    final String actualInstanceType = actualAdditionalParams.get("instance_type");
    assertEquals("m1.small", actualInstanceType);
    final List<ExternalVirtualLink> actualExtVirtualLinks = actual.getExtVirtualLinks();
    assertEquals(1, actualExtVirtualLinks.size());
    final ExternalVirtualLink actualExternalVirtualLink = actualExtVirtualLinks.get(0);
    assertEquals("ac1ed33d-8dc1-4800-8ce8-309b99c38eec", actualExternalVirtualLink.getId());
}
Also used : TestConstants.getUserParamsMap(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap) Map(java.util.Map) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink) Test(org.junit.Test)

Example 2 with ExternalVirtualLink

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink in project so by onap.

the class InputParameterTest method getExternalVirtualLinkList.

private List<ExternalVirtualLink> getExternalVirtualLinkList(final String id) {
    final ExternalVirtualLink externalVirtualLink = new ExternalVirtualLink();
    externalVirtualLink.setId(id);
    final List<ExternalVirtualLink> list = new ArrayList<>();
    list.add(externalVirtualLink);
    return list;
}
Also used : ArrayList(java.util.ArrayList) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink)

Example 3 with ExternalVirtualLink

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink in project so by onap.

the class SdncInputParametersProviderImplTest method assertValues.

private void assertValues(final GenericVnf genericVnf) throws MapperException, BadResponseException, IOException {
    when(mockedSdncClient.get(Mockito.eq(URL))).thenReturn(getReponseAsString(PRE_LOAD_SDNC_RESPONSE));
    final InputParametersProvider<GenericVnf> objUnderTest = new SdncInputParametersProvider(mockedSdncClient);
    final InputParameter actual = objUnderTest.getInputParameter(genericVnf);
    assertNotNull(actual);
    final Map<String, String> actualAdditionalParams = actual.getAdditionalParams();
    assertEquals(3, actualAdditionalParams.size());
    final String actualInstanceType = actualAdditionalParams.get("instance_type");
    assertEquals("m1.small", actualInstanceType);
    final List<ExternalVirtualLink> actualExtVirtualLinks = actual.getExtVirtualLinks();
    assertEquals(1, actualExtVirtualLinks.size());
    final ExternalVirtualLink actualExternalVirtualLink = actualExtVirtualLinks.get(0);
    assertEquals("ac1ed33d-8dc1-4800-8ce8-309b99c38eec", actualExternalVirtualLink.getId());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink)

Example 4 with ExternalVirtualLink

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink in project so by onap.

the class InputParameterRetrieverTaskTest method testGetInputParameters_SdncAndUserParamInputParameterStoredInExecutionContext.

@Test
public void testGetInputParameters_SdncAndUserParamInputParameterStoredInExecutionContext() throws BBObjectNotFoundException {
    final InputParameterRetrieverTask objUnderTest = new InputParameterRetrieverTask(sdncInputParametersProvider, userParamsinputParametersProvider, extractPojosForBB);
    final GeneralBuildingBlock buildingBlock = getGeneralBuildingBlock(getUserParamsMap(ADDITIONAL_PARAMS_VALUE, EXT_VIRTUAL_LINKS_VALUE));
    stubbedxecution.setGeneralBuildingBlock(buildingBlock);
    final InputParameter inputParameter = new InputParameter(getAdditionalParams(), getExternalVirtualLink());
    when(sdncInputParametersProvider.getInputParameter(Mockito.any(GenericVnf.class))).thenReturn(inputParameter);
    when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(new GenericVnf());
    objUnderTest.getInputParameters(stubbedxecution);
    final Object actual = stubbedxecution.getVariable(Constants.INPUT_PARAMETER);
    assertNotNull(actual);
    assertTrue(actual instanceof InputParameter);
    final InputParameter actualInputParameter = (InputParameter) actual;
    final Map<String, String> actualAdditionalParams = actualInputParameter.getAdditionalParams();
    assertEquals(4, actualAdditionalParams.size());
    final String actualInstanceType = actualAdditionalParams.get(INSTANCE_TYPE);
    assertEquals(INSTANCE_TYPE_VALUE_1, actualInstanceType);
    assertEquals(FLAVOR_VALUE, actualAdditionalParams.get(FLAVOR));
    final List<ExternalVirtualLink> actualExtVirtualLinks = actualInputParameter.getExtVirtualLinks();
    assertEquals(2, actualExtVirtualLinks.size());
    final Optional<ExternalVirtualLink> externalVirtualLink0 = actualExtVirtualLinks.stream().filter(extVirtualLink -> EXT_VIRTUAL_LINK_ID.equals(extVirtualLink.getId())).findAny();
    assertTrue(externalVirtualLink0.isPresent());
    assertEquals(EXT_VIRTUAL_LINK_ID, externalVirtualLink0.get().getId());
    final Optional<ExternalVirtualLink> externalVirtualLink1 = actualExtVirtualLinks.stream().filter(extVirtualLink -> RANDOM_EXT_VIRTUAL_LINK_ID.equals(extVirtualLink.getId())).findAny();
    assertTrue(externalVirtualLink1.isPresent());
    assertEquals(RANDOM_EXT_VIRTUAL_LINK_ID, externalVirtualLink1.get().getId());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) EXT_VIRTUAL_LINK_ID(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINK_ID) Arrays(java.util.Arrays) TestConstants.getUserParamsMap(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) InputParameterRetrieverTask(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.InputParameterRetrieverTask) ADDITIONAL_PARAMS_VALUE(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.ADDITIONAL_PARAMS_VALUE) HashMap(java.util.HashMap) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) EXT_VIRTUAL_LINKS_VALUE(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXT_VIRTUAL_LINKS_VALUE) ExternalVirtualLinkCpConfig(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLinkCpConfig) RequiredExecutionVariableExeception(org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception) ExternalVirtualLinkExtCps(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLinkExtCps) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink) Map(java.util.Map) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UUID(java.util.UUID) SDNCClient(org.onap.so.client.sdnc.SDNCClient) Serializable(java.io.Serializable) Mockito(org.mockito.Mockito) List(java.util.List) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Constants(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants) Optional(java.util.Optional) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink) InputParameterRetrieverTask(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.InputParameterRetrieverTask) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 5 with ExternalVirtualLink

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink in project so by onap.

the class AbstractInputParametersProvider method parseExternalVirtualLinks.

protected List<ExternalVirtualLink> parseExternalVirtualLinks(final String extVirtualLinksString) {
    try {
        final ObjectMapper mapper = new ObjectMapper();
        final TypeReference<List<ExternalVirtualLink>> extVirtualLinksStringTypeRef = new TypeReference<List<ExternalVirtualLink>>() {
        };
        return mapper.readValue(extVirtualLinksString, extVirtualLinksStringTypeRef);
    } catch (final Exception exception) {
        LOGGER.error("Unable to parse {} ", EXT_VIRTUAL_LINKS, exception);
    }
    return Collections.emptyList();
}
Also used : List(java.util.List) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ExternalVirtualLink(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ExternalVirtualLink (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.ExternalVirtualLink)5 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 TestConstants.getUserParamsMap (org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getUserParamsMap)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)1