PlaceHistoryGeneratorContext { void ensureInitialized() { if (this.tokenizers == null) { assert this.placeTypes.isEmpty(); this.tokenizers = new HashMap<>(); this.initTokenizerGetters(); this.initTokenizersWithoutGetters(); } } PlaceHistoryGeneratorContext(
      Messager messager,
      Types types,
      Elements elements,
      TypeElement interfaceType,
      DeclaredType factoryType,
      TypeElement stringType,
      TypeElement placeTokenizerType,
      String packageName,
      String implName); Set<TypeElement> getPlaceTypes(); String getPrefix(TypeElement placeType); Set<String> getPrefixes(); ExecutableElement getTokenizerGetter(String prefix); TypeElement getTokenizerType(String prefix);  }
@Test public void testDuplicatePrefix() { PlaceHistoryGeneratorContext context = createContext( MapperWithDuplicatePrefix.class.getCanonicalName(), MapperWithDuplicatePrefix.Factory.class.getCanonicalName()); context.ensureInitialized(); verify(messager) .printMessage( eq(Diagnostic.Kind.ERROR), eq( String.format( "Found duplicate place prefix \"%s\" on %s, already seen on %s", Place1.Tokenizer.PREFIX, Place1.Tokenizer.class.getCanonicalName(), MapperWithDuplicatePrefix.Factory.class.getCanonicalName() + "#tokenizer2()")), any(Element.class)); }
@Test public void testDuplicatePlaceType() { PlaceHistoryGeneratorContext context = createContext( MapperWithDuplicatePlaceType.class.getCanonicalName(), MapperWithDuplicatePlaceType.Factory.class.getCanonicalName()); context.ensureInitialized(); verify(messager) .printMessage( eq(Diagnostic.Kind.ERROR), eq( String.format( "Found duplicate tokenizer's place type \"%s\" on %s, already seen on %s", Place1.class.getCanonicalName(), Place1.Tokenizer.class.getCanonicalName(), MapperWithDuplicatePlaceType.Factory.class.getCanonicalName() + "#bar()")), any(Element.class)); }
@Test public void testPrefixContainingColon() { PlaceHistoryGeneratorContext context = createContext( MapperWithPrefixContainingColon.class.getCanonicalName(), MapperWithPrefixContainingColon.Factory.class.getCanonicalName()); context.ensureInitialized(); verify(messager) .printMessage( eq(Diagnostic.Kind.ERROR), eq( "Found place prefix \"foo:bar\" containing separator char \":\", on " + MapperWithPrefixContainingColon.Factory.class.getCanonicalName() + "#foo_bar()"), any(Element.class)); }