import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.Rpc;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
input, ResponseCodes.FINAL_ACK_YES,
validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
}
- //Check any presence of services with the same name
+ //Check any presence of services with the same nameequipmentNotification
String serviceName = input.getServiceName();
if (this.serviceDataStoreOperations.getService(serviceName).isPresent()) {
LOG.warn(SERVICE_CREATE_MSG, LogMessages.serviceInDS(serviceName));
public final ListenableFuture<RpcResult<EquipmentNotificationOutput>>
equipmentNotification(EquipmentNotificationInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<EquipmentNotificationOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceRerouteConfirmOutput>>
serviceRerouteConfirm(ServiceRerouteConfirmInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceRerouteConfirmOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
@Override
public final ListenableFuture<RpcResult<ServiceReversionOutput>> serviceReversion(ServiceReversionInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceReversionOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceRollOutput>> serviceRoll(ServiceRollInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceRollOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<NetworkReOptimizationOutput>>
networkReOptimization(NetworkReOptimizationInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<NetworkReOptimizationOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
ServiceDeleteComplexResultNotificationRequestOutput>> serviceDeleteComplexResultNotificationRequest(
ServiceDeleteComplexResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceDeleteComplexResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
ServiceCreateResultNotificationRequestOutput>> serviceCreateResultNotificationRequest(
ServiceCreateResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceCreateResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
ServiceDeleteResultNotificationRequestOutput>> serviceDeleteResultNotificationRequest(
ServiceDeleteResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceDeleteResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
ServiceCreateComplexResultNotificationRequestOutput>> serviceCreateComplexResultNotificationRequest(
ServiceCreateComplexResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceCreateComplexResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceFeasibilityCheckBulkOutput>> serviceFeasibilityCheckBulk(
ServiceFeasibilityCheckBulkInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceFeasibilityCheckBulkOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceCreateBulkOutput>> serviceCreateBulk(ServiceCreateBulkInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceCreateBulkOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<TempServiceCreateBulkOutput>> tempServiceCreateBulk(
TempServiceCreateBulkInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<TempServiceCreateBulkOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
ServiceRollResultNotificationRequestOutput>> serviceRollResultNotificationRequest(
ServiceRollResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceRollResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceReconfigureBulkOutput>> serviceReconfigureBulk(
ServiceReconfigureBulkInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceReconfigureBulkOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceReconfigureResultNotificationRequestOutput>>
serviceReconfigureResultNotificationRequest(ServiceReconfigureResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceReconfigureResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceRestorationResultNotificationRequestOutput>>
serviceRestorationResultNotificationRequest(ServiceRestorationResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceRestorationResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceReversionResultNotificationRequestOutput>>
serviceReversionResultNotificationRequest(ServiceReversionResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceReversionResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<ServiceRerouteConfirmResultNotificationRequestOutput>>
serviceRerouteConfirmResultNotificationRequest(ServiceRerouteConfirmResultNotificationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceRerouteConfirmResultNotificationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<
OpticalTunnelCreateOutput>> opticalTunnelCreate(OpticalTunnelCreateInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<OpticalTunnelCreateOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<OpticalTunnelRequestCancelOutput>> opticalTunnelRequestCancel(
OpticalTunnelRequestCancelInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<OpticalTunnelRequestCancelOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
@Override
public final ListenableFuture<RpcResult<ServiceSrlgGetOutput>> serviceSrlgGet(ServiceSrlgGetInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<ServiceSrlgGetOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<EndTerminalPerformanceInfoRequestOutput>> endTerminalPerformanceInfoRequest(
EndTerminalPerformanceInfoRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<EndTerminalPerformanceInfoRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<EndTerminalActivationRequestOutput>> endTerminalActivationRequest(
EndTerminalActivationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<EndTerminalActivationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<EndTerminalDeactivationRequestOutput>> endTerminalDeactivationRequest(
EndTerminalDeactivationRequestInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<EndTerminalDeactivationRequestOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
@Override
public final ListenableFuture<RpcResult<EndTerminalPowerControlOutput>> endTerminalPowerControl(
EndTerminalPowerControlInput input) {
// TODO Auto-generated method stub
- return null;
+ return RpcResultBuilder.<EndTerminalPowerControlOutput>failed()
+ .withError(ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED, "RPC not implemented yet")
+ .buildFuture();
}
public Registration getRegisteredRpc() {
*/
package org.opendaylight.transportpce.servicehandler.impl;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRestorationOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGetInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceSrlgGetOutput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceCreateOutput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPointBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.ResponseParametersBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.response.parameters.sp.response.parameters.PathDescriptionBuilder;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.Uint32;
@ExtendWith(MockitoExtension.class)
public class ServicehandlerImplTest extends AbstractTest {
-
@Mock
private RpcProviderService rpcProviderService;
@Mock
verify(rpcProviderService, times(1)).registerRpcImplementations(any());
}
+ @Test
+ void testNotImplementedRpc() throws InterruptedException, ExecutionException {
+ ListenableFuture<RpcResult<ServiceSrlgGetOutput>> result = new ServicehandlerImpl(rpcProviderService,
+ pathComputationService, rendererServiceOperations, notificationPublishService,
+ pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
+ serviceDataStoreOperations, catalogDataStoreOperations)
+ .serviceSrlgGet(new ServiceSrlgGetInputBuilder().build());
+ result.addListener(() -> endSignal.countDown(), executorService);
+ endSignal.await();
+ assertNotNull(result.get());
+ assertFalse(result.get().isSuccessful());
+ assertNull(result.get().getResult());
+ assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
+ assertEquals(ErrorSeverity.ERROR, result.get().getErrors().get(0).getSeverity());
+ assertEquals(ErrorTag.OPERATION_NOT_SUPPORTED, result.get().getErrors().get(0).getTag());
+ assertEquals("RPC not implemented yet", result.get().getErrors().get(0).getMessage());
+ }
+
@Test
void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
ListenableFuture<RpcResult<ServiceCreateOutput>> result =