SimpleTypeUtil { public static String nameOf(File file, ClassOrInterface<?> clazz) { return Formatting.fileToClassName(file.getName()) .flatMap(Formatting::packageName) .orElseThrow( () -> new RuntimeException( "File did not have appropriate name." ) ) + "." + pathTo(file, clazz.getName()); } private  SimpleTypeUtil(); static String nameOf(File file, ClassOrInterface<?> clazz);  }
@Test void nameOfIllegalFileName() { final File file = File.of("com.company.module.Foo.c++"); final Class clazz = Class.of("Bar"); assertThrows(RuntimeException.class, () -> SimpleTypeUtil.nameOf(file, clazz)); }
@Test void nameOfNoClass() { final File file = File.of("com.company.module.Foo.java"); final Class clazz = Class.of("Bar"); assertThrows(RuntimeException.class, () -> SimpleTypeUtil.nameOf(file, clazz)); }
@Test void nameOf() { final File file = File.of("com.company.module.Foo.java"); final Class clazz = Class.of("Foo"); file.add(clazz); assertDoesNotThrow(() -> SimpleTypeUtil.nameOf(file, clazz)); }