@Test public void postResults() { List<FlashcardWordResult> results = Arrays.asList( FlashcardWordResult.create(FlashcardWord.create("word", "translation", "id"), true), FlashcardWordResult.create(FlashcardWord.create("word2", "translation2", "id2"), false) ); FlashcardTestResult result = FlashcardTestResult.create("ui", "learn", results); when(service.postFlashcardResults(any())).thenReturn(Call.just(null)); module.postResult(result); ArgumentCaptor<FlashcardResultsController> captor = ArgumentCaptor .forClass(FlashcardResultsController.class); verify(service).postFlashcardResults(captor.capture()); FlashcardResultsController controller = captor.getValue(); assertThat(controller.uiLanguage, equalTo("ui")); assertThat(controller.learningLanguage, equalTo("learn")); FlashcardResultsController.FlashcardResultModel flashcardResultModel = controller.flashcardResults.get(0); assertThat(flashcardResultModel.id, equalTo("id")); assertThat(flashcardResultModel.correct, equalTo(1)); flashcardResultModel = controller.flashcardResults.get(1); assertThat(flashcardResultModel.id, equalTo("id2")); assertThat(flashcardResultModel.correct, equalTo(0)); }
@Override public void postResult(FlashcardTestResult result) { logger.debug("postResult() called with: result = [{}]", result); service.postFlashcardResults(new FlashcardResultsController(result)) .enqueue(whatever -> { }, throwable -> logger.error("Failed to post results", throwable)); }
RestFlashcardsModule implements FlashcardsModule { @Override public void postResult(FlashcardTestResult result) { logger.debug("postResult() called with: result = [{}]", result); service.postFlashcardResults(new FlashcardResultsController(result)) .enqueue(whatever -> { }, throwable -> logger.error("Failed to post results", throwable)); } }
RestFlashcardsModule implements FlashcardsModule { @Override public void postResult(FlashcardTestResult result) { logger.debug("postResult() called with: result = [{}]", result); service.postFlashcardResults(new FlashcardResultsController(result)) .enqueue(whatever -> { }, throwable -> logger.error("Failed to post results", throwable)); } @Inject  RestFlashcardsModule(RestService service); }
RestFlashcardsModule implements FlashcardsModule { @Override public void postResult(FlashcardTestResult result) { logger.debug("postResult() called with: result = [{}]", result); service.postFlashcardResults(new FlashcardResultsController(result)) .enqueue(whatever -> { }, throwable -> logger.error("Failed to post results", throwable)); } @Inject  RestFlashcardsModule(RestService service); @Override Call<FlashcardTestData> getFlashcards(); @Override void postResult(FlashcardTestResult result); }
RestFlashcardsModule implements FlashcardsModule { @Override public void postResult(FlashcardTestResult result) { logger.debug("postResult() called with: result = [{}]", result); service.postFlashcardResults(new FlashcardResultsController(result)) .enqueue(whatever -> { }, throwable -> logger.error("Failed to post results", throwable)); } @Inject  RestFlashcardsModule(RestService service); @Override Call<FlashcardTestData> getFlashcards(); @Override void postResult(FlashcardTestResult result);  }