summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml5
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java44
2 files changed, 49 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
index 33b8aafec1..fc1adc6bbb 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
@@ -128,6 +128,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java
new file mode 100644
index 0000000000..08dcd4ed97
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdcrests.validation.rest.service;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.openecomp.sdc.validation.UploadValidationManager;
+import org.openecomp.sdc.validation.types.ValidationFileResponse;
+import org.openecomp.sdcrests.validation.rest.services.ValidationImpl;
+
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class ValidationImplTest {
+
+ @Mock
+ private UploadValidationManager uploadValidationManager;
+ @InjectMocks
+ private ValidationImpl validation;
+
+ @Before
+ public void setUp(){
+ initMocks(this);
+ }
+
+ @Test
+ public void validateFileTest() throws IOException {
+ when(uploadValidationManager.validateFile(any(), any())).thenReturn(new ValidationFileResponse());
+ Response response = validation.validateFile("", new ByteArrayInputStream("".getBytes()));
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void validateFileExceptionTest() throws IOException {
+ when(uploadValidationManager.validateFile(any(), any())).thenThrow(new IOException());
+ Response response = validation.validateFile("", new ByteArrayInputStream("".getBytes()));
+ }
+}