### Question:
SortParser implements ISortParser { @Override public List<Sort> parse(String unparsedSort, String unparsedDir) { if (unparsedSort == null || unparsedSort.isEmpty()) { return Collections.emptyList(); } List<Sort> orderings = new ArrayList<>(3); if (unparsedSort.startsWith("[")) { appendFromArray(orderings, jsonParser.parseJson(unparsedSort)); } else if (unparsedSort.startsWith("{")) { appendFromObject(orderings, jsonParser.parseJson(unparsedSort)); } else { appendPath(orderings, unparsedSort, unparsedDir); } return orderings; } SortParser(@Inject IJacksonService jsonParser); @Override List<Sort> parse(String unparsedSort, String unparsedDir); @Override List<Sort> parseJson(JsonNode json);  }### Answer:
@Test public void testProcess_Array() { List<Sort> orderings = parser.parse("[{\"property\":\"name\"}," + "{\"property\":\"address\",\"direction\":\"ASC\"}," + "{\"property\":\"city\",\"direction\":\"DESC_CI\"}]", null); assertNotNull(orderings); assertEquals(3, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.ASC, orderings.get(0).getDirection()); assertEquals("address", orderings.get(1).getProperty()); assertEquals(Dir.ASC, orderings.get(1).getDirection()); assertEquals("city", orderings.get(2).getProperty()); assertEquals(Dir.DESC_CI, orderings.get(2).getDirection()); }
@Test public void testProcess_Object() { List<Sort> orderings = parser.parse("{\"property\":\"name\"}", null); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.ASC, orderings.get(0).getDirection()); }
@Test public void testProcess_Simple() { List<Sort> orderings = parser.parse("name", null); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.ASC, orderings.get(0).getDirection()); }
@Test public void testProcess_Simple_ASC() { List<Sort> orderings = parser.parse("name", "ASC"); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.ASC, orderings.get(0).getDirection()); }
@Test public void testProcess_Simple_DESC() { List<Sort> orderings = parser.parse("name", "DESC"); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.DESC, orderings.get(0).getDirection()); }
@Test public void testProcess_Simple_ASC_INSENSITIVE() { List<Sort> orderings = parser.parse("name", "ASC_CI"); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.ASC_CI, orderings.get(0).getDirection()); }
@Test public void testProcess_Simple_DESC_INSENSITIVE() { List<Sort> orderings = parser.parse("name", "DESC_CI"); assertEquals(1, orderings.size()); assertEquals("name", orderings.get(0).getProperty()); assertEquals(Dir.DESC_CI, orderings.get(0).getDirection()); }