GraphVisualizer { String shortName(String key) { Matcher matcher = KEY_PATTERN.matcher(key); if (!matcher.matches()) throw new IllegalArgumentException("Unexpected key: " + key); StringBuilder result = new StringBuilder(); String annotationSimpleName = matcher.group(1); if (annotationSimpleName != null) { result.append('@').append(annotationSimpleName).append(' '); } String simpleName = matcher.group(2); result.append(simpleName); String typeParameters = matcher.group(3); if (typeParameters != null) { result.append(typeParameters); } String arrays = matcher.group(4); if (arrays != null) { result.append(arrays); } return result.toString(); }  void write(Map<String, Binding<?>> bindings, GraphVizWriter writer);  }
@Test public void testSimpleKey() throws Exception { String key = fieldKey("simpleKey"); assertThat(graphVisualizer.shortName(key)).isEqualTo("String"); }
@Test public void testAnnotatedKey() throws Exception { String key = fieldKey("annotatedKey"); assertThat(graphVisualizer.shortName(key)).isEqualTo("@Named String"); }
@Test public void testAnnotatedKeyWithParameters() throws Exception { String key = fieldKey("annotatedKeyWithParameters"); assertThat(graphVisualizer.shortName(key)).isEqualTo("@Named String"); }
@Test public void testArrayKey() throws Exception { String key = fieldKey("arrayKey"); assertThat(graphVisualizer.shortName(key)).isEqualTo("String[][]"); }
@Test public void testTypeParameterKey() throws Exception { String key = fieldKey("typeParameterKey"); assertThat(graphVisualizer.shortName(key)) .isEqualTo("Map<java.lang.String, java.util.Set<java.lang.Object>>"); }
@Test public void testEverythingKey() throws Exception { String key = fieldKey("everythingKey"); assertThat(graphVisualizer.shortName(key)) .isEqualTo("@Named Map<java.lang.String, java.util.Set<java.lang.Object>>[]"); }
@Test public void testMembersKey() throws Exception { String key = Keys.getMembersKey(String.class); assertThat(graphVisualizer.shortName(key)).isEqualTo("String"); }