Fixing project and owning entity relationship endpoints
[integration/csit.git] / plans / so / integration-etsi-testing / so-simulators / aai-simulator / src / test / java / org / onap / so / aaisimulator / controller / PlatformControllerTest.java
index 754c7eb..331d972 100644 (file)
@@ -24,7 +24,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
+import static org.onap.so.aaisimulator.utils.TestConstants.GENERIC_VNF_URL;
 import static org.onap.so.aaisimulator.utils.TestConstants.PLATFORM_NAME;
+import static org.onap.so.aaisimulator.utils.TestConstants.VNF_ID;
 import java.util.List;
 import java.util.Optional;
 import org.junit.After;
@@ -33,6 +35,8 @@ import org.onap.aai.domain.yang.Platform;
 import org.onap.aai.domain.yang.RelatedToProperty;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.so.aaisimulator.models.Format;
+import org.onap.so.aaisimulator.models.Results;
 import org.onap.so.aaisimulator.service.providers.PlatformCacheServiceProvider;
 import org.onap.so.aaisimulator.utils.Constants;
 import org.onap.so.aaisimulator.utils.TestConstants;
@@ -74,6 +78,28 @@ public class PlatformControllerTest extends AbstractSpringBootTest {
 
     }
 
+    @Test
+    public void test_getPlatformWithFormatCount() throws Exception {
+
+        final String platformUrl = getUrl(Constants.PLATFORMS_URL, PLATFORM_NAME);
+
+        final ResponseEntity<Void> platformResponse =
+                testRestTemplateService.invokeHttpPut(platformUrl, TestUtils.getPlatform(), Void.class);
+        assertEquals(HttpStatus.ACCEPTED, platformResponse.getStatusCode());
+
+        final ResponseEntity<Results> response = testRestTemplateService.invokeHttpGet(
+                platformUrl + "?resultIndex=0&resultSize=1&format=" + Format.COUNT.getValue(), Results.class);
+        assertEquals(HttpStatus.OK, response.getStatusCode());
+
+        assertTrue(response.hasBody());
+
+        final Results result = response.getBody();
+        assertNotNull(result.getValues());
+        assertFalse(result.getValues().isEmpty());
+        assertEquals(1, result.getValues().get(0).get(Constants.PLATFORM));
+
+    }
+
     @Test
     public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
 
@@ -99,6 +125,7 @@ public class PlatformControllerTest extends AbstractSpringBootTest {
         assertFalse("Relationship list should not be empty", relationshipList.isEmpty());
         final Relationship relationship = relationshipList.get(0);
 
+        assertEquals(GENERIC_VNF_URL + VNF_ID, relationship.getRelatedLink());
         assertFalse("RelationshipData list should not be empty", relationship.getRelationshipData().isEmpty());
         assertFalse("RelatedToProperty list should not be empty", relationship.getRelatedToProperty().isEmpty());