Program: 6226
Project: 6226
Buggy source:
@Test public void testArtifacts() throws Exception {
  Id.Artifact myapp1Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Id.Artifact myapp2Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  LocalLocationFactory locationFactory=new LocalLocationFactory(tmpFolder.newFolder());
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.BUNDLE_VERSION,"String_Node_Str");
  final Location appJarLoc=AppJarHelper.createDeploymentJar(locationFactory,MyApp.class,manifest);
  InputSupplier<InputStream> inputSupplier=new InputSupplier<InputStream>(){
    @Override public InputStream getInput() throws IOException {
      return appJarLoc.getInputStream();
    }
  }
;
  artifactClient.add(myapp1Id.getNamespace(),myapp1Id.getName(),inputSupplier,myapp1Id.getVersion().getVersion());
  Map<String,String> myapp1Properties=ImmutableMap.of("String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp1Id,myapp1Properties);
  artifactClient.add(myapp2Id.getNamespace(),myapp2Id.getName(),inputSupplier,null,null);
  Map<String,String> myapp2Properties=ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp2Id,myapp2Properties);
  Id.Artifact pluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
  final Location pluginJarLoc=PluginJarHelper.createPluginJar(locationFactory,manifest,Plugin1.class);
  inputSupplier=new InputSupplier<InputStream>(){
    @Override public InputStream getInput() throws IOException {
      return pluginJarLoc.getInputStream();
    }
  }
;
  Set<ArtifactRange> parents=Sets.newHashSet(new ArtifactRange(myapp2Id.getNamespace(),myapp2Id.getName(),myapp2Id.getVersion(),new ArtifactVersion("String_Node_Str")));
  Set<PluginClass> additionalPlugins=Sets.newHashSet(new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Collections.<String,PluginPropertyField>emptyMap()));
  artifactClient.add(pluginId.getNamespace(),pluginId.getName(),inputSupplier,pluginId.getVersion().getVersion(),parents,additionalPlugins);
  ArtifactSummary myapp1Summary=new ArtifactSummary(myapp1Id.getName(),myapp1Id.getVersion().getVersion());
  ArtifactSummary myapp2Summary=new ArtifactSummary(myapp2Id.getName(),myapp2Id.getVersion().getVersion());
  ArtifactSummary pluginArtifactSummary=new ArtifactSummary(pluginId.getName(),pluginId.getVersion().getVersion());
  Set<ArtifactSummary> artifacts=Sets.newHashSet(artifactClient.list(Id.Namespace.DEFAULT));
  Assert.assertEquals(Sets.newHashSet(myapp1Summary,myapp2Summary,pluginArtifactSummary),artifacts);
  Assert.assertEquals(Sets.newHashSet(myapp1Summary,myapp2Summary),Sets.newHashSet(artifactClient.listVersions(Id.Namespace.DEFAULT,myapp1Id.getName())));
  Assert.assertEquals(Sets.newHashSet(pluginArtifactSummary),Sets.newHashSet(artifactClient.listVersions(Id.Namespace.DEFAULT,pluginId.getName())));
  try {
    artifactClient.listVersions(Id.Namespace.DEFAULT,pluginId.getName(),ArtifactScope.SYSTEM);
    Assert.fail();
  }
 catch (  ArtifactNotFoundException e) {
  }
  Schema myAppConfigSchema=new ReflectionSchemaGenerator(false).generate(MyApp.Conf.class);
  ArtifactClasses myAppClasses=ArtifactClasses.builder().addApp(new ApplicationClass(MyApp.class.getName(),"String_Node_Str",myAppConfigSchema)).build();
  ArtifactInfo myapp1Info=new ArtifactInfo(myapp1Id.getName(),myapp1Id.getVersion().getVersion(),ArtifactScope.USER,myAppClasses,myapp1Properties);
  Assert.assertEquals(myapp1Info,artifactClient.getArtifactInfo(myapp1Id));
  ArtifactInfo myapp2Info=new ArtifactInfo(myapp2Id.getName(),myapp2Id.getVersion().getVersion(),ArtifactScope.USER,myAppClasses,myapp2Properties);
  Assert.assertEquals(myapp2Info,artifactClient.getArtifactInfo(myapp2Id));
  myapp2Properties=ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp2Id,myapp2Properties);
  Assert.assertEquals(myapp2Properties,artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.deleteProperty(myapp2Id,"String_Node_Str");
  Assert.assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.writeProperty(myapp2Id,"String_Node_Str","String_Node_Str");
  Assert.assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.deleteProperties(myapp2Id);
  Assert.assertTrue(artifactClient.getArtifactInfo(myapp2Id).getProperties().isEmpty());
  Map<String,PluginPropertyField> props=ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true));
  ArtifactClasses pluginClasses=ArtifactClasses.builder().addPlugin(new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),"String_Node_Str",props)).addPlugins(additionalPlugins).build();
  ArtifactInfo pluginArtifactInfo=new ArtifactInfo(pluginId.getName(),pluginId.getVersion().getVersion(),ArtifactScope.USER,pluginClasses,ImmutableMap.<String,String>of());
  Assert.assertEquals(pluginArtifactInfo,artifactClient.getArtifactInfo(pluginId));
  Set<ApplicationClassSummary> expectedSummaries=ImmutableSet.of(new ApplicationClassSummary(myapp1Summary,MyApp.class.getName()),new ApplicationClassSummary(myapp2Summary,MyApp.class.getName()));
  Set<ApplicationClassSummary> appClassSummaries=Sets.newHashSet(artifactClient.getApplicationClasses(Id.Namespace.DEFAULT));
  Assert.assertEquals(expectedSummaries,appClassSummaries);
  Set<ApplicationClassInfo> appClassInfos=Sets.newHashSet(artifactClient.getApplicationClasses(Id.Namespace.DEFAULT,MyApp.class.getName()));
  Set<ApplicationClassInfo> expectedInfos=ImmutableSet.of(new ApplicationClassInfo(myapp1Summary,MyApp.class.getName(),myAppConfigSchema),new ApplicationClassInfo(myapp2Summary,MyApp.class.getName(),myAppConfigSchema));
  Assert.assertEquals(expectedInfos,appClassInfos);
  Assert.assertTrue(artifactClient.getPluginTypes(myapp1Id).isEmpty());
  Assert.assertEquals(Lists.newArrayList("String_Node_Str","String_Node_Str"),artifactClient.getPluginTypes(myapp2Id));
  PluginSummary pluginSummary=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),pluginArtifactSummary);
  Assert.assertEquals(Sets.newHashSet(pluginSummary),Sets.newHashSet(artifactClient.getPluginSummaries(myapp2Id,"String_Node_Str")));
  Assert.assertTrue(artifactClient.getPluginSummaries(myapp2Id,"String_Node_Str").isEmpty());
  PluginInfo pluginInfo=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),pluginArtifactSummary,props);
  Assert.assertEquals(Sets.newHashSet(pluginInfo),Sets.newHashSet(artifactClient.getPluginInfo(myapp2Id,"String_Node_Str","String_Node_Str")));
}

