@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 initiate() throws Exception { Person bob = new Person(UUID.randomUUID()); String sessionId = (new Date()).toString(); securityService.setCurrent(bob); UUID selfHelpGuideId = UUID.randomUUID(); SelfHelpGuide selfHelpGuide = new SelfHelpGuide(); SelfHelpGuideResponse selfHelpGuideResponse = new SelfHelpGuideResponse(); expect(selfHelpGuideService.get(selfHelpGuideId)).andReturn(selfHelpGuide); expect(service.initiateSelfHelpGuideResponse(selfHelpGuide, bob, sessionId)) .andReturn(selfHelpGuideResponse); replay(service); replay(selfHelpGuideService); String response = controller.initiate(selfHelpGuideId); verify(service); verify(selfHelpGuideService); assertEquals(selfHelpGuideResponse.toString(), 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); }