Program: 60358
Project: 60358
Buggy source:
@SuppressWarnings("String_Node_Str") private static <T>void mapInjectorTest(Key<T> mapKey,TypeLiteral<?> keyType,TypeLiteral<?> valueType,Iterable<? extends Module> modules,boolean allowDuplicates,int expectedMapBindings,MapResult... results){
  Injector injector=Guice.createInjector(modules);
  Visitor<T> visitor=new Visitor<T>();
  Binding<T> mapBinding=injector.getBinding(mapKey);
  MapBinderBinding<T> mapbinder=(MapBinderBinding<T>)mapBinding.acceptTargetVisitor(visitor);
  assertNotNull(mapbinder);
  assertEquals(keyType,mapbinder.getKeyTypeLiteral());
  assertEquals(valueType,mapbinder.getValueTypeLiteral());
  assertEquals(allowDuplicates,mapbinder.permitsDuplicates());
  List<Map.Entry<?,Binding<?>>> entries=Lists.newArrayList(mapbinder.getEntries());
  List<MapResult> mapResults=Lists.newArrayList(results);
  assertEquals("String_Node_Str" + mapResults + "String_Node_Str"+ entries,mapResults.size(),entries.size());
  for (  MapResult result : mapResults) {
    Map.Entry<?,Binding<?>> found=null;
    for (    Map.Entry<?,Binding<?>> entry : entries) {
      Object key=entry.getKey();
      Binding<?> value=entry.getValue();
      if (!key.equals(result.k)) {
        continue;
      }
switch (result.v.type) {
case INSTANCE:
        if (value instanceof InstanceBinding && ((InstanceBinding)value).getInstance().equals(result.v.instance)) {
          found=entry;
        }
      break;
case LINKED:
    if (value instanceof LinkedKeyBinding && ((LinkedKeyBinding)value).getKey().equals(result.v.key)) {
      found=entry;
    }
  break;
case PROVIDER_INSTANCE:
if (value instanceof ProviderInstanceBinding && ((ProviderInstanceBinding)value).getProviderInstance().get().equals(result.v.instance)) {
  found=entry;
}
break;
}
}
if (found == null) {
fail("String_Node_Str" + result + "String_Node_Str"+ entries);
}
 else {
assertTrue(mapbinder.containsElement(found.getValue()));
entries.remove(found);
}
}
if (!entries.isEmpty()) {
fail("String_Node_Str" + mapResults + "String_Node_Str"+ entries);
}
Key<?> mapOfProvider=adapt(mapKey,mapOfProviderOf(keyType,valueType));
Key<?> mapOfSetOfProvider=adapt(mapKey,mapOfSetOfProviderOf(keyType,valueType));
Key<?> mapOfSet=adapt(mapKey,mapOf(keyType,setOf(valueType)));
Key<?> setOfEntry=adapt(mapKey,setOf(entryOfProviderOf(keyType,valueType)));
boolean entrySetMatch=false;
boolean mapProviderMatch=false;
boolean mapSetMatch=false;
boolean mapSetProviderMatch=false;
List<Object> otherMapBindings=Lists.newArrayList();
List<Binding> otherMatches=Lists.newArrayList();
for (Binding b : injector.getAllBindings().values()) {
boolean contains=mapbinder.containsElement(b);
Object visited=b.acceptTargetVisitor(visitor);
if (visited instanceof MapBinderBinding) {
if (visited.equals(mapbinder)) {
assertTrue(contains);
}
 else {
otherMapBindings.add(visited);
}
}
 else if (b.getKey().equals(mapOfProvider)) {
assertTrue(contains);
mapProviderMatch=true;
}
 else if (b.getKey().equals(mapOfSet)) {
assertTrue(contains);
mapSetMatch=true;
}
 else if (b.getKey().equals(mapOfSetOfProvider)) {
assertTrue(contains);
mapSetProviderMatch=true;
}
 else if (b.getKey().equals(setOfEntry)) {
assertTrue(contains);
entrySetMatch=true;
assertTrue(b.acceptTargetVisitor(visitor) instanceof MultibinderBinding);
}
 else if (contains) {
otherMatches.add(b);
}
}
int sizeOfOther=otherMatches.size();
if (allowDuplicates) {
sizeOfOther--;
}
sizeOfOther=sizeOfOther / 2;
assertEquals("String_Node_Str" + otherMatches,mapResults.size(),sizeOfOther);
assertTrue(entrySetMatch);
assertTrue(mapProviderMatch);
assertEquals(allowDuplicates,mapSetMatch);
assertEquals(allowDuplicates,mapSetProviderMatch);
assertEquals("String_Node_Str" + otherMapBindings,expectedMapBindings,otherMapBindings.size());
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static <T>void mapInjectorTest(Key<T> mapKey,TypeLiteral<?> keyType,TypeLiteral<?> valueType,Iterable<? extends Module> modules,boolean allowDuplicates,int expectedMapBindings,MapResult... results){
  Injector injector=Guice.createInjector(modules);
  Visitor<T> visitor=new Visitor<T>();
  Binding<T> mapBinding=injector.getBinding(mapKey);
  MapBinderBinding<T> mapbinder=(MapBinderBinding<T>)mapBinding.acceptTargetVisitor(visitor);
  assertNotNull(mapbinder);
  assertEquals(keyType,mapbinder.getKeyTypeLiteral());
  assertEquals(valueType,mapbinder.getValueTypeLiteral());
  assertEquals(allowDuplicates,mapbinder.permitsDuplicates());
  List<Map.Entry<?,Binding<?>>> entries=Lists.newArrayList(mapbinder.getEntries());
  List<MapResult> mapResults=Lists.newArrayList(results);
  assertEquals("String_Node_Str" + mapResults + "String_Node_Str"+ entries,mapResults.size(),entries.size());
  for (  MapResult result : mapResults) {
    Map.Entry<?,Binding<?>> found=null;
    for (    Map.Entry<?,Binding<?>> entry : entries) {
      Object key=entry.getKey();
      Binding<?> value=entry.getValue();
      if (!key.equals(result.k)) {
        continue;
      }
switch (result.v.type) {
case INSTANCE:
        if (value instanceof InstanceBinding && ((InstanceBinding)value).getInstance().equals(result.v.instance)) {
          found=entry;
        }
      break;
case LINKED:
    if (value instanceof LinkedKeyBinding && ((LinkedKeyBinding)value).getKey().equals(result.v.key)) {
      found=entry;
    }
  break;
case PROVIDER_INSTANCE:
if (value instanceof ProviderInstanceBinding && ((ProviderInstanceBinding)value).getProviderInstance().get().equals(result.v.instance)) {
  found=entry;
}
break;
}
}
if (found == null) {
fail("String_Node_Str" + result + "String_Node_Str"+ entries);
}
 else {
assertTrue(mapbinder.containsElement(found.getValue()));
entries.remove(found);
}
}
if (!entries.isEmpty()) {
fail("String_Node_Str" + mapResults + "String_Node_Str"+ entries);
}
Key<?> mapOfJavaxProvider=mapKey.ofType(mapOfJavaxProviderOf(keyType,valueType));
Key<?> mapOfProvider=mapKey.ofType(mapOfProviderOf(keyType,valueType));
Key<?> mapOfSetOfProvider=mapKey.ofType(mapOfSetOfProviderOf(keyType,valueType));
Key<?> mapOfSet=mapKey.ofType(mapOf(keyType,setOf(valueType)));
Key<?> setOfEntry=mapKey.ofType(setOf(entryOfProviderOf(keyType,valueType)));
boolean entrySetMatch=false;
boolean mapJavaxProviderMatch=false;
boolean mapProviderMatch=false;
boolean mapSetMatch=false;
boolean mapSetProviderMatch=false;
List<Object> otherMapBindings=Lists.newArrayList();
List<Binding> otherMatches=Lists.newArrayList();
for (Binding b : injector.getAllBindings().values()) {
boolean contains=mapbinder.containsElement(b);
Object visited=b.acceptTargetVisitor(visitor);
if (visited instanceof MapBinderBinding) {
if (visited.equals(mapbinder)) {
assertTrue(contains);
}
 else {
otherMapBindings.add(visited);
}
}
 else if (b.getKey().equals(mapOfProvider)) {
assertTrue(contains);
mapProviderMatch=true;
}
 else if (b.getKey().equals(mapOfJavaxProvider)) {
assertTrue(contains);
mapJavaxProviderMatch=true;
}
 else if (b.getKey().equals(mapOfSet)) {
assertTrue(contains);
mapSetMatch=true;
}
 else if (b.getKey().equals(mapOfSetOfProvider)) {
assertTrue(contains);
mapSetProviderMatch=true;
}
 else if (b.getKey().equals(setOfEntry)) {
assertTrue(contains);
entrySetMatch=true;
assertTrue(b.acceptTargetVisitor(visitor) instanceof MultibinderBinding);
}
 else if (contains) {
otherMatches.add(b);
}
}
int sizeOfOther=otherMatches.size();
if (allowDuplicates) {
sizeOfOther--;
}
sizeOfOther=sizeOfOther / 2;
assertEquals("String_Node_Str" + otherMatches,mapResults.size(),sizeOfOther);
assertTrue(entrySetMatch);
assertTrue(mapProviderMatch);
assertTrue(mapJavaxProviderMatch);
assertEquals(allowDuplicates,mapSetMatch);
assertEquals(allowDuplicates,mapSetProviderMatch);
assertEquals("String_Node_Str" + otherMapBindings,expectedMapBindings,otherMapBindings.size());
}