RequestSort { public static RequestSort of(String fieldName, String type) { return of(fieldName, SortType.fromString(type)); } private  RequestSort(String fieldName, SortType type); static RequestSort of(String fieldName, String type); static RequestSort of(String fieldName, SortType type); String getFieldName(); SortType getType(); @Override String toString(); @Override final boolean equals(Object obj); @Override final int hashCode();  }
@Test(expected = IllegalArgumentException.class) public void testOfMethodShouldFailWhenIncorrectTypeSpecified() { RequestSort requestSort = RequestSort.of("fieldName", "wrongName"); }