@Test public void testSample() throws Exception { final Date timestamp1 = timestampProvider.sample(); assertNotNull(timestamp1); for (int i = 0; i < 10; i++) { Thread.sleep(100); assertEquals(timestamp1, timestampProvider.getSampledTimestamp()); } final Date timestamp2 = timestampProvider.sample(); assertFalse(timestamp1.equals(timestamp2)); assertNotNull(timestamp2); for (int i = 0; i < 10; i++) { Thread.sleep(100); assertEquals(timestamp2, timestampProvider.getSampledTimestamp()); } }
@Nonnull public Collection<? extends MetadataItemHolder<MetadataItemMock>> loadMetadataItems (final DataObject dataObject, final FindOption ... options) { final String name = dataObject.getName(); if (name.contains("noitem")) { return Collections.emptyList(); } final MetadataItemMock item = MetadataItemEnhancer.createEnhancedItem(new MetadataItemMock()); item.setName("the name"); return Collections.singletonList(new MetadataItemHolderMock<MetadataItemMock>(item, getName(), "Mock", TimestampProvider.Locator.findTimestampProvider().getTimestamp())); } }
@Test public void testGetSampledTimestampWithNoSample() { assertNotNull(timestampProvider.getSampledTimestamp()); }
@Nonnull public Collection<? extends MetadataItemHolder<TIFF>> loadMetadataItems (final DataObject dataObject, final FindOption ... options) { final String name = dataObject.getPrimaryFile().getNameExt(); if (name.contains("bad")) { return Collections.emptyList(); } final TIFF tiff = new TIFF(); tiff.setArtist("..."); // set a property to make it "available" return Collections.singletonList(new DirectoryMetadataItemHolder<TIFF>(tiff, getName(), "Mock", TimestampProvider.Locator.findTimestampProvider().getTimestamp())); } }