Search in sources :

Example 1 with TimeOffsetImageComparator

use of org.fagu.fmv.mymedia.classify.image.TimeOffsetImageComparator in project fmv by f-agu.

the class TimeOffsetImageComparatorTestCase method testSome.

/**
 */
@Test
public void testSome() {
    TimeOffsetImageComparator comparator = new TimeOffsetImageComparator();
    comparator.addFilter(im -> "a".equals(im.getDevice()), 17);
    // 18 = 1 + 17
    FileFinder<Image>.InfosFile imageA1 = mockImage(1, "a", "a", "A1");
    // 21 = 4 + 17
    FileFinder<Image>.InfosFile imageA2 = mockImage(4, "a", "a", "A2");
    // 12
    FileFinder<Image>.InfosFile imageB1 = mockImage(15, "b", "b", "B1");
    // 15
    FileFinder<Image>.InfosFile imageB2 = mockImage(12, "b", "b", "B2");
    // 17
    FileFinder<Image>.InfosFile imageB3 = mockImage(17, "b", "b", "B3");
    // 19
    FileFinder<Image>.InfosFile imageB4 = mockImage(19, "b", "b", "B4");
    TreeSet<FileFinder<Image>.InfosFile> images = new TreeSet<>(comparator);
    images.add(imageA1);
    images.add(imageA2);
    images.add(imageB1);
    images.add(imageB2);
    images.add(imageB3);
    images.add(imageB4);
    Iterator<FileFinder<Image>.InfosFile> iterator = images.iterator();
    assertSame(imageB2, iterator.next());
    assertSame(imageB1, iterator.next());
    assertSame(imageB3, iterator.next());
    assertSame(imageA1, iterator.next());
    assertSame(imageB4, iterator.next());
    assertSame(imageA2, iterator.next());
    assertFalse(iterator.hasNext());
}
Also used : InfosFile(org.fagu.fmv.utils.file.FileFinder.InfosFile) TreeSet(java.util.TreeSet) TimeOffsetImageComparator(org.fagu.fmv.mymedia.classify.image.TimeOffsetImageComparator) FileFinder(org.fagu.fmv.utils.file.FileFinder) Image(org.fagu.fmv.im.Image) Test(org.junit.Test)

Example 2 with TimeOffsetImageComparator

use of org.fagu.fmv.mymedia.classify.image.TimeOffsetImageComparator in project fmv by f-agu.

the class TimeOffsetImageComparatorTestCase method testEmpty.

/**
 */
@Test
public void testEmpty() {
    TimeOffsetImageComparator comparator = new TimeOffsetImageComparator();
    FileFinder<Image>.InfosFile image1 = mockImage(1, "1");
    FileFinder<Image>.InfosFile image2 = mockImage(2, "2");
    FileFinder<Image>.InfosFile image1b = mockImage(1, "1b");
    assertEquals(-1, comparator.compare(image1, image2));
    assertEquals(1, comparator.compare(image2, image1));
    assertEquals(1, comparator.compare(image1b, image1));
}
Also used : TimeOffsetImageComparator(org.fagu.fmv.mymedia.classify.image.TimeOffsetImageComparator) FileFinder(org.fagu.fmv.utils.file.FileFinder) Test(org.junit.Test)

Aggregations

TimeOffsetImageComparator (org.fagu.fmv.mymedia.classify.image.TimeOffsetImageComparator)2 FileFinder (org.fagu.fmv.utils.file.FileFinder)2 Test (org.junit.Test)2 TreeSet (java.util.TreeSet)1 Image (org.fagu.fmv.im.Image)1 InfosFile (org.fagu.fmv.utils.file.FileFinder.InfosFile)1