Merge "Complement sims configuration files"
[transportpce.git] / servicehandler / src / test / java / org / opendaylight / transportpce / servicehandler / service / PCEServiceWrapperTest.java
index 505eb1c1ebae59ecc9fbb98cfbcb4d76630d354b..30f8bb9e55a1a33f8a058dac0de08d706949c49c 100644 (file)
@@ -7,38 +7,39 @@
  */
 package org.opendaylight.transportpce.servicehandler.service;
 
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
 
 import com.google.common.util.concurrent.ListenableFuture;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.CancelResourceReserveOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceNotificationTypes;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
 
+@ExtendWith(MockitoExtension.class)
 public class PCEServiceWrapperTest extends AbstractTest {
 
     @Mock
@@ -48,118 +49,98 @@ public class PCEServiceWrapperTest extends AbstractTest {
     @InjectMocks
     private PCEServiceWrapper pceServiceWrapperMock;
 
-    @Before
-    public void init() throws NoSuchMethodException {
-        MockitoAnnotations.initMocks(this);
-    }
 
     @Test
-    public void performPCENullSdncRequestHeader() {
+    void performPCENullSdncRequestHeader() {
         ServiceCreateInput input =  ServiceDataUtils.buildServiceCreateInput();
         input = new ServiceCreateInputBuilder(input).setSdncRequestHeader(null).build();
         PathComputationRequestOutput pceResponse = this.pceServiceWrapperMock.performPCE(input, true);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_YES,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        verifyZeroInteractions(this.pathComputationServiceMock);
+        assertEquals(ResponseCodes.FINAL_ACK_YES, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_FAILED, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        verifyNoInteractions(this.pathComputationServiceMock);
     }
 
     @Test
-    public void performPCENullServiceName() {
+    void performPCENullServiceName() {
         ServiceCreateInput input = ServiceDataUtils.buildServiceCreateInput();
         input = new ServiceCreateInputBuilder(input).setServiceName(null).build();
         PathComputationRequestOutput pceResponse = this.pceServiceWrapperMock.performPCE(input, true);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_YES,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        verifyZeroInteractions(this.pathComputationServiceMock);
+        assertEquals(ResponseCodes.FINAL_ACK_YES, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_FAILED, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        verifyNoInteractions(this.pathComputationServiceMock);
     }
 
     @Test
-    public void performPCENullCommonId() {
+    void performPCENullCommonId() {
         TempServiceCreateInput input = ServiceDataUtils.buildTempServiceCreateInput();
         input = new TempServiceCreateInputBuilder(input).setCommonId(null).build();
         PathComputationRequestOutput pceResponse = this.pceServiceWrapperMock.performPCE(input, true);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_YES,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        verifyZeroInteractions(this.pathComputationServiceMock);
+        assertEquals(ResponseCodes.FINAL_ACK_YES, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_FAILED, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        verifyNoInteractions(this.pathComputationServiceMock);
     }
 
 
     @Test
-    public void cancelPCEResourceNullServiceName() {
+    void cancelPCEResourceNullServiceName() {
         CancelResourceReserveOutput pceResponse =
                 this.pceServiceWrapperMock.cancelPCEResource(null, ServiceNotificationTypes.ServiceDeleteResult);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_YES,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        verifyZeroInteractions(this.pathComputationServiceMock);
+        assertEquals(ResponseCodes.FINAL_ACK_YES, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_FAILED, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        verifyNoInteractions(this.pathComputationServiceMock);
     }
 
     @Test
-    public void cancelPCEResourceValid() {
+    void cancelPCEResourceValid() {
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setRequestId("request 1").setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO)
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
         CancelResourceReserveOutput output = new CancelResourceReserveOutputBuilder()
                 .setConfigurationResponseCommon(configurationResponseCommon).build();
         ListenableFuture<CancelResourceReserveOutput> response = ServiceDataUtils.returnFuture(output);
-        Mockito.when(this.pathComputationServiceMock.cancelResourceReserve(any(CancelResourceReserveInput.class)))
-                .thenReturn(response);
-        CancelResourceReserveOutput pceResponse =
-                this.pceServiceWrapperMock.cancelPCEResource("service 1", ServiceNotificationTypes.ServiceDeleteResult);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_NO,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_OK,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        Assert.assertEquals("PCE calculation in progress",
-                pceResponse.getConfigurationResponseCommon().getResponseMessage());
+        when(this.pathComputationServiceMock.cancelResourceReserve(any(CancelResourceReserveInput.class)))
+            .thenReturn(response);
+        CancelResourceReserveOutput pceResponse = this.pceServiceWrapperMock
+            .cancelPCEResource("service 1", ServiceNotificationTypes.ServiceDeleteResult);
+        assertEquals(ResponseCodes.FINAL_ACK_NO, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_OK, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        assertEquals("PCE calculation in progress", pceResponse.getConfigurationResponseCommon().getResponseMessage());
         verify(this.pathComputationServiceMock).cancelResourceReserve(any(CancelResourceReserveInput.class));
     }
 
     @Test
-    public void performPCEValid() {
+    void performPCEValid() {
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setRequestId("request 1").setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO)
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
         PathComputationRequestOutput output = new PathComputationRequestOutputBuilder()
                 .setConfigurationResponseCommon(configurationResponseCommon).build();
         ListenableFuture<PathComputationRequestOutput> response = ServiceDataUtils.returnFuture(output);
-        Mockito.when(this.pathComputationServiceMock.pathComputationRequest(any(PathComputationRequestInput.class)))
-                .thenReturn(response);
+        when(this.pathComputationServiceMock.pathComputationRequest(any(PathComputationRequestInput.class)))
+            .thenReturn(response);
         ServiceCreateInput input =  ServiceDataUtils.buildServiceCreateInput();
         PathComputationRequestOutput pceResponse = this.pceServiceWrapperMock.performPCE(input, true);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_NO,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_OK,
-                pceResponse.getConfigurationResponseCommon().getResponseCode());
-        Assert.assertEquals("PCE calculation in progress",
-                pceResponse.getConfigurationResponseCommon().getResponseMessage());
+        assertEquals(ResponseCodes.FINAL_ACK_NO, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_OK, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        assertEquals("PCE calculation in progress", pceResponse.getConfigurationResponseCommon().getResponseMessage());
         verify(this.pathComputationServiceMock).pathComputationRequest((any(PathComputationRequestInput.class)));
     }
 
     @Test
-    public void performPCETempValid() {
+    void performPCETempValid() {
         ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder()
                 .setRequestId("request 1").setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO)
                 .setResponseCode(ResponseCodes.RESPONSE_OK).setResponseMessage("PCE calculation in progress").build();
         PathComputationRequestOutput output = new PathComputationRequestOutputBuilder()
                 .setConfigurationResponseCommon(configurationResponseCommon).build();
         ListenableFuture<PathComputationRequestOutput> response = ServiceDataUtils.returnFuture(output);
-        Mockito.when(this.pathComputationServiceMock.pathComputationRequest(any(PathComputationRequestInput.class)))
-                .thenReturn(response);
+        when(this.pathComputationServiceMock.pathComputationRequest(any(PathComputationRequestInput.class)))
+            .thenReturn(response);
         TempServiceCreateInput input = ServiceDataUtils.buildTempServiceCreateInput();
         PathComputationRequestOutput pceResponse = this.pceServiceWrapperMock.performPCE(input, true);
-        Assert.assertEquals(ResponseCodes.FINAL_ACK_NO,
-                pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
-        Assert.assertEquals(ResponseCodes.RESPONSE_OK, pceResponse.getConfigurationResponseCommon().getResponseCode());
-        Assert.assertEquals("PCE calculation in progress",
-                pceResponse.getConfigurationResponseCommon().getResponseMessage());
+        assertEquals(ResponseCodes.FINAL_ACK_NO, pceResponse.getConfigurationResponseCommon().getAckFinalIndicator());
+        assertEquals(ResponseCodes.RESPONSE_OK, pceResponse.getConfigurationResponseCommon().getResponseCode());
+        assertEquals("PCE calculation in progress", pceResponse.getConfigurationResponseCommon().getResponseMessage());
         verify(this.pathComputationServiceMock).pathComputationRequest((any(PathComputationRequestInput.class)));
     }
-}
+}
\ No newline at end of file