src/test/java/tech/zettervall/openlibrary/rxclient/models/WorkTest.java
/**
     * Test the natural sorting of Work Objects.
     */
Test the natural sorting of Work Objects.
Test the natural sorting of Work Objects .
@Test
    public void compareTo() {
        List<Work> works = new ArrayList<>();
        works.add(Work.newWorkForTesting("B", 1));
        works.add(Work.newWorkForTesting("A", 2));
        works.add(Work.newWorkForTesting("C", 1));
        works.add(Work.newWorkForTesting("A", 1));
        works.add(Work.newWorkForTesting("A", 3));
        Collections.sort(works);
        assertEquals("A", works.get(0).getTitle());
        assertEquals(3, works.get(0).getRevision());
        assertEquals("A", works.get(1).getTitle());
        assertEquals(2, works.get(1).getRevision());
        assertEquals("A", works.get(2).getTitle());
        assertEquals(1, works.get(2).getRevision());
        assertEquals("B", works.get(3).getTitle());
        assertEquals(1, works.get(3).getRevision());
        assertEquals("C", works.get(4).getTitle());
        assertEquals(1, works.get(4).getRevision());
    }
@ Test public void compareTo ( ) { List < Work > works = new ArrayList < > ( ) ; works . add ( Work . newWorkForTesting ( "B" , 1 ) ) ; works . add ( Work . newWorkForTesting ( "A" , 2 ) ) ; works . add ( Work . newWorkForTesting ( "C" , 1 ) ) ; works . add ( Work . newWorkForTesting ( "A" , 1 ) ) ; works . add ( Work . newWorkForTesting ( "A" , 3 ) ) ; Collections . sort ( works ) ; assertEquals ( "A" , works . get ( 0 ) . getTitle ( ) ) ; assertEquals ( 3 , works . get ( 0 ) . getRevision ( ) ) ; assertEquals ( "A" , works . get ( 1 ) . getTitle ( ) ) ; assertEquals ( 2 , works . get ( 1 ) . getRevision ( ) ) ; assertEquals ( "A" , works . get ( 2 ) . getTitle ( ) ) ; assertEquals ( 1 , works . get ( 2 ) . getRevision ( ) ) ; assertEquals ( "B" , works . get ( 3 ) . getTitle ( ) ) ; assertEquals ( 1 , works . get ( 3 ) . getRevision ( ) ) ; assertEquals ( "C" , works . get ( 4 ) . getTitle ( ) ) ; assertEquals ( 1 , works . get ( 4 ) . getRevision ( ) ) ; }
Test the natural sorting of Work Objects.
Test the natural sorting of Work Objects .
// A3 // A2 // A1 // B1 // C1