Program: 5043
Project: 5043
Buggy source:
@Test public void testGetPlugins() throws Exception {
  ArtifactRange parentArtifacts=new ArtifactRange(NamespaceId.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str"));
  PluginClass pluginA1=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",false,false)));
  PluginClass pluginA2=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false)));
  PluginClass pluginB1=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",false,false)));
  PluginClass pluginB2=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false)));
  String contents="String_Node_Str";
  Id.Artifact parentArtifactId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta parentMeta=new ArtifactMeta(ArtifactClasses.builder().build());
  writeArtifact(parentArtifactId,parentMeta,contents);
  Id.Artifact artifactXv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv100=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginA1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv100,metaXv100,contents);
  ArtifactDescriptor artifactXv100Info=artifactStore.getArtifact(artifactXv100).getDescriptor();
  Id.Artifact artifactXv110=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv110=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginA1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv110,metaXv110,contents);
  ArtifactDescriptor artifactXv110Info=artifactStore.getArtifact(artifactXv110).getDescriptor();
  Id.Artifact artifactXv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv200=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginA2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv200,metaXv200,contents);
  ArtifactDescriptor artifactXv200Info=artifactStore.getArtifact(artifactXv200).getDescriptor();
  Id.Artifact artifactYv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaYv100=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginB1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactYv100,metaYv100,contents);
  ArtifactDescriptor artifactYv100Info=artifactStore.getArtifact(artifactYv100).getDescriptor();
  Id.Artifact artifactYv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaYv200=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginB2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactYv200,metaYv200,contents);
  ArtifactDescriptor artifactYv200Info=artifactStore.getArtifact(artifactYv200).getDescriptor();
  Id.Artifact artifactZv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaZv100=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginB1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactZv100,metaZv100,contents);
  ArtifactDescriptor artifactZv100Info=artifactStore.getArtifact(artifactZv100).getDescriptor();
  Id.Artifact artifactZv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaZv200=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginA2,pluginB1,pluginB2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactZv200,metaZv200,contents);
  ArtifactDescriptor artifactZv200Info=artifactStore.getArtifact(artifactZv200).getDescriptor();
  Map<ArtifactDescriptor,Set<PluginClass>> expected=Maps.newHashMap();
  expected.put(artifactXv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv110Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv200Info,ImmutableSet.of(pluginA1,pluginA2));
  expected.put(artifactYv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactYv200Info,ImmutableSet.of(pluginB2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginA1,pluginB1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginA1,pluginA2,pluginB1,pluginB2));
  Map<ArtifactDescriptor,Set<PluginClass>> actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId);
  Assert.assertEquals(expected,actual);
  expected=Maps.newHashMap();
  expected.put(artifactXv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv110Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv200Info,ImmutableSet.of(pluginA1,pluginA2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginA1,pluginA2));
  actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str");
  Assert.assertEquals(expected,actual);
  expected=Maps.newHashMap();
  expected.put(artifactYv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactYv200Info,ImmutableSet.of(pluginB2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginB1,pluginB2));
  actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str");
  Assert.assertEquals(expected,actual);
  Map<ArtifactDescriptor,PluginClass> expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv100Info,pluginA1);
  expectedMap.put(artifactXv110Info,pluginA1);
  expectedMap.put(artifactXv200Info,pluginA1);
  expectedMap.put(artifactZv100Info,pluginA1);
  expectedMap.put(artifactZv200Info,pluginA1);
  Map<ArtifactDescriptor,PluginClass> actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,1,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(ImmutableMap.of(artifactXv100Info,pluginA1),actualMap);
  actualMap=new TreeMap<>(artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.DESC));
  Assert.assertEquals(expectedMap,new TreeMap<>(actualMap).descendingMap());
  Predicate<ArtifactId> predicate=new Predicate<ArtifactId>(){
    @Override public boolean apply(    ArtifactId input){
      try {
        return input.getParent().equals(NamespaceId.DEFAULT) && input.getArtifact().equals("String_Node_Str") && ArtifactVersionRange.parse("String_Node_Str").versionIsInRange(new ArtifactVersion(input.getVersion()));
      }
 catch (      InvalidArtifactRangeException e) {
        return false;
      }
    }
  }
;
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv100Info,pluginA1);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",predicate,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv200Info,pluginA2);
  expectedMap.put(artifactZv200Info,pluginA2);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactYv100Info,pluginB1);
  expectedMap.put(artifactZv100Info,pluginB1);
  expectedMap.put(artifactZv200Info,pluginB1);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactYv200Info,pluginB2);
  expectedMap.put(artifactZv200Info,pluginB2);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
}

