當前位置: 首頁>>代碼示例>>Java>>正文


Java NotifiableTaskMetadata類代碼示例

本文整理匯總了Java中org.sejda.model.task.NotifiableTaskMetadata的典型用法代碼示例。如果您正苦於以下問題:Java NotifiableTaskMetadata類的具體用法?Java NotifiableTaskMetadata怎麽用?Java NotifiableTaskMetadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NotifiableTaskMetadata類屬於org.sejda.model.task包,在下文中一共展示了NotifiableTaskMetadata類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: split

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
public void split(NotifiableTaskMetadata taskMetadata) throws TaskException {
    nextOutputStrategy().ensureIsValid();
    PdfCopier pdfCopier = null;
    try {
        int outputDocumentsCounter = 0;
        for (int page = 1; page <= totalPages; page++) {
            if (nextOutputStrategy().isOpening(page)) {
                LOG.debug("Starting split at page {} of the original document", page);
                outputDocumentsCounter++;
                pdfCopier = open(page, outputDocumentsCounter);
            }
            pdfCopier.addPage(reader, page);
            notifyEvent(taskMetadata).stepsCompleted(page).outOf(totalPages);
            if (nextOutputStrategy().isClosing(page) || page == totalPages) {
                LOG.trace("Adding bookmarks to the temporary buffer");
                pdfCopier.setOutline(outlineSubsetProvider.getOutlineUntillPage(page));
                nullSafeCloseQuietly(pdfCopier);
                LOG.debug("Ending split at page {} of the original document", page);
            }
        }
    } finally {
        nullSafeCloseQuietly(pdfCopier);
    }
    parameters.getOutput().accept(outputWriter);
}
 
開發者ID:torakiki,項目名稱:sejda-itext5,代碼行數:26,代碼來源:AbstractPdfSplitter.java

