diff options
Diffstat (limited to 'catalog-be/src/test')
4 files changed, 48 insertions, 18 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index f0b2865373..a453df2563 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -157,7 +157,7 @@ public class ResourceImportManagerTest { // Mockito.verify(log).error(Mockito.anyString(), Mockito.anyString(), // Mockito.anyString()); - Mockito.verify(resourceBusinessLogic, Mockito.times(0)).createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.eq(user), Mockito.eq(true), Mockito.eq(false), Mockito.eq(true)); + Mockito.verify(resourceBusinessLogic, Mockito.times(0)).createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.eq(user), Mockito.eq(true), Mockito.eq(false), Mockito.eq(true), Mockito.eq(null)); Mockito.verify(resourceBusinessLogic, Mockito.times(0)).propagateStateToCertified(Mockito.eq(user), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false)); @@ -182,7 +182,7 @@ public class ResourceImportManagerTest { testSetCapabilities(resource); Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false)); - Mockito.verify(resourceBusinessLogic, Mockito.times(1)).createOrUpdateResourceByImport(resource, user, true, false, true); + Mockito.verify(resourceBusinessLogic, Mockito.times(1)).createOrUpdateResourceByImport(resource, user, true, false, true, null); } @@ -207,7 +207,7 @@ public class ResourceImportManagerTest { private void setResourceBusinessLogicMock() { when(resourceBusinessLogic.getUserAdmin()).thenReturn(userAdmin); - when(resourceBusinessLogic.createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean())) + when(resourceBusinessLogic.createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.eq(null))) .thenAnswer(new Answer<Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat>>() { public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); @@ -230,7 +230,7 @@ public class ResourceImportManagerTest { } }); - when(resourceBusinessLogic.validateResourceBeforeCreate(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.any(AuditingActionEnum.class), Mockito.eq(false))).thenAnswer(new Answer<Either<Resource, ResponseFormat>>() { + when(resourceBusinessLogic.validateResourceBeforeCreate(Mockito.any(Resource.class), Mockito.any(User.class), Mockito.any(AuditingActionEnum.class), Mockito.eq(false), Mockito.eq(null))).thenAnswer(new Answer<Either<Resource, ResponseFormat>>() { public Either<Resource, ResponseFormat> answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return Either.left((Resource) args[0]); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index bbfa8bf236..f3c7a7d24c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1328,7 +1328,7 @@ public class ResourceBusinessLogicTest { Resource resourceToUpdtae = createResourceObject(false); - Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false); + Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null); assertTrue(createOrUpdateResource.isLeft()); Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class)); @@ -1356,7 +1356,7 @@ public class ResourceBusinessLogicTest { Resource resourceToUpdtae = createResourceObject(false); - Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false); + Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null); assertTrue(createOrUpdateResource.isLeft()); Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)); @@ -1374,7 +1374,7 @@ public class ResourceBusinessLogicTest { Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either.right(StorageOperationStatus.NOT_FOUND); when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName())).thenReturn(getLatestToscaNameResult); - Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false); + Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null); assertTrue(createOrUpdateResource.isLeft()); Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java index d41e95da9d..2b33fbd704 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java @@ -20,6 +20,17 @@ package org.openecomp.sdc.be.servlets; +import fj.data.Either; +import org.apache.commons.codec.binary.Base64; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.be.model.UploadResourceInfo; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.common.datastructure.Wrapper; +import org.openecomp.sdc.exception.ResponseFormat; +import org.slf4j.Logger; + +import javax.ws.rs.core.Response; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -27,19 +38,20 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; -import org.apache.commons.codec.binary.Base64; -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.sdc.be.model.UploadResourceInfo; -import org.openecomp.sdc.be.servlets.AbstractValidationsServlet; -import org.openecomp.sdc.exception.ResponseFormat; - -import fj.data.Either; +import java.util.stream.Stream; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; public class AbstractValidationsServletTest { - private static AbstractValidationsServlet servlet = mock(AbstractValidationsServlet.class); + private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() {}; + + private static final String BASIC_TOSCA_TEMPLATE = "tosca_definitions_version: tosca_simple_yaml_%s"; + + @Before + public void setUp() throws Exception { + servlet.initLog(mock(Logger.class)); + } @SuppressWarnings("unchecked") @Test @@ -65,8 +77,23 @@ public class AbstractValidationsServletTest { } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } - Assert.assertTrue(returnValue.isLeft()); + assertTrue(returnValue.isLeft()); Map<String, byte[]> csar = returnValue.left().value(); - Assert.assertTrue(csar != null); + assertTrue(csar != null); + } + + @Test + public void testValidToscaVersion() throws Exception { + Stream.of("1_0", "1_0_0", "1_1", "1_1_0").forEach(this::testValidToscaVersion); } + + + private void testValidToscaVersion(String version) { + Wrapper<Response> responseWrapper = new Wrapper<>(); + servlet.validatePayloadIsTosca(responseWrapper, new UploadResourceInfo(), new User(), String.format(BASIC_TOSCA_TEMPLATE, version)); + assertTrue(responseWrapper.isEmpty()); + } + + + } diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml index 6a94f7268a..8be1322c2c 100644 --- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml @@ -296,6 +296,9 @@ serviceDeploymentArtifacts: YANG_XML: acceptedTypes: - xml + UCPE_LAYER_2_CONFIGURATION: + acceptedTypes: + - xml VNF_CATALOG: acceptedTypes: - xml |