@Test public void test_includeApplicationDefaultCSS_emptyList() { replayDefault(); List<CSS> cssList = cssCommand.includeApplicationDefaultCSS(); assertNotNull(cssList); verifyDefault(); }
@Test public void testOnEvent_nullDoc_ing() { Event event = new DocumentUpdatingEvent(); replayDefault(); listener.onEvent(event, null, context); verifyDefault(); }
@Test public void test_includeApplicationDefaultCSS_registerMockComponent_emptyList() throws Exception { ICssExtensionRole testCssExtMock = registerComponentMock(ICssExtensionRole.class, "testCssExt"); expect(testCssExtMock.getCssList()).andReturn(Collections.<CSS>emptyList()).once(); replayDefault(); List<CSS> cssList = cssCommand.includeApplicationDefaultCSS(); assertNotNull(cssList); verifyDefault(); }
@Test public void testCheckCaptcha_singleCall_emptyAnswer() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn("").atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").anyTimes(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).anyTimes(); replayDefault(); assertFalse(captchaService.checkCaptcha()); verifyDefault(); }
@Test public void testOnEvent_isRemote_ed() { Event event = new DocumentUpdatedEvent(); expect(remoteObsManContextMock.isRemoteState()).andReturn(true).once(); replayDefault(); listener.onEvent(event, docMock, context); verifyDefault(); }
@Test public void test_includeApplicationDefaultCSS_registerMockComponent_oneElem() throws Exception { ICssExtensionRole testCssExtMock = registerComponentMock(ICssExtensionRole.class, "testCssExt"); expect(testCssExtMock.getCssList()) .andReturn(Arrays.<CSS>asList(new CSSString(":celRes/test.css", getContext()))) .once(); replayDefault(); List<CSS> cssList = cssCommand.includeApplicationDefaultCSS(); assertNotNull(cssList); verifyDefault(); }
@Test public void testOnEvent_update_ed_noChange() { Event event = new DocumentUpdatedEvent(); expect(remoteObsManContextMock.isRemoteState()).andReturn(false).once(); expect(docMock.getXObject(eq(classRef))).andReturn(new BaseObject()).once(); expect(origDocMock.getXObject(eq(classRef))).andReturn(new BaseObject()).once(); replayDefault(); listener.onEvent(event, docMock, context); verifyDefault(); }
@Test public void testCheckCaptcha_singleCall_false() throws Exception { String wrongAnwser = "chetuck"; expect(requestMock.get(eq("captcha_answer"))).andReturn(wrongAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser))) .andReturn(false) .once(); replayDefault(); assertFalse(captchaService.checkCaptcha()); verifyDefault(); }
@Test public void testOnEvent_update_ed() { Event event = new DocumentUpdatedEvent(); expect(remoteObsManContextMock.isRemoteState()).andReturn(false).once(); expect(docMock.getXObject(eq(classRef))).andReturn(getBaseObject1()).once(); expect(origDocMock.getXObject(eq(classRef))).andReturn(getBaseObject2()).once(); obsManagerMock.notify(same(updatedEventMock), same(docMock), same(context)); expectLastCall().once(); replayDefault(); listener.onEvent(event, docMock, context); verifyDefault(); }
@Test public void testCheckCaptcha_doubleCall_true() throws Exception { String expectedAnwser = "chetuck"; expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) .andReturn(true) .once(); expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) .andReturn(false) .anyTimes(); replayDefault(); assertTrue(captchaService.checkCaptcha()); // check answer caching assertTrue(captchaService.checkCaptcha()); verifyDefault(); }
@Test public void testGetMandatoryDocumentsList() { // use LinkedHashMap to preserve inserting order. mdCompositor.mandatoryDocumentsMap = new LinkedHashMap<String, IMandatoryDocumentRole>(); IMandatoryDocumentRole mockA_mandDoc = createMockAndAddToDefault(IMandatoryDocumentRole.class); expect(mockA_mandDoc.dependsOnMandatoryDocuments()) .andReturn(Collections.<String>emptyList()) .atLeastOnce(); IMandatoryDocumentRole mockB_mandDocDepA = createMockAndAddToDefault(IMandatoryDocumentRole.class); expect(mockB_mandDocDepA.dependsOnMandatoryDocuments()) .andReturn(Arrays.asList("A_mandDoc")) .atLeastOnce(); mdCompositor.mandatoryDocumentsMap.put("B_mandDocDepA", mockB_mandDocDepA); mdCompositor.mandatoryDocumentsMap.put("A_mandDoc", mockA_mandDoc); replayDefault(); List<String> expectedExedList = Arrays.asList("A_mandDoc", "B_mandDocDepA"); assertFalse( "check precondition", expectedExedList.equals( new ArrayList<String>(mdCompositor.mandatoryDocumentsMap.keySet()))); assertEquals(expectedExedList, mdCompositor.getMandatoryDocumentsList()); verifyDefault(); }
@Test public void testGetMandatoryDocumentsList_empty() { replayDefault(); assertEquals(Collections.emptyList(), mdCompositor.getMandatoryDocumentsList()); verifyDefault(); }