- public void createServiceShouldBeSuccessfulWhenPreformPCESuccessful()
- throws ExecutionException, InterruptedException {
- ServiceCreateInput input = ServiceDataUtils.buildServiceCreateInput();
- Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
- ServicehandlerImpl servicehandlerImpl =
- new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
- notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
- serviceDataStoreOperations);
- ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
+ public void createServiceShouldBeFailedWithServiceAlreadyExist() throws ExecutionException,
+ InterruptedException {
+ final ServiceDataStoreOperations serviceDSOperations = mock(ServiceDataStoreOperations.class);
+ Mockito.when(serviceDSOperations.getService(serviceCreateInput.getServiceName()))
+ .thenReturn(Optional.of(
+ new ServicesBuilder()
+ .setServiceName(serviceCreateInput.getServiceName())
+ .build()));
+ ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService,
+ rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+ networkModelListenerImpl, serviceDSOperations);
+ ListenableFuture<RpcResult<ServiceCreateOutput>> result = servicehandlerImpl.serviceCreate(serviceCreateInput);
+ result.addListener(() -> endSignal.countDown(), executorService);