summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-05-28 12:29:13 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-06-14 08:01:13 +0000
commitab6a90df6444ef7282fe9de8fe8107641bf7082f (patch)
tree19f8005ddac7ff4ee6ee8a893384a028f5ff4e44 /catalog-be/src/test/java/org
parent68a8c007e2bb9c1e79357432fbaa0336774327d7 (diff)
Support adding capability types to model
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3612 Change-Id: I5d3713ba420c2392dd232b5651aef4d51560ab4a
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java18
2 files changed, 18 insertions, 2 deletions
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<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> createCapabilityTypes = manager.createCapabilityTypes(ymlContent);
+ Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> createCapabilityTypes = manager.createCapabilityTypes(ymlContent, "testModel");
assertTrue(createCapabilityTypes.isLeft());
List<ImmutablePair<CapabilityTypeDefinition, Boolean>> 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<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, 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<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, 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) {