本文整理匯總了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);
}
示例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);
}
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
}
示例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);
}
}
示例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());
}
示例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));
}
示例15: TaskExecutionFailedEvent
import org.sejda.model.task.NotifiableTaskMetadata; //導入依賴的package包/類
public TaskExecutionFailedEvent(Exception failingCause, NotifiableTaskMetadata taskMetadata) {
super(taskMetadata);
this.failingCause = failingCause;
}