Program: 5193
Project: 5193
Buggy source:
@Test public void testOwnerUsingArtifact() throws Exception {
  ArtifactId artifactId=new ArtifactId(NamespaceId.DEFAULT.getNamespace(),"String_Node_Str","String_Node_Str");
  addAppArtifact(artifactId.toId(),WordCountApp.class);
  ApplicationId applicationId=new ApplicationId(NamespaceId.DEFAULT.getNamespace(),"String_Node_Str");
  String ownerPrincipal="String_Node_Str";
  AppRequest<ConfigTestApp.ConfigClass> appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  JsonObject appDetails=getAppDetails(NamespaceId.DEFAULT.getNamespace(),applicationId.getApplication());
  Assert.assertEquals(ownerPrincipal,appDetails.get(Constants.Security.PRINCIPAL).getAsString());
  Assert.assertEquals(ownerPrincipal,getStreamConfig(applicationId.getNamespaceId().stream("String_Node_Str")).getOwnerPrincipal());
  Assert.assertEquals(ownerPrincipal,getDatasetMeta(applicationId.getNamespaceId().dataset("String_Node_Str")).getOwnerPrincipal());
  String bobPrincipal="String_Node_Str";
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,bobPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_BAD_REQUEST,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,bobPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_BAD_REQUEST,deploy(new ApplicationId(applicationId.getNamespace(),applicationId.getApplication(),"String_Node_Str"),appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(new ApplicationId(applicationId.getNamespace(),applicationId.getApplication(),"String_Node_Str"),appRequest).getStatusLine().getStatusCode());
  Assert.assertEquals(200,doDelete(getVersionedAPIPath("String_Node_Str" + applicationId.getApplication(),applicationId.getNamespace())).getStatusLine().getStatusCode());
  Assert.assertEquals(ownerPrincipal,getStreamConfig(applicationId.getNamespaceId().stream("String_Node_Str")).getOwnerPrincipal());
  Assert.assertEquals(ownerPrincipal,getDatasetMeta(applicationId.getNamespaceId().dataset("String_Node_Str")).getOwnerPrincipal());
  deleteNamespace(NamespaceId.DEFAULT.getNamespace());
}

Fixed version (ground truth):
@Test public void testOwnerUsingArtifact() throws Exception {
  ArtifactId artifactId=new ArtifactId(NamespaceId.DEFAULT.getNamespace(),"String_Node_Str","String_Node_Str");
  addAppArtifact(artifactId.toId(),WordCountApp.class);
  ApplicationId applicationId=new ApplicationId(NamespaceId.DEFAULT.getNamespace(),"String_Node_Str");
  String ownerPrincipal="String_Node_Str";
  AppRequest<ConfigTestApp.ConfigClass> appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  JsonObject appDetails=getAppDetails(NamespaceId.DEFAULT.getNamespace(),applicationId.getApplication());
  Assert.assertEquals(ownerPrincipal,appDetails.get(Constants.Security.PRINCIPAL).getAsString());
  Assert.assertEquals(ownerPrincipal,getStreamConfig(applicationId.getNamespaceId().stream("String_Node_Str")).getOwnerPrincipal());
  Assert.assertEquals(ownerPrincipal,getDatasetMeta(applicationId.getNamespaceId().dataset("String_Node_Str")).getOwnerPrincipal());
  String bobPrincipal="String_Node_Str";
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,bobPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_FORBIDDEN,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,bobPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_FORBIDDEN,deploy(new ApplicationId(applicationId.getNamespace(),applicationId.getApplication(),"String_Node_Str"),appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(applicationId,appRequest).getStatusLine().getStatusCode());
  appRequest=new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(),artifactId.getVersion()),null,ownerPrincipal);
  Assert.assertEquals(HttpResponseCodes.SC_OK,deploy(new ApplicationId(applicationId.getNamespace(),applicationId.getApplication(),"String_Node_Str"),appRequest).getStatusLine().getStatusCode());
  Assert.assertEquals(200,doDelete(getVersionedAPIPath("String_Node_Str" + applicationId.getApplication(),applicationId.getNamespace())).getStatusLine().getStatusCode());
  Assert.assertEquals(ownerPrincipal,getStreamConfig(applicationId.getNamespaceId().stream("String_Node_Str")).getOwnerPrincipal());
  Assert.assertEquals(ownerPrincipal,getDatasetMeta(applicationId.getNamespaceId().dataset("String_Node_Str")).getOwnerPrincipal());
  deleteNamespace(NamespaceId.DEFAULT.getNamespace());
}