FileNameUtil { public static String removeExtension(final Path path, final ResourceTypeDefinition type) { if (path == null) { return null; } final String fileName = path.getFileName(); if (type == null) { return fileName; } return removeExtension(path, type.getSuffix()); }  static String removeExtension(final Path path,
                                         final ResourceTypeDefinition type); static String removeExtension(final Path path,
                                         final String extension); static String removeExtension(final String fileName,
                                         final String extension);  }
@Test public void removeExtensionFromFileNameTest() { assertNull(removeExtension((String) null, ".java")); assertEquals("file.java", removeExtension("file.java", null)); assertEquals("file.java", removeExtension("file.java", "")); assertEquals("file", removeExtension("file.java", "java")); }
@Test public void removeExtensionFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file.java", removeExtension(path, (String) null)); assertEquals("file.java", removeExtension(path, "")); assertEquals("file", removeExtension(path, "java")); }
@Test public void removeResourceTypeDefinitionSuffixFromPathTest() { final Path path = mock(Path.class); doReturn("file.java").when(path).getFileName(); final ResourceTypeDefinition resourceTypeDefinition = mock(ResourceTypeDefinition.class); doReturn("java").when(resourceTypeDefinition).getSuffix(); assertNull(removeExtension((Path) null, ".java")); assertEquals("file", removeExtension(path, resourceTypeDefinition)); }