Program: 34716
Project: 34716
Buggy source:
/** 
 * Tests for validating Application Processor behaviour in the following scenarios: single app with OAS, two apps with OAS, two apps one with OAS and one without, single app without OAS. This tests deploys and undeploys apps to ensure once deployed, nothing is left behind.
 */
@Test public void testApplicationProcessor() throws Exception {
  OpenAPITestUtil.addApplication(server,APP_NAME_1);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_1);
  String app1Doc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  JsonNode openapiNode=OpenAPITestUtil.readYamlTree(app1Doc);
  OpenAPITestUtil.checkServer(openapiNode,"String_Node_Str","String_Node_Str");
  OpenAPITestUtil.checkPaths(openapiNode,16);
  OpenAPITestUtil.addApplication(server,APP_NAME_2);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_2);
  String openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",app1Doc,openapi);
  OpenAPITestUtil.removeApplication(server,APP_NAME_1);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_2);
  String app2Doc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  openapiNode=OpenAPITestUtil.readYamlTree(app2Doc);
  OpenAPITestUtil.checkServer(openapiNode,OpenAPITestUtil.getServerURLs(server,server.getHttpDefaultPort(),server.getHttpDefaultSecurePort(),APP_NAME_2));
  OpenAPITestUtil.checkPaths(openapiNode,1);
  OpenAPITestUtil.removeApplication(server,APP_NAME_2);
  String emptyDoc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  openapiNode=OpenAPITestUtil.readYamlTree(emptyDoc);
  OpenAPITestUtil.checkServer(openapiNode,OpenAPITestUtil.getServerURLs(server,server.getHttpDefaultPort(),server.getHttpDefaultSecurePort()));
  OpenAPITestUtil.checkPaths(openapiNode,0);
  OpenAPITestUtil.addApplication(server,APP_NAME_3);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_3);
  openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",emptyDoc,openapi);
  OpenAPITestUtil.addApplication(server,APP_NAME_1);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_1);
  openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",app1Doc,openapi);
}

Fixed version (ground truth):
/** 
 * Tests for validating Application Processor behaviour in the following scenarios: single app with OAS, two apps with OAS, two apps one with OAS and one without, single app without OAS. This tests deploys and undeploys apps to ensure once deployed, nothing is left behind.
 */
@Test public void testApplicationProcessor() throws Exception {
  OpenAPITestUtil.addApplication(server,APP_NAME_1);
  String app1Doc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  JsonNode openapiNode=OpenAPITestUtil.readYamlTree(app1Doc);
  OpenAPITestUtil.checkServer(openapiNode,"String_Node_Str","String_Node_Str");
  OpenAPITestUtil.checkPaths(openapiNode,16);
  OpenAPITestUtil.setMarkToEndOfAllLogs(server);
  OpenAPITestUtil.addApplication(server,APP_NAME_2,false);
  String openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",app1Doc,openapi);
  OpenAPITestUtil.removeApplication(server,APP_NAME_1);
  OpenAPITestUtil.waitForApplicationProcessorAddedEvent(server,APP_NAME_2);
  String app2Doc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  openapiNode=OpenAPITestUtil.readYamlTree(app2Doc);
  OpenAPITestUtil.checkServer(openapiNode,OpenAPITestUtil.getServerURLs(server,server.getHttpDefaultPort(),server.getHttpDefaultSecurePort(),APP_NAME_2));
  OpenAPITestUtil.checkPaths(openapiNode,1);
  OpenAPITestUtil.setMarkToEndOfAllLogs(server);
  OpenAPITestUtil.removeApplication(server,APP_NAME_2);
  String emptyDoc=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  openapiNode=OpenAPITestUtil.readYamlTree(emptyDoc);
  OpenAPITestUtil.checkServer(openapiNode,OpenAPITestUtil.getServerURLs(server,server.getHttpDefaultPort(),server.getHttpDefaultSecurePort()));
  OpenAPITestUtil.checkPaths(openapiNode,0);
  OpenAPITestUtil.setMarkToEndOfAllLogs(server);
  OpenAPITestUtil.addApplication(server,APP_NAME_3);
  openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",emptyDoc,openapi);
  OpenAPITestUtil.setMarkToEndOfAllLogs(server);
  OpenAPITestUtil.addApplication(server,APP_NAME_1);
  openapi=OpenAPIConnection.openAPIDocsConnection(server,false).download();
  assertEquals("String_Node_Str",app1Doc,openapi);
}