use of org.onap.so.db.catalog.utils.MavenLikeVersioningComparator in project so by onap.
the class MavenVersioningTest method testListSort.
@Test
public final void testListSort() {
MavenLikeVersioning test1 = new MavenLikeVersioning();
test1.setVersion("1.1");
MavenLikeVersioning test2 = new MavenLikeVersioning();
test2.setVersion("1.10");
MavenLikeVersioning test3 = new MavenLikeVersioning();
test3.setVersion("1.2");
MavenLikeVersioning test4 = new MavenLikeVersioning();
test4.setVersion("1.20");
MavenLikeVersioning test5 = new MavenLikeVersioning();
test5.setVersion("1.02");
MavenLikeVersioning test6 = new MavenLikeVersioning();
test6.setVersion("2.02");
MavenLikeVersioning test7 = new MavenLikeVersioning();
test7.setVersion("0.02");
MavenLikeVersioning test8 = new MavenLikeVersioning();
test8.setVersion("2.02");
MavenLikeVersioning test9 = new MavenLikeVersioning();
test9.setVersion("10.2004");
MavenLikeVersioning test10 = new MavenLikeVersioning();
test10.setVersion("2");
MavenLikeVersioning test11 = new MavenLikeVersioning();
test11.setVersion("12");
MavenLikeVersioning test12 = new MavenLikeVersioning();
test12.setVersion("2.0");
List<MavenLikeVersioning> list = new LinkedList<MavenLikeVersioning>();
list.add(test1);
list.add(test2);
list.add(test3);
list.add(test4);
list.add(test5);
list.add(test6);
list.add(test7);
list.add(test8);
list.add(test9);
list.add(test10);
list.add(test11);
list.add(test12);
Collections.sort(list, new MavenLikeVersioningComparator());
// Collections.reverse(list);
assertTrue(list.get(0).getVersion().equals("0.02"));
assertTrue(list.get(1).getVersion().equals("1.1"));
assertTrue(list.get(2).getVersion().equals("1.02") || list.get(3).getVersion().equals("1.02"));
assertTrue(list.get(3).getVersion().equals("1.2") || list.get(2).getVersion().equals("1.2"));
assertTrue(list.get(4).getVersion().equals("1.10"));
assertTrue(list.get(5).getVersion().equals("1.20"));
assertTrue(list.get(6).getVersion().equals("2"));
assertTrue(list.get(7).getVersion().equals("2.0"));
assertTrue(list.get(8).getVersion().equals("2.02"));
assertTrue(list.get(9).getVersion().equals("2.02"));
assertTrue(list.get(10).getVersion().equals("10.2004"));
assertTrue(list.get(11).getVersion().equals("12"));
}
Aggregations