### Question:
GeeseService extends GeeseServiceImplBase { @Override public void getGeese(GetGeeseRequest request, StreamObserver<GeeseResponse> responseObserver) { GeeseResponse.Builder response = GeeseResponse.newBuilder(); int gooseWidth = Integer.max(request.getGooseWidth(), DEFAULT_GOOSE_WIDTH); IntStream.range(0, request.getLinesCount()) .mapToObj(i -> generateGeeseLine(request.getLineWidth(), gooseWidth)) .forEach(response::addLines); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } GeeseService(BinaryOperator<Integer> numberOfGeeseGenerator,
                 UnaryOperator<Integer> geeseGenerator,
                 FixtureFailureProvider fixtureFailureProvider); @Override void getGeese(GetGeeseRequest request,
                         StreamObserver<GeeseResponse> responseObserver);  }### Answer:
@Test public void shouldReturnNonOverlappingGeese() { AtomicInteger counter = new AtomicInteger(); UnaryOperator<Integer> sequentialGenerator = i -> counter.getAndIncrement(); int numberOfGeese = 5; grpcServerRule.getServiceRegistry() .addService(new GeeseService((min, max) -> numberOfGeese, sequentialGenerator, new InjectedFailureProvider())); GeeseServiceBlockingStub geeseClient = GeeseServiceGrpc.newBlockingStub(grpcServerRule.getChannel()); GeeseResponse response = geeseClient.getGeese(GetGeeseRequest.newBuilder() .setLinesCount(1).setGooseWidth(10).setLineWidth(50).build()); GeeseResponse geeseResponse = GeeseResponse.newBuilder() .addLines(GeeseLine.newBuilder().addAllGeesePositions(asList(0, 10, 20, 30, 40)).build()) .build(); assertThat(response).isEqualTo(geeseResponse); }
@Test public void shouldReturnLineFullOfGeeseIfFullFixtureFailureIsEnabled() { InjectedFailureProvider fixtureFailureProvider = new InjectedFailureProvider(); fixtureFailureProvider.setFullFixtureEnabled(true); grpcServerRule.getServiceRegistry() .addService(new GeeseService((min, max) -> 0, index -> 0, fixtureFailureProvider)); GeeseServiceBlockingStub geeseClient = GeeseServiceGrpc.newBlockingStub(grpcServerRule.getChannel()); GeeseResponse response = geeseClient.getGeese(GetGeeseRequest.newBuilder() .setLinesCount(1).setGooseWidth(4).setLineWidth(21).build()); GeeseResponse geeseResponse = GeeseResponse.newBuilder() .addLines(GeeseLine.newBuilder().addAllGeesePositions(asList(0, 4, 8, 12, 16, 20)).build()) .build(); assertThat(response).isEqualTo(geeseResponse); }