Create based CSIT test for SO-CNFM - Simulator Changes.
[integration/csit.git] / plans / so / integration-etsi-testing / so-simulators / sdc-simulator / src / test / java / org / onap / so / sdcsimulator / controller / CatalogControllerTest.java
index 57db74c..51b90fa 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Set;
 import java.util.UUID;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.so.sdcsimulator.models.Metadata;
 import org.onap.so.sdcsimulator.models.ResourceAssetInfo;
 import org.onap.so.sdcsimulator.models.ResourceMetadata;
 import org.onap.so.sdcsimulator.models.ServiceAssetInfo;
@@ -80,7 +79,7 @@ public class CatalogControllerTest {
     private UserCredentials userCredentials;
 
     @Test
-    public void test_getCsar_validCsarId_matchContent() {
+    public void test_getResourceCsar_validCsarId_matchContent() {
 
         final String url = getBaseUrl() + "/resources/" + RESOURCE_ID + "/toscaModel";
 
@@ -93,6 +92,20 @@ public class CatalogControllerTest {
 
     }
 
+    @Test
+    public void test_getServiceCsar_validCsarId_matchContent() {
+
+        final String url = getBaseUrl() + "/services/" + SERVICE_ID + "/toscaModel";
+
+        final ResponseEntity<byte[]> response =
+                restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), byte[].class);
+
+        assertEquals(HttpStatus.OK, response.getStatusCode());
+        assertTrue(response.hasBody());
+        assertEquals(147255, response.getBody().length);
+
+    }
+
     @Test
     public void test_getResources_validResourcesFromClassPath() {
 
@@ -102,8 +115,8 @@ public class CatalogControllerTest {
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertTrue(response.hasBody());
-        assertEquals(1, response.getBody().size());
-        assertEquals(SUB_CATEGORY, response.getBody().iterator().next().getSubCategory());
+        assertEquals(2, response.getBody().size());
+        assertTrue(response.getBody().stream().anyMatch(predicate -> SUB_CATEGORY.equals(predicate.getSubCategory())));
 
     }
 
@@ -116,8 +129,9 @@ public class CatalogControllerTest {
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertTrue(response.hasBody());
-        assertEquals(1, response.getBody().size());
-        assertEquals(DISTRIBUTION_STATUS, response.getBody().iterator().next().getDistributionStatus());
+        assertEquals(2, response.getBody().size());
+        assertTrue(response.getBody().stream()
+            .anyMatch(predicate -> DISTRIBUTION_STATUS.equals(predicate.getDistributionStatus())));
 
     }