@Test public void answer() throws ObjectNotFoundException { UUID selfHelpGuideResponseId = UUID.randomUUID(); UUID selfHelpGuideQuestionId = UUID.randomUUID(); Boolean answerResponse = true; SelfHelpGuideResponse selfHelpGuideResponse = new SelfHelpGuideResponse(); SelfHelpGuideQuestion selfHelpGuideQuestion = new SelfHelpGuideQuestion(); expect(service.get(selfHelpGuideResponseId)).andReturn(selfHelpGuideResponse); expect(selfHelpGuideQuestionService.get(selfHelpGuideQuestionId)) .andReturn(selfHelpGuideQuestion); expect( service.answerSelfHelpGuideQuestion( selfHelpGuideResponse, selfHelpGuideQuestion, answerResponse)) .andReturn(false); replay(service); replay(selfHelpGuideQuestionService); try { Boolean response = controller.answer(selfHelpGuideResponseId, selfHelpGuideQuestionId, answerResponse); verify(service); verify(selfHelpGuideQuestionService); assertFalse(response); } catch (Exception e) { fail("controller error"); } }
@Test public void complete() throws Exception { UUID selfHelpGuideResponseId = UUID.randomUUID(); SelfHelpGuideResponse selfHelpGuideResponse = new SelfHelpGuideResponse(); expect(service.get(selfHelpGuideResponseId)).andReturn(selfHelpGuideResponse); expect(service.completeSelfHelpGuideResponse(selfHelpGuideResponse)).andReturn(false); replay(service); Boolean response = controller.complete(selfHelpGuideResponseId); verify(service); assertFalse(response); }
@Test public void getById() throws Exception { UUID selfHelpGuideResponseId = UUID.randomUUID(); SelfHelpGuideResponse selfHelpGuideResponse = new SelfHelpGuideResponse(); expect(service.get(selfHelpGuideResponseId)).andReturn(selfHelpGuideResponse); SelfHelpGuideResponseTO expectedResponseTO = new SelfHelpGuideResponseTO(); expect( service.getSelfHelpGuideResponseFor( eq(selfHelpGuideResponse), isA(SortingAndPaging.class))) .andReturn(expectedResponseTO); replay(service); SelfHelpGuideResponseTO responseTO = controller.getById(selfHelpGuideResponseId); verify(service); assertEquals(responseTO, expectedResponseTO); }