Fixed version (ground truth):
@Test public void testArtifacts() throws Exception {
  Id.Artifact myapp1Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Id.Artifact myapp2Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  LocalLocationFactory locationFactory=new LocalLocationFactory(tmpFolder.newFolder());
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.BUNDLE_VERSION,"String_Node_Str");
  final Location appJarLoc=AppJarHelper.createDeploymentJar(locationFactory,MyApp.class,manifest);
  InputSupplier<InputStream> inputSupplier=new InputSupplier<InputStream>(){
    @Override public InputStream getInput() throws IOException {
      return appJarLoc.getInputStream();
    }
  }
;
  artifactClient.add(myapp1Id.getNamespace(),myapp1Id.getName(),inputSupplier,myapp1Id.getVersion().getVersion());
  Map<String,String> myapp1Properties=ImmutableMap.of("String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp1Id,myapp1Properties);
  artifactClient.add(myapp2Id.getNamespace(),myapp2Id.getName(),inputSupplier,null,null);
  Map<String,String> myapp2Properties=ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp2Id,myapp2Properties);
  Id.Artifact pluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
  final Location pluginJarLoc=PluginJarHelper.createPluginJar(locationFactory,manifest,Plugin1.class);
  inputSupplier=new InputSupplier<InputStream>(){
    @Override public InputStream getInput() throws IOException {
      return pluginJarLoc.getInputStream();
    }
  }