Fixed version (ground truth):
@Test public void testGetPlugins() throws Exception {
  ArtifactRange parentArtifacts=new ArtifactRange(NamespaceId.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str"));
  PluginClass pluginA1=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",false,false)));
  PluginClass pluginA2=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false)));
  PluginClass pluginB1=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",false,false)));
  PluginClass pluginB2=new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true,false)));
  String contents="String_Node_Str";
  Id.Artifact parentArtifactId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta parentMeta=new ArtifactMeta(ArtifactClasses.builder().build());
  writeArtifact(parentArtifactId,parentMeta,contents);
  Id.Artifact artifactXv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv100=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginA1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv100,metaXv100,contents);
  ArtifactDescriptor artifactXv100Info=artifactStore.getArtifact(artifactXv100).getDescriptor();
  Id.Artifact artifactXv110=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv110=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginA1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv110,metaXv110,contents);
  ArtifactDescriptor artifactXv110Info=artifactStore.getArtifact(artifactXv110).getDescriptor();
  Id.Artifact artifactXv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaXv200=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginA2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactXv200,metaXv200,contents);
  ArtifactDescriptor artifactXv200Info=artifactStore.getArtifact(artifactXv200).getDescriptor();
  Id.Artifact artifactYv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaYv100=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginB1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactYv100,metaYv100,contents);
  ArtifactDescriptor artifactYv100Info=artifactStore.getArtifact(artifactYv100).getDescriptor();
  Id.Artifact artifactYv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaYv200=new ArtifactMeta(ArtifactClasses.builder().addPlugin(pluginB2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactYv200,metaYv200,contents);
  ArtifactDescriptor artifactYv200Info=artifactStore.getArtifact(artifactYv200).getDescriptor();
  Id.Artifact artifactZv100=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaZv100=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginB1).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactZv100,metaZv100,contents);
  ArtifactDescriptor artifactZv100Info=artifactStore.getArtifact(artifactZv100).getDescriptor();
  Id.Artifact artifactZv200=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  ArtifactMeta metaZv200=new ArtifactMeta(ArtifactClasses.builder().addPlugins(pluginA1,pluginA2,pluginB1,pluginB2).build(),ImmutableSet.of(parentArtifacts));
  writeArtifact(artifactZv200,metaZv200,contents);
  ArtifactDescriptor artifactZv200Info=artifactStore.getArtifact(artifactZv200).getDescriptor();
  Map<ArtifactDescriptor,Set<PluginClass>> expected=Maps.newHashMap();
  expected.put(artifactXv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv110Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv200Info,ImmutableSet.of(pluginA1,pluginA2));
  expected.put(artifactYv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactYv200Info,ImmutableSet.of(pluginB2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginA1,pluginB1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginA1,pluginA2,pluginB1,pluginB2));
  Map<ArtifactDescriptor,Set<PluginClass>> actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId);
  Assert.assertEquals(expected,actual);
  expected=Maps.newHashMap();
  expected.put(artifactXv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv110Info,ImmutableSet.of(pluginA1));
  expected.put(artifactXv200Info,ImmutableSet.of(pluginA1,pluginA2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginA1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginA1,pluginA2));
  actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str");
  Assert.assertEquals(expected,actual);
  expected=Maps.newHashMap();
  expected.put(artifactYv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactYv200Info,ImmutableSet.of(pluginB2));
  expected.put(artifactZv100Info,ImmutableSet.of(pluginB1));
  expected.put(artifactZv200Info,ImmutableSet.of(pluginB1,pluginB2));
  actual=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str");
  Assert.assertEquals(expected,actual);
  Map<ArtifactDescriptor,PluginClass> expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv100Info,pluginA1);
  expectedMap.put(artifactXv110Info,pluginA1);
  expectedMap.put(artifactXv200Info,pluginA1);
  expectedMap.put(artifactZv100Info,pluginA1);
  expectedMap.put(artifactZv200Info,pluginA1);
  Map<ArtifactDescriptor,PluginClass> actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,1,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(ImmutableMap.of(artifactXv100Info,pluginA1),actualMap);
  actualMap=new TreeMap<>(artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.DESC));
  Assert.assertEquals(expectedMap,new TreeMap<>(actualMap).descendingMap());
  Predicate<ArtifactId> predicate=new Predicate<ArtifactId>(){
    @Override public boolean apply(    ArtifactId input){
      try {
        return input.getParent().equals(NamespaceId.DEFAULT) && input.getArtifact().equals("String_Node_Str") && ArtifactVersionRange.parse("String_Node_Str").versionIsInRange(new ArtifactVersion(input.getVersion()));
      }
 catch (      InvalidArtifactRangeException e) {
        return false;
      }
    }
  }
;
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv100Info,pluginA1);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",predicate,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,1,ArtifactSortOrder.DESC);
  Assert.assertEquals(ImmutableMap.of(artifactZv200Info,pluginA1),actualMap);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",predicate,1,ArtifactSortOrder.DESC);
  Assert.assertEquals(ImmutableMap.of(artifactXv100Info,pluginA1),actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactXv200Info,pluginA2);
  expectedMap.put(artifactZv200Info,pluginA2);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactYv100Info,pluginB1);
  expectedMap.put(artifactZv100Info,pluginB1);
  expectedMap.put(artifactZv200Info,pluginB1);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
  expectedMap=Maps.newHashMap();
  expectedMap.put(artifactYv200Info,pluginB2);
  expectedMap.put(artifactZv200Info,pluginB2);
  actualMap=artifactStore.getPluginClasses(NamespaceId.DEFAULT,parentArtifactId,"String_Node_Str","String_Node_Str",null,Integer.MAX_VALUE,ArtifactSortOrder.UNORDERED);
  Assert.assertEquals(expectedMap,actualMap);
}