@Test
public void testAppPackage() throws Exception
{

  Assert.assertEquals("com.example", json.getString("appPackageGroupId"));
  Assert.assertEquals("mydtapp", json.getString("appPackageName"));
  Assert.assertEquals("1.0-SNAPSHOT", json.getString("appPackageVersion"));
  Assert.assertEquals(System.getProperty("apex.version", "3.4.0"), json.getString("dtEngineVersion"));
  Assert.assertEquals("lib/*.jar", json.getJSONArray("classPath").getString(0));
  // Test if there are fixed number of applications
  Assert.assertEquals("Number of applications", 2, json.getJSONArray("applications").length());
  JSONArray applications = json.getJSONArray("applications");
  Map<String, JSONObject> apps = new HashMap<>();
  for (int i = 0; i < applications.length(); i++) {
    JSONObject application = applications.getJSONObject(i);
    apps.put(application.getString("name"), application);
  }
  // Retrieve applications found
  JSONObject myFirstApplication = apps.get("MyFirstApplication");
  JSONObject mySecondApplication = apps.get("MySecondApplication");
  // Testing if expected applications are found
  Assert.assertNotNull("MyFirstApplication not found", myFirstApplication);
  Assert.assertNotNull("MySecondApplication not found", mySecondApplication);
  // Tests related to MyFirstApplication start
  Assert.assertEquals("mydtapp-1.0-SNAPSHOT.jar", myFirstApplication.getString("file"));
  String errorStackTrace = myFirstApplication.getString("errorStackTrace");
  Assert.assertEquals("ErrorStackTrace", "null", errorStackTrace);
  JSONObject dag = myFirstApplication.getJSONObject("dag");
  Assert.assertNotNull("MyFirstApplication DAG does not exist", dag);
  Assert.assertEquals("Number of streams", 1, dag.getJSONArray("streams").length());
  Assert.assertEquals("Number of operators", 3, dag.getJSONArray("operators").length());
  JSONArray operatorsJSONArray = dag.getJSONArray("operators");
  Map<String, JSONObject> operatorMap = new HashMap<>();
  for (int i = 0; i < operatorsJSONArray.length(); i++) {
    JSONObject operator = operatorsJSONArray.getJSONObject(i);
    operatorMap.put(operator.getString("name"), operator);
  }
  JSONObject operator = operatorMap.get("rand");
  Assert.assertNotNull("Input Operator not found", operator);
  Assert.assertEquals("Input operator class", "com.example.mydtapp.RandomNumberGenerator", operator.getJSONObject("properties").get("@class"));
  operator = operatorMap.get("stdout");
  Assert.assertNotNull("Output Operator not found", operator);
  Assert.assertEquals("Value for Output Operator's testInput:", "default-value-1", operator.getJSONObject("properties").get("testInput"));
  Assert.assertEquals("Output Operator class", "com.example.mydtapp.StdoutOperator", operator.getJSONObject("properties").get("@class"));
  operator = operatorMap.get("testModule$testModuleOperator");
  Assert.assertNotNull("Test Module Operator not found", operator);
  Assert.assertEquals("Test Module Operator class", "com.example.mydtapp.TestModuleOperator", operator.getJSONObject("properties").get("@class"));
  Assert.assertEquals("Value for Test Module Operator's testInput:", "default-value-1", operator.getJSONObject("properties").get("testInput"));
  // Tests related to MyFirstApplication end
  Assert.assertTrue("app package extraction folder should be retained", new File("target/testapp").exists());
  yap.cleanContent();
  Assert.assertTrue("app package extraction folder should be removed", !new File("target/testapp").exists());
}