;
  Set<ArtifactRange> parents=Sets.newHashSet(new ArtifactRange(myapp2Id.getNamespace(),myapp2Id.getName(),myapp2Id.getVersion(),new ArtifactVersion("String_Node_Str")));
  Set<PluginClass> additionalPlugins=Sets.newHashSet(new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Collections.<String,PluginPropertyField>emptyMap()));
  artifactClient.add(pluginId.getNamespace(),pluginId.getName(),inputSupplier,pluginId.getVersion().getVersion(),parents,additionalPlugins);
  ArtifactSummary myapp1Summary=new ArtifactSummary(myapp1Id.getName(),myapp1Id.getVersion().getVersion());
  ArtifactSummary myapp2Summary=new ArtifactSummary(myapp2Id.getName(),myapp2Id.getVersion().getVersion());
  ArtifactSummary pluginArtifactSummary=new ArtifactSummary(pluginId.getName(),pluginId.getVersion().getVersion());
  Set<ArtifactSummary> artifacts=Sets.newHashSet(artifactClient.list(Id.Namespace.DEFAULT));
  Assert.assertEquals(Sets.newHashSet(myapp1Summary,myapp2Summary,pluginArtifactSummary),artifacts);
  Assert.assertEquals(Sets.newHashSet(myapp1Summary,myapp2Summary),Sets.newHashSet(artifactClient.listVersions(Id.Namespace.DEFAULT,myapp1Id.getName())));
  Assert.assertEquals(Sets.newHashSet(pluginArtifactSummary),Sets.newHashSet(artifactClient.listVersions(Id.Namespace.DEFAULT,pluginId.getName())));
  try {
    artifactClient.listVersions(Id.Namespace.DEFAULT,pluginId.getName(),ArtifactScope.SYSTEM);
    Assert.fail();
  }
 catch (  ArtifactNotFoundException e) {
  }
  Schema myAppConfigSchema=new ReflectionSchemaGenerator(false).generate(MyApp.Conf.class);
  ArtifactClasses myAppClasses=ArtifactClasses.builder().addApp(new ApplicationClass(MyApp.class.getName(),"String_Node_Str",myAppConfigSchema)).build();
  ArtifactInfo myapp1Info=new ArtifactInfo(myapp1Id.getName(),myapp1Id.getVersion().getVersion(),ArtifactScope.USER,myAppClasses,myapp1Properties);
  Assert.assertEquals(myapp1Info,artifactClient.getArtifactInfo(myapp1Id));
  ArtifactInfo myapp2Info=new ArtifactInfo(myapp2Id.getName(),myapp2Id.getVersion().getVersion(),ArtifactScope.USER,myAppClasses,myapp2Properties);
  Assert.assertEquals(myapp2Info,artifactClient.getArtifactInfo(myapp2Id));
  myapp2Properties=ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  artifactClient.writeProperties(myapp2Id,myapp2Properties);
  Assert.assertEquals(myapp2Properties,artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.deleteProperty(myapp2Id,"String_Node_Str");
  Assert.assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.writeProperty(myapp2Id,"String_Node_Str","String_Node_Str");
  Assert.assertEquals(ImmutableMap.of("String_Node_Str","String_Node_Str"),artifactClient.getArtifactInfo(myapp2Id).getProperties());
  artifactClient.deleteProperties(myapp2Id);
  Assert.assertTrue(artifactClient.getArtifactInfo(myapp2Id).getProperties().isEmpty());
  Map<String,PluginPropertyField> props=ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true));
  ArtifactClasses pluginClasses=ArtifactClasses.builder().addPlugin(new PluginClass("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),"String_Node_Str",props)).addPlugins(additionalPlugins).build();
  ArtifactInfo pluginArtifactInfo=new ArtifactInfo(pluginId.getName(),pluginId.getVersion().getVersion(),ArtifactScope.USER,pluginClasses,ImmutableMap.<String,String>of());
  Assert.assertEquals(pluginArtifactInfo,artifactClient.getArtifactInfo(pluginId));
  Set<ApplicationClassSummary> expectedSummaries=ImmutableSet.of(new ApplicationClassSummary(myapp1Summary,MyApp.class.getName()),new ApplicationClassSummary(myapp2Summary,MyApp.class.getName()));
  Set<ApplicationClassSummary> appClassSummaries=Sets.newHashSet(artifactClient.getApplicationClasses(Id.Namespace.DEFAULT));
  Assert.assertEquals(expectedSummaries,appClassSummaries);
  Set<ApplicationClassInfo> appClassInfos=Sets.newHashSet(artifactClient.getApplicationClasses(Id.Namespace.DEFAULT,MyApp.class.getName()));
  Set<ApplicationClassInfo> expectedInfos=ImmutableSet.of(new ApplicationClassInfo(myapp1Summary,MyApp.class.getName(),myAppConfigSchema),new ApplicationClassInfo(myapp2Summary,MyApp.class.getName(),myAppConfigSchema));
  Assert.assertEquals(expectedInfos,appClassInfos);
  Assert.assertTrue(artifactClient.getPluginTypes(myapp1Id).isEmpty());
  Assert.assertEquals(Lists.newArrayList("String_Node_Str","String_Node_Str"),artifactClient.getPluginTypes(myapp2Id));
  PluginSummary pluginSummary=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),pluginArtifactSummary);
  Assert.assertEquals(Sets.newHashSet(pluginSummary),Sets.newHashSet(artifactClient.getPluginSummaries(myapp2Id,"String_Node_Str")));
  Assert.assertTrue(artifactClient.getPluginSummaries(myapp2Id,"String_Node_Str").isEmpty());
  PluginInfo pluginInfo=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),pluginArtifactSummary,props,new HashSet<String>());
  Assert.assertEquals(Sets.newHashSet(pluginInfo),Sets.newHashSet(artifactClient.getPluginInfo(myapp2Id,"String_Node_Str","String_Node_Str")));
}