UncheckedUtils { public static <T> T uncheckedCast(Object object) { return (T) object; } protected  UncheckedUtils(); static T uncheckedCast(Object object);  }
@Test public void uncheckedCast_rawList_empty() { List rawList = new ArrayList(); List<String> value = uncheckedCast(rawList); assertThat(value).isSameAs(rawList); }
@Test public void uncheckedCast_rawList_nonEmpty() { List rawList = new ArrayList(); rawList.add("1"); rawList.add("2"); List<String> value = uncheckedCast(rawList); assertThat(value).isSameAs(rawList); }
@Test public void uncheckedCast_rawList_wrongTypes() { List rawList = new ArrayList(); rawList.add(1); rawList.add(2); List<String> wrongType = uncheckedCast(rawList); Throwable thrown = catchThrowable(() -> wrongType.get(0)); assertThat(thrown).isInstanceOf(ClassCastException.class); }