示例2: testFinallyDoesntSwallowErrors

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test(expected = OutOfMemoryError.class)
// issue #80
public void testFinallyDoesntSwallowErrors() throws IOException, TaskException {
    InputStream inputStream = null;
    try {
        inputStream = getClass().getClassLoader().getResourceAsStream("pdf/test_no_outline.pdf");
        reader = new PdfReader(inputStream);
        PagesPdfSplitter<AbstractSplitByPageParameters> victim = spy(new PagesPdfSplitter<AbstractSplitByPageParameters>(
                reader, params));
        PdfCopier mockCopier = mock(PdfCopier.class);
        doReturn(mockCopier).when(victim).openCopier(any(PdfReader.class), any(File.class), any(PdfVersion.class));
        doThrow(new RuntimeException()).when(mockCopier).close();
        doThrow(new OutOfMemoryError()).when(mockCopier).addPage(reader, 1);
        NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class);
        victim.split(taskMetadata);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
開發者ID:torakiki,項目名稱:sejda-itext5,代碼行數:20,代碼來源:PagesPdfSplitterTest.java

示例3: sendToModuleClick

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void sendToModuleClick() throws Exception {
    File file = temp.newFile();
    NotifiableTaskMetadata taskMetadata = new NotifiableTaskMetadata(mock(Task.class));
    taskMetadata.addTaskOutput(file);
    TaskExecutionCompletedEvent event = new TaskExecutionCompletedEvent(10, taskMetadata);
    HitTestListener<ClearModuleEvent> clear = new HitTestListener<>();
    eventStudio().add(ClearModuleEvent.class, clear, module.id());
    HitTestListener<PdfLoadRequestEvent> load = new HitTestListener<>();
    eventStudio().add(PdfLoadRequestEvent.class, load, module.id());
    HitTestListener<SetActiveModuleRequest> active = new HitTestListener<>();
    eventStudio().add(SetActiveModuleRequest.class, active);
    eventStudio().broadcast(event, "moduleId");
    click(".arrow-button").click(module.descriptor().getName());
    assertTrue(clear.isHit());
    assertTrue(active.isHit());
    assertTrue(load.isHit());
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:19,代碼來源:OpenButtonTest.java

示例4: testNotificationContextNotify

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
private void testNotificationContextNotify(NotificationContext victim) {
    TestListenerPercentage listener = newPercentageListener();
    TestListenerAny<PercentageOfWorkDoneChangedEvent> secondListener = newGeneralListener();
    TestListenerAny<TaskExecutionFailedEvent> thirdListener = newGeneralListener();
    victim.addListener(listener);
    victim.addListener(PercentageOfWorkDoneChangedEvent.class, secondListener);
    victim.addListener(TaskExecutionFailedEvent.class, thirdListener);
    BigDecimal value = new BigDecimal("32");
    PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent(value,
            NotifiableTaskMetadata.NULL);
    assertFalse(event.isUndetermined());
    victim.notifyListeners(event);
    assertEquals(value, listener.getPercentage());
    assertFalse(listener.isUndeterminate());
    assertTrue(secondListener.hasListened());
    assertFalse(thirdListener.hasListened());
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:18,代碼來源:NotificationContextTest.java

示例5: onProgress

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void onProgress() {
    NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class);
    PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent(new BigDecimal(50), taskMetadata);
    victim.onProgress(event);
    assertFalse(victim.lookup(".footer-failed-button").isVisible());
    assertFalse(victim.lookup(".footer-open-button").isVisible());
    assertEquals(DefaultI18nContext.getInstance().i18n("Running {0}%", "50"),
            ((Labeled) victim.lookup(".status-label")).getText());
    assertEquals(0.5, ((ProgressBar) victim.lookup(".pdfsam-footer-bar")).getProgress(), 0.01);
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:12,代碼來源:FooterTest.java

示例6: onProgressIndeterminate

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void onProgressIndeterminate() {
    NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class);
    PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent(
            PercentageOfWorkDoneChangedEvent.UNDETERMINED, taskMetadata);
    victim.onProgress(event);
    assertFalse(victim.lookup(".footer-failed-button").isVisible());
    assertFalse(victim.lookup(".footer-open-button").isVisible());
    assertEquals(DefaultI18nContext.getInstance().i18n("Running"),
            ((Labeled) victim.lookup(".status-label")).getText());
    assertTrue(((ProgressBar) victim.lookup(".pdfsam-footer-bar")).isIndeterminate());
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:13,代碼來源:FooterTest.java

示例7: openSingleFileDirectoryDestinationClick

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void openSingleFileDirectoryDestinationClick() throws Exception {
    File file = temp.newFile();
    DirectoryTaskOutput output = new DirectoryTaskOutput(file.getParentFile());
    TestListener listener = new TestListener(file);
    OpenButton victim = find(".footer-open-button");
    eventStudio().add(listener);
    NotifiableTaskMetadata taskMetadata = new NotifiableTaskMetadata(mock(Task.class));
    taskMetadata.addTaskOutput(file);
    eventStudio().broadcast(new TaskExecutionCompletedEvent(12, taskMetadata), "moduleId");
    FXTestUtils.invokeAndWait(() -> victim.dispatch(output), 1);
    click(victim);
    assertTrue(listener.isHit());
    assertTrue(listener.equal);
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:16,代碼來源:OpenButtonTest.java

示例8: disableOnFail

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void disableOnFail() {
    victim.setDisable(true);
    NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class);
    eventStudio().broadcast(new TaskExecutionFailedEvent(null, taskMetadata));
    assertFalse(victim.isDisabled());
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:8,代碼來源:RunButtonTest.java

示例9: enableOnComplete

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void enableOnComplete() {
    victim.setDisable(true);
    NotifiableTaskMetadata taskMetadata = mock(NotifiableTaskMetadata.class);
    eventStudio().broadcast(new TaskExecutionCompletedEvent(1, taskMetadata));
    assertFalse(victim.isDisabled());
}
 
開發者ID:torakiki,項目名稱:pdfsam,代碼行數:8,代碼來源:RunButtonTest.java

示例10: percentageConstructor

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
public void percentageConstructor() {
    PercentageOfWorkDoneChangedEvent victim = new PercentageOfWorkDoneChangedEvent(BigDecimal.ONE,
            NotifiableTaskMetadata.NULL);
    assertEquals(BigDecimal.ONE, victim.getPercentage());
    assertFalse(victim.isUndetermined());
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:8,代碼來源:PercentageOfWorkDoneChangedEventTest.java

示例11: assertOnEvent

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
public void assertOnEvent(Exception in, String expectedExceptionMessage) {
    try {
        victim.onEvent(new TaskExecutionFailedEvent(in, NotifiableTaskMetadata.NULL));
        fail("Expected an exception to be propagated");
    } catch (SejdaRuntimeException actual) {
        assertThat(actual.getMessage(), containsString(expectedExceptionMessage));
    }
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:9,代碼來源:DefaultTaskExecutionFailedEventListenerTest.java

示例12: executionFailed

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
private void executionFailed(Exception e, TaskExecutionContext executionContext) {
    if (executionContext == null) {
        notifyEvent(NotifiableTaskMetadata.NULL).taskFailed(e);
    } else {
        notifyEvent(executionContext.notifiableTaskMetadata()).taskFailed(e);
    }
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:8,代碼來源:DefaultTaskExecutionService.java

示例13: testNotificationContextUndetermined

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
private void testNotificationContextUndetermined(NotificationContext victim) {
    TestListenerPercentage listener = newPercentageListener();
    victim.addListener(listener);
    PercentageOfWorkDoneChangedEvent event = new PercentageOfWorkDoneChangedEvent(
            PercentageOfWorkDoneChangedEvent.UNDETERMINED, NotifiableTaskMetadata.NULL);
    assertTrue(event.isUndetermined());
    victim.notifyListeners(event);
    assertTrue(listener.isUndeterminate());
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:10,代碼來源:NotificationContextTest.java

示例14: testNotifyEvent

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
@Test
@SuppressWarnings("rawtypes")
public void testNotifyEvent() throws InterruptedException {
    EventListener listener = mock(EventListener.class);
    victim.notifyListener(listener, new TaskExecutionCompletedEvent(1L, NotifiableTaskMetadata.NULL));
    // FIXME
    // ugly but needed to give time for the async notification
    Thread.sleep(1000);
    verify(listener, times(1)).onEvent(Matchers.any(AbstractNotificationEvent.class));
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:11,代碼來源:AsyncNotificationStrategyTest.java

示例15: TaskExecutionFailedEvent

import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
public TaskExecutionFailedEvent(Exception failingCause, NotifiableTaskMetadata taskMetadata) {
    super(taskMetadata);
    this.failingCause = failingCause;
}
 
開發者ID:torakiki,項目名稱:sejda,代碼行數:5,代碼來源:TaskExecutionFailedEvent.java


注:本文中的org.sejda.model.task.NotifiableTaskMetadata類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。