From ab6a90df6444ef7282fe9de8fe8107641bf7082f Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 28 May 2021 12:29:13 +0100 Subject: Support adding capability types to model Signed-off-by: MichaelMorris Issue-ID: SDC-3612 Change-Id: I5d3713ba420c2392dd232b5651aef4d51560ab4a --- .../impl/CapabilityTypeImportManagerTest.java | 2 +- .../sdc/be/servlets/TypesUploadServletTest.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'catalog-be/src/test/java') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java index 7de4296ffa..a684e21ce1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java @@ -81,7 +81,7 @@ public class CapabilityTypeImportManagerTest { @Test public void testCreateCapabilityTypes() throws IOException { String ymlContent = getCapabilityTypesYml(); - Either>, ResponseFormat> createCapabilityTypes = manager.createCapabilityTypes(ymlContent); + Either>, ResponseFormat> createCapabilityTypes = manager.createCapabilityTypes(ymlContent, "testModel"); assertTrue(createCapabilityTypes.isLeft()); List> capabilityTypesList = createCapabilityTypes.left().value(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java index 214d1a7aba..395bee3755 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java @@ -37,6 +37,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.eclipse.jetty.http.HttpStatus; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.glassfish.jersey.media.multipart.MultiPart; import org.glassfish.jersey.media.multipart.MultiPartFeature; @@ -129,7 +130,7 @@ class TypesUploadServletTest extends JerseyTest { @Test void creatingCapabilityTypeSuccessTest() { final Either>, ResponseFormat> either = Either.left(emptyList()); - when(importManager.createCapabilityTypes(Mockito.anyString())).thenReturn(either); + when(importManager.createCapabilityTypes(Mockito.anyString(), Mockito.isNull())).thenReturn(either); final FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip")); MultiPart multipartEntity = new FormDataMultiPart(); multipartEntity.bodyPart(filePart); @@ -139,6 +140,21 @@ class TypesUploadServletTest extends JerseyTest { assertEquals(HttpStatus.CREATED_201, response.getStatus()); } + + @Test + void creatingCapabilityTypeWithModelSuccessTest() { + final Either>, ResponseFormat> either = Either.left(emptyList()); + when(importManager.createCapabilityTypes(Mockito.anyString(), Mockito.eq("testModel"))).thenReturn(either); + final FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip")); + FormDataMultiPart multipartEntity = new FormDataMultiPart(); + multipartEntity.bodyPart(filePart); + multipartEntity.field("model", "testModel"); + + final Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON) + .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class); + + assertEquals(HttpStatus.CREATED_201, response.getStatus()); + } @Override protected void configureClient(ClientConfig config) { -- cgit 1.2.3-korg