import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutionException;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.binding.api.MountPoint;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
import org.opendaylight.transportpce.renderer.stub.MountPointStub;
import org.opendaylight.transportpce.renderer.stub.OlmServiceStub;
import org.opendaylight.transportpce.renderer.utils.MountPointUtils;
+import org.opendaylight.transportpce.renderer.utils.NotificationPublishServiceMock;
import org.opendaylight.transportpce.renderer.utils.ServiceDataUtils;
import org.opendaylight.transportpce.test.AbstractTest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
this.deviceTransactionManager, openRoadmInterfaceFactory, openRoadmInterfaces, crossConnect, portMapping);
Mockito.doNothing().when(this.openRoadmInterfaces).postEquipmentState(Mockito.anyString(),
Mockito.anyString(), Mockito.anyBoolean());
+ NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
this.olmService = Mockito.spy(this.olmService);
this.deviceRenderer = Mockito.spy(this.deviceRenderer);
this.rendererServiceOperations = new RendererServiceOperationsImpl(this.deviceRenderer, this.olmService,
- getDataBroker(), this.networkModelWavelengthService);
+ getDataBroker(), this.networkModelWavelengthService, notificationPublishService);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
}
@Test
- public void serviceImplementationTerminationPointAsResourceTtp() {
+ public void serviceImplementationTerminationPointAsResourceTtp() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationTerminationPointAsResourceTtp2() {
+ public void serviceImplementationTerminationPointAsResourceTtp2() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.TTP_TOKEN);
Mockito.any());
Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
.servicePowerSetup(Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationTerminationPointAsResourcePp() {
+ public void serviceImplementationTerminationPointAsResourcePp() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.PP_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationTerminationPointAsResourceNetwork() {
+ public void serviceImplementationTerminationPointAsResourceNetwork()
+ throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationTerminationPointAsResourceClient() {
+ public void serviceImplementationTerminationPointAsResourceClient()
+ throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.CLIENT_TOKEN);
writePortMapping(input, OpenRoadmInterfacesImpl.CLIENT_TOKEN);
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationTerminationPointAsResourceNoMapping() {
+ public void serviceImplementationTerminationPointAsResourceNoMapping()
+ throws InterruptedException, ExecutionException {
String[] interfaceTokens = {
OpenRoadmInterfacesImpl.NETWORK_TOKEN,
for (String tpToken : interfaceTokens) {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(tpToken);
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result =
+ this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED,
result.getConfigurationResponseCommon().getResponseCode());
}
}
@Test
- public void serviceImplementationRollbackAllNecessary() {
+ public void serviceImplementationRollbackAllNecessary() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
Mockito.doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService)
.servicePowerSetup(Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}
}
@Test
- public void serviceImplementationServiceInActive() {
+ public void serviceImplementationServiceInActive() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.setNodeId("node1").setMeasurements(measurementsList).build();
Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
.getPm(Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceInActive2() {
+ public void serviceImplementationServiceInActive2() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
Mockito.when(this.olmService.getPm(Mockito.any()))
.thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceInActive3() {
+ public void serviceImplementationServiceInActive3() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputA)))
.thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceActive() {
+ public void serviceImplementationServiceActive() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceActive2() {
+ public void serviceImplementationServiceActive2() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceInActive4() {
+ public void serviceImplementationServiceInActive4() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
.setSuccess(true);
Mockito.doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(Mockito.any(),
Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
}
@Test
- public void serviceImplementationServiceInActive5() {
+ public void serviceImplementationServiceInActive5() throws InterruptedException, ExecutionException {
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
.getPm(Mockito.any());
- ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input).get();
Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
}