import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCServiceInstanceResourcesTest extends TestDataSetup{
-
- @InjectMocks
+public class SDNCServiceInstanceResourcesTest extends TestDataSetup {
+
+ @InjectMocks
private SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Mock
- protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private Customer customer;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
- serviceInstance = buildServiceInstance();
- customer = buildCustomer();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- }
-
- @Test
- public void assignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void assignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void deleteServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deleteServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void unassignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void unassignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance,customer, requestContext);
- }
+ @Mock
+ protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+ serviceInstance = buildServiceInstance();
+ customer = buildCustomer();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
+
+ @Test
+ public void assignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void assignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deleteServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void deleteServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void unassignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void unassignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deactivateServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
- @Test
- public void deactivateServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deactivateServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- }
+ @Test
+ public void deactivateServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ }
- @Test
- public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
+ @Test
+ public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
}