Program: 6223
Project: 6223
Buggy source:
@Test public void testPluginWithEndpoints() throws Exception {
  Id.Artifact wordCount1Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addAppArtifact(wordCount1Id,WordCountApp.class).getStatusLine().getStatusCode());
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,CallablePlugin.class.getPackage().getName());
  Id.Artifact plugins3Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins3Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins3Id,CallablePlugin.class,manifest,plugins3Parents).getStatusLine().getStatusCode());
  Assert.assertEquals("String_Node_Str",GSON.fromJson(callPluginMethod(plugins3Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,200).getResponseBodyAsString(),String.class));
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,CallingPlugin.class.getPackage().getName());
  Id.Artifact plugins4Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins4Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins4Id,CallingPlugin.class,manifest,plugins4Parents).getStatusLine().getStatusCode());
  Assert.assertEquals("String_Node_Str",GSON.fromJson(callPluginMethod(plugins4Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,200).getResponseBodyAsString(),String.class));
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,PluginWithPojo.class.getPackage().getName());
  Id.Artifact plugins5Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins5Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins5Id,PluginWithPojo.class,manifest,plugins5Parents).getStatusLine().getStatusCode());
  List<TestData> data=ImmutableList.of(new TestData(1,10),new TestData(1,20),new TestData(3,15),new TestData(4,5),new TestData(3,15));
  Map<Long,Long> expectedResult=new HashMap<>();
  expectedResult.put(1L,30L);
  expectedResult.put(3L,30L);
  expectedResult.put(4L,5L);
  String response=callPluginMethod(plugins5Id,"String_Node_Str","String_Node_Str","String_Node_Str",GSON.toJson(data),ArtifactScope.USER,200).getResponseBodyAsString();
  Assert.assertEquals(expectedResult,GSON.fromJson(response,new TypeToken<Map<Long,Long>>(){
  }
.getType()));
  callPluginMethod(plugins4Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,404);
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPlugin.class.getPackage().getName());
  Id.Artifact invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPlugin.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPluginMethodParams.class.getPackage().getName());
  invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPluginMethodParams.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPluginMethodParamType.class.getPackage().getName());
  invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPluginMethodParamType.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,PluginEndpointContextTestPlugin.class.getPackage().getName());
  Id.Artifact validPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> validPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(validPluginId,PluginEndpointContextTestPlugin.class,manifest,validPluginParents).getStatusLine().getStatusCode());
}

Fixed version (ground truth):
@Test public void testPluginWithEndpoints() throws Exception {
  Id.Artifact wordCount1Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addAppArtifact(wordCount1Id,WordCountApp.class).getStatusLine().getStatusCode());
  Manifest manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,CallablePlugin.class.getPackage().getName());
  Id.Artifact plugins3Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins3Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins3Id,CallablePlugin.class,manifest,plugins3Parents).getStatusLine().getStatusCode());
  Set<PluginInfo> expectedInfos=Sets.newHashSet(new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",CallablePlugin.class.getName(),new ArtifactSummary("String_Node_Str","String_Node_Str"),ImmutableMap.<String,PluginPropertyField>of(),ImmutableSet.<String>of("String_Node_Str")));
  Assert.assertEquals(expectedInfos,getPluginInfos(wordCount1Id,"String_Node_Str","String_Node_Str"));
  Assert.assertEquals("String_Node_Str",GSON.fromJson(callPluginMethod(plugins3Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,200).getResponseBodyAsString(),String.class));
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,CallingPlugin.class.getPackage().getName());
  Id.Artifact plugins4Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins4Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins4Id,CallingPlugin.class,manifest,plugins4Parents).getStatusLine().getStatusCode());
  Assert.assertEquals("String_Node_Str",GSON.fromJson(callPluginMethod(plugins4Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,200).getResponseBodyAsString(),String.class));
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,PluginWithPojo.class.getPackage().getName());
  Id.Artifact plugins5Id=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> plugins5Parents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(plugins5Id,PluginWithPojo.class,manifest,plugins5Parents).getStatusLine().getStatusCode());
  List<TestData> data=ImmutableList.of(new TestData(1,10),new TestData(1,20),new TestData(3,15),new TestData(4,5),new TestData(3,15));
  Map<Long,Long> expectedResult=new HashMap<>();
  expectedResult.put(1L,30L);
  expectedResult.put(3L,30L);
  expectedResult.put(4L,5L);
  String response=callPluginMethod(plugins5Id,"String_Node_Str","String_Node_Str","String_Node_Str",GSON.toJson(data),ArtifactScope.USER,200).getResponseBodyAsString();
  Assert.assertEquals(expectedResult,GSON.fromJson(response,new TypeToken<Map<Long,Long>>(){
  }
.getType()));
  callPluginMethod(plugins4Id,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ArtifactScope.USER,404);
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPlugin.class.getPackage().getName());
  Id.Artifact invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPlugin.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPluginMethodParams.class.getPackage().getName());
  invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPluginMethodParams.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,InvalidPluginMethodParamType.class.getPackage().getName());
  invalidPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  invalidPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.getCode(),addPluginArtifact(invalidPluginId,InvalidPluginMethodParamType.class,manifest,invalidPluginParents).getStatusLine().getStatusCode());
  manifest=new Manifest();
  manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,PluginEndpointContextTestPlugin.class.getPackage().getName());
  Id.Artifact validPluginId=Id.Artifact.from(Id.Namespace.DEFAULT,"String_Node_Str","String_Node_Str");
  Set<ArtifactRange> validPluginParents=Sets.newHashSet(new ArtifactRange(Id.Namespace.DEFAULT,"String_Node_Str",new ArtifactVersion("String_Node_Str"),new ArtifactVersion("String_Node_Str")));
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(validPluginId,PluginEndpointContextTestPlugin.class,manifest,validPluginParents).getStatusLine().getStatusCode());
}