GraphExportStyles { @SuppressWarnings("squid:S4248") public static String getLabel(List<Abbreviation> abbreviations, String name) { checkNotNull(abbreviations, "abbreviations"); if (name == null) { return null; } String result = name; for (Abbreviation abbreviation : abbreviations) { result = abbreviation.abbreviate(result); } result = result.replaceAll("_ROOT$", ""); return result; } private  GraphExportStyles(); static EdgeStyle getEdgeStyle(Dependency rel); @SuppressWarnings("squid:S4248") // wants to move the RegExes into constants; would not help readability here. static String getId(String classname); @SuppressWarnings("squid:S4248") // wants to move the RegExes into constants; would not help readability here. static String getLabel(List<Abbreviation> abbreviations, String name);  }
@Test public void testGetLabel() { List<Abbreviation> abbreviations = Lists.newArrayList(new Abbreviation("com.my", "C"), new Abbreviation("org.apache", "A")); assertThat(GraphExportStyles.getLabel(abbreviations, "com.my.any.Clazz"), is("C.any.Clazz")); assertThat(GraphExportStyles.getLabel(abbreviations, "org.apache.Helper"), is("A.Helper")); assertThat(GraphExportStyles.getLabel(abbreviations, "org.apache"), is("A")); assertThat(GraphExportStyles.getLabel(abbreviations, "org"), is("org")); }
@Test public void testGetLabelNoAbbreviations() { assertThat(GraphExportStyles.getLabel(new ArrayList<>(), "com.my.any.Clazz"), is("com.my.any.Clazz")); }
@Test(expected = NullPointerException.class) public void testGetLabelNullAbbreviations() { GraphExportStyles.getLabel(null, "com.my.any.Clazz"); }
@Test public void testGetLabelNullName() { assertThat(GraphExportStyles.getLabel(new ArrayList<>(), null), nullValue()); }