aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTest.java147
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTestWithoutOnap.java74
2 files changed, 220 insertions, 1 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java
index 5e07486..033f3be 100644
--- a/src/test/java/org/onap/nbi/apis/ApiTest.java
+++ b/src/test/java/org/onap/nbi/apis/ApiTest.java
@@ -281,6 +281,30 @@ public class ApiTest {
}
+
+ @Test
+ public void testCheckServiceOrderWithUnknownSverviceSpecId() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.getService().getServiceSpecification().setId("toto");
+ }
+
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("102");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("serviceSpecification.id");
+ }
+ }
+
@Test
public void testCheckServiceOrderWithGenericCustomer() throws Exception {
@@ -337,6 +361,80 @@ public class ApiTest {
}
+ @Test
+ public void testCheckServiceOrderInDeleteWithNoServiceId() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.getService().setId(null);
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("101");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("service.id");
+ }
+ }
+
+ @Test
+ public void testCheckServiceOrderInAddWithServiceId() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.getService().setId("toto");
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("103");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("service.id");
+ }
+ }
+
+ @Test
+ public void testCheckServiceOrderWithUnKnownCustomerInChange() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ List<RelatedParty> customers = new ArrayList<>();
+ RelatedParty customer = new RelatedParty();
+ customer.setId("new");
+ customer.setRole("ONAPcustomer");
+ customer.setName("romain");
+ customers.add(customer);
+ testServiceOrder.setRelatedParty(customers);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0);
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("104");
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getField()).isEqualTo("relatedParty.id");
+ }
+
+
@Test
public void testCheckServiceOrderWithCustomerAAINotResponding() throws Exception {
@@ -360,9 +458,46 @@ public class ApiTest {
ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0);
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("501");
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getMessageInformation()).isEqualTo("Problem with AAI API");
+ }
+
+
+ @Test
+ public void testCheckServiceOrderWithSDCNotResponding() throws Exception {
+
+ removeWireMockMapping("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/metadata");
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ List<RelatedParty> customers = new ArrayList<>();
+ RelatedParty customer = new RelatedParty();
+ customer.setId("new");
+ customer.setRole("ONAPcustomer");
+ customer.setName("romain");
+ customers.add(customer);
+ testServiceOrder.setRelatedParty(customers);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("102");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("serviceSpecification.id");
+ }
}
+
+
@Test
public void testCheckServiceOrderWithPutServiceAAINotResponding() throws Exception {
@@ -423,6 +558,11 @@ public class ApiTest {
ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("106");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("service.id");
+ }
}
@Test
@@ -514,6 +654,13 @@ public class ApiTest {
ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ if(serviceOrderItem.getId().equals("A")) {
+ assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1);
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("102");
+ assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("serviceSpecification.id");
+ }
+ }
}
@Test
diff --git a/src/test/java/org/onap/nbi/apis/ApiTestWithoutOnap.java b/src/test/java/org/onap/nbi/apis/ApiTestWithoutOnap.java
index c37c441..782c39a 100644
--- a/src/test/java/org/onap/nbi/apis/ApiTestWithoutOnap.java
+++ b/src/test/java/org/onap/nbi/apis/ApiTestWithoutOnap.java
@@ -17,11 +17,17 @@ package org.onap.nbi.apis;
import static org.assertj.core.api.Assertions.assertThat;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.nbi.apis.assertions.ServiceOrderAssertions;
+import org.onap.nbi.apis.servicecatalog.ServiceSpecificationResource;
+import org.onap.nbi.apis.serviceinventory.ServiceInventoryResource;
+import org.onap.nbi.apis.serviceorder.ServiceOrderResource;
import org.onap.nbi.apis.serviceorder.model.ActionType;
+import org.onap.nbi.apis.serviceorder.model.RelatedParty;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.onap.nbi.apis.serviceorder.model.StateType;
@@ -30,9 +36,12 @@ import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
import org.onap.nbi.apis.serviceorder.workflow.SOTaskProcessor;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@@ -48,6 +57,15 @@ public class ApiTestWithoutOnap {
@Autowired
SOTaskProcessor SoTaskProcessor;
+ @Autowired
+ ServiceSpecificationResource serviceSpecificationResource;
+
+ @Autowired
+ ServiceInventoryResource serviceInventoryResource;
+
+ @Autowired
+ ServiceOrderResource serviceOrderResource;
+
@After
public void tearsDownUpPort() throws Exception {
executionTaskRepository.deleteAll();
@@ -79,11 +97,65 @@ public class ApiTestWithoutOnap {
for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED);
}
+ assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0);
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("502");
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getMessageInformation()).isEqualTo("Problem with SO API");
assertThat(executionTaskRepository.count()).isEqualTo(0);
}
+ @Test
+ public void testCheckServiceOrderWithSDCNotResponding() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ List<RelatedParty> customers = new ArrayList<>();
+ RelatedParty customer = new RelatedParty();
+ customer.setId("new");
+ customer.setRole("ONAPcustomer");
+ customer.setName("romain");
+ customers.add(customer);
+ testServiceOrder.setRelatedParty(customers);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0);
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("500");
+ assertThat(serviceOrderChecked.getOrderMessage().get(0).getMessageInformation()).isEqualTo("Problem with SDC API");
+ }
+
+
+
+ @Test
+ public void testServiceCatalogGetResource() throws Exception {
+
+ ResponseEntity<Object> resource = serviceSpecificationResource
+ .getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439", null);
+ assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
+
+
+ }
+
+
+
+ @Test
+ public void testServiceResourceGetInventory() throws Exception {
+
+ String serviceName = "vFW";
+ String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb";
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.name", serviceName);
+ params.add("relatedParty.id", "6490");
+ ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+ assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
+
+ }