GraphAnalysisLoader extends Loader { @VisibleForTesting static TypeElement resolveType(Elements elements, String className) { int index = nextDollar(className, className, 0); if (index == -1) { return getTypeElement(elements, className); } StringBuilder sb = new StringBuilder(className); return resolveType(elements, className, sb, index); } GraphAnalysisLoader(ProcessingEnvironment processingEnv); @Override Binding<?> getAtInjectBinding(
      String key, String className, ClassLoader classLoader, boolean mustHaveInjections); @Override ModuleAdapter<T> getModuleAdapter(Class<T> moduleClass); @Override StaticInjection getStaticInjection(Class<?> injectedClass);  }
@Test public void resolveType() { final List<String> resolveAttempts = new ArrayList<String>(); Elements elements = mock(Elements.class); when(elements.getTypeElement(any(CharSequence.class))).then(new Answer<TypeElement>() { @Override public TypeElement answer(InvocationOnMock invocationOnMock) throws Throwable { resolveAttempts.add(invocationOnMock.getArguments()[0].toString()); return null; } }); assertNull(GraphAnalysisLoader.resolveType(elements, "blah.blah.Foo$Bar$Baz")); List<String> expectedAttempts = ImmutableList.<String>builder() .add("blah.blah.Foo.Bar.Baz") .add("blah.blah.Foo.Bar$Baz") .add("blah.blah.Foo$Bar.Baz") .add("blah.blah.Foo$Bar$Baz") .build(); assertEquals(expectedAttempts, resolveAttempts); resolveAttempts.clear(); assertNull(GraphAnalysisLoader.resolveType(elements, "$$Foo$$Bar$$Baz$$")); expectedAttempts = ImmutableList.<String>builder() .add("$.Foo.$Bar.$Baz.$") .add("$.Foo.$Bar.$Baz$$") .add("$.Foo.$Bar$.Baz.$") .add("$.Foo.$Bar$.Baz$$") .add("$.Foo.$Bar$$Baz.$") .add("$.Foo.$Bar$$Baz$$") .add("$.Foo$.Bar.$Baz.$") .add("$.Foo$.Bar.$Baz$$") .add("$.Foo$.Bar$.Baz.$") .add("$.Foo$.Bar$.Baz$$") .add("$.Foo$.Bar$$Baz.$") .add("$.Foo$.Bar$$Baz$$") .add("$.Foo$$Bar.$Baz.$") .add("$.Foo$$Bar.$Baz$$") .add("$.Foo$$Bar$.Baz.$") .add("$.Foo$$Bar$.Baz$$") .add("$.Foo$$Bar$$Baz.$") .add("$.Foo$$Bar$$Baz$$") .add("$$Foo.$Bar.$Baz.$") .add("$$Foo.$Bar.$Baz$$") .add("$$Foo.$Bar$.Baz.$") .add("$$Foo.$Bar$.Baz$$") .add("$$Foo.$Bar$$Baz.$") .add("$$Foo.$Bar$$Baz$$") .add("$$Foo$.Bar.$Baz.$") .add("$$Foo$.Bar.$Baz$$") .add("$$Foo$.Bar$.Baz.$") .add("$$Foo$.Bar$.Baz$$") .add("$$Foo$.Bar$$Baz.$") .add("$$Foo$.Bar$$Baz$$") .add("$$Foo$$Bar.$Baz.$") .add("$$Foo$$Bar.$Baz$$") .add("$$Foo$$Bar$.Baz.$") .add("$$Foo$$Bar$.Baz$$") .add("$$Foo$$Bar$$Baz.$") .add("$$Foo$$Bar$$Baz$$") .build(); assertEquals(expectedAttempts, resolveAttempts); Mockito.validateMockitoUsage(); }