@Test public void shouldThrowOnInvalidSortOption() { List<Integer> invalidOptions = asList(-1, 14, 65535, 8); for (Integer item : invalidOptions) { try { mInstance.performSortOperation(item, mFiles); } catch (IllegalArgumentException ex) { Assert.assertTrue(ex.getMessage().startsWith("Invalid sort option")); } } }
public void performSortOperation(int option, List<File> pdf) { switch (option) { case DATE_INDEX: sortFilesByDateNewestToOldest(pdf); break; case NAME_INDEX: sortByNameAlphabetical(pdf); break; case SIZE_INCREASING_ORDER_INDEX: sortFilesBySizeIncreasingOrder(pdf); break; case SIZE_DECREASING_ORDER_INDEX: sortFilesBySizeDecreasingOrder(pdf); break; } }
FileSortUtils { public void performSortOperation(int option, List<File> pdf) { switch (option) { case DATE_INDEX: sortFilesByDateNewestToOldest(pdf); break; case NAME_INDEX: sortByNameAlphabetical(pdf); break; case SIZE_INCREASING_ORDER_INDEX: sortFilesBySizeIncreasingOrder(pdf); break; case SIZE_DECREASING_ORDER_INDEX: sortFilesBySizeDecreasingOrder(pdf); break; } } }
FileSortUtils { public void performSortOperation(int option, List<File> pdf) { switch (option) { case DATE_INDEX: sortFilesByDateNewestToOldest(pdf); break; case NAME_INDEX: sortByNameAlphabetical(pdf); break; case SIZE_INCREASING_ORDER_INDEX: sortFilesBySizeIncreasingOrder(pdf); break; case SIZE_DECREASING_ORDER_INDEX: sortFilesBySizeDecreasingOrder(pdf); break; } } private  FileSortUtils(); }
FileSortUtils { public void performSortOperation(int option, List<File> pdf) { switch (option) { case DATE_INDEX: sortFilesByDateNewestToOldest(pdf); break; case NAME_INDEX: sortByNameAlphabetical(pdf); break; case SIZE_INCREASING_ORDER_INDEX: sortFilesBySizeIncreasingOrder(pdf); break; case SIZE_DECREASING_ORDER_INDEX: sortFilesBySizeDecreasingOrder(pdf); break; } } private  FileSortUtils(); void performSortOperation(int option, List<File> pdf); static FileSortUtils getInstance(); }
FileSortUtils { public void performSortOperation(int option, List<File> pdf) { switch (option) { case DATE_INDEX: sortFilesByDateNewestToOldest(pdf); break; case NAME_INDEX: sortByNameAlphabetical(pdf); break; case SIZE_INCREASING_ORDER_INDEX: sortFilesBySizeIncreasingOrder(pdf); break; case SIZE_DECREASING_ORDER_INDEX: sortFilesBySizeDecreasingOrder(pdf); break; } } private  FileSortUtils(); void performSortOperation(int option, List<File> pdf); static FileSortUtils getInstance(); final int NAME_INDEX; final int DATE_INDEX; final int SIZE_INCREASING_ORDER_INDEX; final int SIZE_DECREASING_ORDER_INDEX; }