NameGenerator { protected static String removeCopyPrefix(String name) { RegExp regexp = RegExp.compile("Copy\\d* of (.*)"); MatchResult matchResult = regexp.exec(name); if (matchResult == null || matchResult.getGroupCount() != 2) { return name; } return matchResult.getGroup(1); } private  NameGenerator(); @NotNull static String generateCopy(@NotNull String name, @NotNull List<Environment> projectEnvironments); static String generateCustomEnvironmentName(@NotNull List<Environment> environments, @NotNull String projectName);  }
@Test public void removeNonExistingPrefix() { String name = NameGenerator.removeCopyPrefix("removeNonExistingPrefix of hello"); assertEquals("removeNonExistingPrefix of hello", name); }
@Test public void removeCopyPrefix() { String name = NameGenerator.removeCopyPrefix(COPY_HELLO); assertEquals(HELLO, name); }
@Test public void removeCopy2Prefix() { String name = NameGenerator.removeCopyPrefix(COPY2_HELLO); assertEquals(HELLO, name); }
@Test public void removeCopy1234Prefix() { String name = NameGenerator.removeCopyPrefix("Copy1234 of hello"); assertEquals(HELLO, name); }