@Test void handleReturnsFileResponseIfZombieHeaderHasCurrentFileValue() throws JsonProcessingException { when(request.getHeaders()).thenReturn(singletonMap("zombie", "current-file")); when(primingContext.getCurrentPriming()).thenReturn(primedRequests); when(currentPrimingFileResponseFactory.create(primedRequests)).thenReturn(fileResponse); final Response got = zombieRequestHandler.handle(request); assertThat(got).isEqualTo(fileResponse); }
@Override public Response handle(Request request) { final String zombieHeaderValue = request.getHeaders().get(zombieHeaderName); switch(zombieHeaderValue) { case "priming": return handlePrimingRequest(request); case "priming-default": return handleDefaultPrimingRequest(request); case "priming-file": return handleFilePrimingRequest(request); case "count": return handleCountRequest(request); case "current": return handleCurrentPrimingRequest(); case "current-file": return handleCurrentPrimingFileRequest(); case "history": return handleHistoryRequest(); case "failed": return handleFailedRequest(); case "reset": return handleResetRequest(); case "truststore": return handleTruststoreRequest(); case "up": return handleUpRequest(); default: throw new RuntimeException(format("Unknown zombie method: %s", zombieHeaderValue)); } }
ZombieRequestHandler implements RequestHandler { @Override public Response handle(Request request) { final String zombieHeaderValue = request.getHeaders().get(zombieHeaderName); switch(zombieHeaderValue) { case "priming": return handlePrimingRequest(request); case "priming-default": return handleDefaultPrimingRequest(request); case "priming-file": return handleFilePrimingRequest(request); case "count": return handleCountRequest(request); case "current": return handleCurrentPrimingRequest(); case "current-file": return handleCurrentPrimingFileRequest(); case "history": return handleHistoryRequest(); case "failed": return handleFailedRequest(); case "reset": return handleResetRequest(); case "truststore": return handleTruststoreRequest(); case "up": return handleUpRequest(); default: throw new RuntimeException(format("Unknown zombie method: %s", zombieHeaderValue)); } } }
ZombieRequestHandler implements RequestHandler { @Override public Response handle(Request request) { final String zombieHeaderValue = request.getHeaders().get(zombieHeaderName); switch(zombieHeaderValue) { case "priming": return handlePrimingRequest(request); case "priming-default": return handleDefaultPrimingRequest(request); case "priming-file": return handleFilePrimingRequest(request); case "count": return handleCountRequest(request); case "current": return handleCurrentPrimingRequest(); case "current-file": return handleCurrentPrimingFileRequest(); case "history": return handleHistoryRequest(); case "failed": return handleFailedRequest(); case "reset": return handleResetRequest(); case "truststore": return handleTruststoreRequest(); case "up": return handleUpRequest(); default: throw new RuntimeException(format("Unknown zombie method: %s", zombieHeaderValue)); } } ZombieRequestHandler(String zombieHeaderName,
                                PrimingContext primingContext,
                                CallHistory callHistory,
                                FixedCapacityCache<AppRequest> failedRequests,
                                Deserializer deserializer,
                                CurrentPrimingFileResponseFactory fileResponseFactory,
                                PrimedMappingUploader primedMappingUploader,
                                HttpsSupport httpsSupport); }
ZombieRequestHandler implements RequestHandler { @Override public Response handle(Request request) { final String zombieHeaderValue = request.getHeaders().get(zombieHeaderName); switch(zombieHeaderValue) { case "priming": return handlePrimingRequest(request); case "priming-default": return handleDefaultPrimingRequest(request); case "priming-file": return handleFilePrimingRequest(request); case "count": return handleCountRequest(request); case "current": return handleCurrentPrimingRequest(); case "current-file": return handleCurrentPrimingFileRequest(); case "history": return handleHistoryRequest(); case "failed": return handleFailedRequest(); case "reset": return handleResetRequest(); case "truststore": return handleTruststoreRequest(); case "up": return handleUpRequest(); default: throw new RuntimeException(format("Unknown zombie method: %s", zombieHeaderValue)); } } ZombieRequestHandler(String zombieHeaderName,
                                PrimingContext primingContext,
                                CallHistory callHistory,
                                FixedCapacityCache<AppRequest> failedRequests,
                                Deserializer deserializer,
                                CurrentPrimingFileResponseFactory fileResponseFactory,
                                PrimedMappingUploader primedMappingUploader,
                                HttpsSupport httpsSupport); @Override Response handle(Request request); }
ZombieRequestHandler implements RequestHandler { @Override public Response handle(Request request) { final String zombieHeaderValue = request.getHeaders().get(zombieHeaderName); switch(zombieHeaderValue) { case "priming": return handlePrimingRequest(request); case "priming-default": return handleDefaultPrimingRequest(request); case "priming-file": return handleFilePrimingRequest(request); case "count": return handleCountRequest(request); case "current": return handleCurrentPrimingRequest(); case "current-file": return handleCurrentPrimingFileRequest(); case "history": return handleHistoryRequest(); case "failed": return handleFailedRequest(); case "reset": return handleResetRequest(); case "truststore": return handleTruststoreRequest(); case "up": return handleUpRequest(); default: throw new RuntimeException(format("Unknown zombie method: %s", zombieHeaderValue)); } } ZombieRequestHandler(String zombieHeaderName,
                                PrimingContext primingContext,
                                CallHistory callHistory,
                                FixedCapacityCache<AppRequest> failedRequests,
                                Deserializer deserializer,
                                CurrentPrimingFileResponseFactory fileResponseFactory,
                                PrimedMappingUploader primedMappingUploader,
                                HttpsSupport httpsSupport); @Override Response handle(Request request);  }