@Test public void testDeleteScope() throws ExecutionException, InterruptedException { when(this.mockControllerService.deleteScope(any())).thenReturn( CompletableFuture.completedFuture(Controller.DeleteScopeStatus.newBuilder() .setStatus(Controller.DeleteScopeStatus.Status.SUCCESS).build())); Assert.assertTrue(this.testController.deleteScope("scope").join()); when(this.mockControllerService.deleteScope(any())).thenReturn( CompletableFuture.completedFuture(Controller.DeleteScopeStatus.newBuilder() .setStatus(Controller.DeleteScopeStatus.Status.SCOPE_NOT_FOUND).build())); Assert.assertFalse(this.testController.deleteScope("scope").join()); when(this.mockControllerService.deleteScope(any())).thenReturn( CompletableFuture.completedFuture(Controller.DeleteScopeStatus.newBuilder() .setStatus(Controller.DeleteScopeStatus.Status.FAILURE).build())); assertThrows("Expected ControllerFailureException", () -> this.testController.deleteScope("scope").join(), ex -> ex instanceof ControllerFailureException); when(this.mockControllerService.deleteScope(any())).thenReturn( CompletableFuture.completedFuture(Controller.DeleteScopeStatus.newBuilder() .setStatus(Controller.DeleteScopeStatus.Status.SCOPE_NOT_EMPTY).build())); assertThrows("Expected IllegalStateException", () -> this.testController.deleteScope("scope").join(), ex -> ex instanceof IllegalStateException); when(this.mockControllerService.deleteScope(any())).thenReturn( CompletableFuture.completedFuture(Controller.DeleteScopeStatus.newBuilder() .setStatusValue(-1).build())); assertThrows("Expected ControllerFailureException", () -> this.testController.deleteScope("scope").join(), ex -> ex instanceof ControllerFailureException); }
public Builder mergeFrom(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus other) { if (other == io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus.getDefaultInstance()) return this; if (other.status_ != 0) { setStatusValue(other.getStatusValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }