+ GetPmInput getPmInputZA = createGetPmInput(input.getServiceZEnd().getNodeId(),
+ input.getServiceZEnd().getNodeId() + "-" + input.getServiceAEnd().getNodeId() + "-"
+ + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmInput getPmInputAA = createGetPmInput(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getNodeId() + "-" + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZZ)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputAZ)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZA)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputAA)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive3() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("FECUncorrectableBlocks")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+ GetPmOutput getPmOutput2 = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+
+ GetPmInput getPmInputZZ = createGetPmInput(input.getServiceZEnd().getNodeId(),
+ input.getServiceZEnd().getNodeId() + "-" + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmInput getPmInputAZ = createGetPmInput(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getNodeId() + "-" + input.getServiceZEnd().getNodeId() + "-"
+ + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+
+ GetPmInput getPmInputZA = createGetPmInput(input.getServiceZEnd().getNodeId(),
+ input.getServiceZEnd().getNodeId() + "-" + input.getServiceAEnd().getNodeId() + "-"
+ + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmInput getPmInputAA = createGetPmInput(input.getServiceAEnd().getNodeId(),
+ input.getServiceAEnd().getNodeId() + "-" + OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZZ)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputAZ)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputZA)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput2).buildFuture());
+ Mockito.when(this.olmService.getPm(Mockito.eq(getPmInputAA)))
+ .thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceActive() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(new ArrayList<>()).build();
+ GetPmOutput getPmOutput1 = null;
+ Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput1)
+ .buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceActive2() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder().setMeasurements(new ArrayList<>()).build();
+ Mockito.when(this.olmService.getPm(Mockito.any())).thenReturn(RpcResultBuilder.success(getPmOutput)
+ .buildFuture());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive4() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
+ .setPmparameterValue("1").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+
+ Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
+ .getPm(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
+
+ }
+
+ @Test
+ public void serviceImplementationServiceInActive5() {
+
+ ServiceImplementationRequestInput input = ServiceDataUtils
+ .buildServiceImplementationRequestInputTerminationPointResource(OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ writePortMapping(input, OpenRoadmInterfacesImpl.NETWORK_TOKEN);
+ Measurements measurements = new MeasurementsBuilder().setPmparameterName("preFECCorrectedErrors")
+ .setPmparameterValue("112000000000d").build();
+ List<Measurements> measurementsList = new ArrayList<Measurements>();
+ measurementsList.add(measurements);
+ GetPmOutput getPmOutput = new GetPmOutputBuilder()
+ .setNodeId("node1").setMeasurements(measurementsList).build();
+
+ Mockito.doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService)
+ .getPm(Mockito.any());
+ ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input);
+ Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, result.getConfigurationResponseCommon().getResponseCode());
+
+ }