X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Fservice%2FRendererServiceWrapperTest.java;h=4d9fe0650d1e69728ab8b2a3f5e0de3e7edc0db8;hb=d4ddb9037a2615f931d30b671bc40c8ab1645e5d;hp=c18e24bf285f4f102e3709651ed8d898ac285d58;hpb=45de2604acea011072a5478eaead6ffb96e1e6ea;p=transportpce.git diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/RendererServiceWrapperTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/RendererServiceWrapperTest.java index c18e24bf2..4d9fe0650 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/RendererServiceWrapperTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/service/RendererServiceWrapperTest.java @@ -9,10 +9,9 @@ package org.opendaylight.transportpce.servicehandler.service; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; import com.google.common.util.concurrent.ListenableFuture; - +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -27,15 +26,15 @@ import org.opendaylight.transportpce.servicehandler.ModelMappingUtils; import org.opendaylight.transportpce.servicehandler.ServiceInput; import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils; import org.opendaylight.transportpce.test.AbstractTest; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutputBuilder; -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.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommon; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.configuration.response.common.ConfigurationResponseCommonBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempServiceDeleteInputBuilder; /** * Test RendererServiceWrapper class. @@ -51,41 +50,43 @@ public class RendererServiceWrapperTest extends AbstractTest { @InjectMocks private RendererServiceWrapper rendererServiceWrapperMock; + private AutoCloseable closeable; + @Before - public void init() throws NoSuchMethodException { - MockitoAnnotations.initMocks(this); + public void openMocks() throws NoSuchMethodException { + closeable = MockitoAnnotations.openMocks(this); } @Test public void performRendererNullServiceHandlerHeader() { ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer - .rev171017.ServiceDeleteInput serviceDeleteInput = + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput + serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input)); serviceDeleteInput = new ServiceDeleteInputBuilder(serviceDeleteInput).setServiceHandlerHeader(null).build(); ServiceDeleteOutput response = this.rendererServiceWrapperMock.performRenderer(serviceDeleteInput, - ServiceNotificationTypes.ServiceDeleteResult); + ServiceNotificationTypes.ServiceDeleteResult, null); Assert.assertEquals(ResponseCodes.FINAL_ACK_YES, response.getConfigurationResponseCommon().getAckFinalIndicator()); Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, response.getConfigurationResponseCommon().getResponseCode()); - verifyZeroInteractions(this.rendererServiceOperationsMock); + Mockito.verifyNoInteractions(this.rendererServiceOperationsMock); } @Test public void performRendererNullServiceName() { ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer - .rev171017.ServiceDeleteInput serviceDeleteInput = + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput + serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input)); serviceDeleteInput = new ServiceDeleteInputBuilder(serviceDeleteInput).setServiceName(null).build(); ServiceDeleteOutput response = this.rendererServiceWrapperMock.performRenderer(serviceDeleteInput, - ServiceNotificationTypes.ServiceDeleteResult); + ServiceNotificationTypes.ServiceDeleteResult, null); Assert.assertEquals(ResponseCodes.FINAL_ACK_YES, response.getConfigurationResponseCommon().getAckFinalIndicator()); Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, response.getConfigurationResponseCommon().getResponseCode()); - verifyZeroInteractions(this.rendererServiceOperationsMock); + Mockito.verifyNoInteractions(this.rendererServiceOperationsMock); } @Test @@ -98,7 +99,7 @@ public class RendererServiceWrapperTest extends AbstractTest { response.getConfigurationResponseCommon().getAckFinalIndicator()); Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, response.getConfigurationResponseCommon().getResponseCode()); - verifyZeroInteractions(this.rendererServiceOperationsMock); + Mockito.verifyNoInteractions(this.rendererServiceOperationsMock); } @@ -112,14 +113,14 @@ public class RendererServiceWrapperTest extends AbstractTest { .setConfigurationResponseCommon(configurationResponseCommon).build(); ListenableFuture response = ServiceDataUtils.returnFuture(output); Mockito.when(this.rendererServiceOperationsMock.serviceDelete(any( - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017 - .ServiceDeleteInput.class))).thenReturn(response); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915 + .ServiceDeleteInput.class), any())).thenReturn(response); ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput(); - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer - .rev171017.ServiceDeleteInput serviceDeleteInput = + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput + serviceDeleteInput = ModelMappingUtils.createServiceDeleteInput(new ServiceInput(input)); ServiceDeleteOutput rendereResponse = this.rendererServiceWrapperMock.performRenderer(serviceDeleteInput, - ServiceNotificationTypes.ServiceDeleteResult); + ServiceNotificationTypes.ServiceDeleteResult, null); Assert.assertEquals(ResponseCodes.FINAL_ACK_NO, rendereResponse.getConfigurationResponseCommon().getAckFinalIndicator()); Assert.assertEquals(ResponseCodes.RESPONSE_OK, @@ -127,8 +128,8 @@ public class RendererServiceWrapperTest extends AbstractTest { Assert.assertEquals("Renderer service delete in progress", rendereResponse.getConfigurationResponseCommon().getResponseMessage()); verify(this.rendererServiceOperationsMock).serviceDelete(any( - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017 - .ServiceDeleteInput.class)); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915 + .ServiceDeleteInput.class), any()); } @Test @@ -141,8 +142,8 @@ public class RendererServiceWrapperTest extends AbstractTest { .setConfigurationResponseCommon(configurationResponseCommon).build(); ListenableFuture response = ServiceDataUtils.returnFuture(output); Mockito.when(this.rendererServiceOperationsMock.serviceDelete(any( - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017 - .ServiceDeleteInput.class))).thenReturn(response); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915 + .ServiceDeleteInput.class), any())).thenReturn(response); TempServiceDeleteInput input = ServiceDataUtils.buildTempServiceDeleteInput(); ServiceDeleteOutput rendereResponse = this.rendererServiceWrapperMock.performRenderer(input, ServiceNotificationTypes.ServiceDeleteResult); @@ -153,7 +154,11 @@ public class RendererServiceWrapperTest extends AbstractTest { Assert.assertEquals("Renderer service delete in progress", rendereResponse.getConfigurationResponseCommon().getResponseMessage()); verify(this.rendererServiceOperationsMock).serviceDelete(any( - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer - .rev171017.ServiceDeleteInput.class)); + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput + .class), any()); + } + + @After public void releaseMocks() throws Exception { + closeable.close(); } }