SubscriptionService extends SubscriptionServiceGrpc.SubscriptionServiceImplBase implements Logging { public static Builder newBuilder() { return new Builder(); } private  SubscriptionService(ImmutableMap<TypeUrl, BoundedContext> map); static Builder newBuilder(); @Override void subscribe(Topic topic, StreamObserver<Subscription> responseObserver); @Override void activate(Subscription subscription, StreamObserver<SubscriptionUpdate> observer); @Override void cancel(Subscription subscription, StreamObserver<Response> responseObserver);  }
@Test @DisplayName("be able to remove bounded context from builder") void removeBcFromBuilder() { BoundedContext bc1 = ctx("Removed"); BoundedContext bc2 = ctx("Also removed"); BoundedContext bc3 = ctx("The one to stay"); SubscriptionService.Builder builder = SubscriptionService .newBuilder() .add(bc1) .add(bc2) .add(bc3) .remove(bc2) .remove(bc1); SubscriptionService subscriptionService = builder.build(); assertNotNull(subscriptionService); List<BoundedContext> contexts = builder.contexts(); assertThat(contexts).containsExactly(bc3); }
@Test @DisplayName("fail to initialize from empty builder") void notInitFromEmptyBuilder() { assertThrows(IllegalStateException.class, () -> SubscriptionService.newBuilder() .build()); }