コード例 #1
0
ファイル: AppFabricTestBase.java プロジェクト: domarps/cdap
 protected HttpResponse programStatus(Id.Program program) throws Exception {
   String path =
       String.format(
           "apps/%s/%s/%s/status",
           program.getApplicationId(), program.getType().getCategoryName(), program.getId());
   return doGet(getVersionedAPIPath(path, program.getNamespaceId()));
 }
コード例 #2
0
ファイル: UsageDatasetTest.java プロジェクト: ngopina/cdap
  @Test
  public void testProgramDatasetMapping() throws Exception {
    UsageDataset usageDataset = getUsageDataset("testProgramDatasetMapping");

    // Add mappings
    usageDataset.register(flow11, datasetInstance1);
    usageDataset.register(flow11, datasetInstance3);
    usageDataset.register(flow12, datasetInstance2);
    usageDataset.register(service11, datasetInstance1);

    usageDataset.register(flow21, datasetInstance2);
    usageDataset.register(service21, datasetInstance1);

    // Verify program mappings
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance3), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service11));

    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow21));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service21));

    // Verify app mappings
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2, datasetInstance3),
        usageDataset.getDatasets(flow11.getApplication()));
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2),
        usageDataset.getDatasets(flow21.getApplication()));

    // Verify dataset mappings
    Assert.assertEquals(
        ImmutableSet.of(flow11, service11, service21), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(
        ImmutableSet.of(flow12, flow21), usageDataset.getPrograms(datasetInstance2));
    Assert.assertEquals(ImmutableSet.of(flow11), usageDataset.getPrograms(datasetInstance3));

    // --------- Delete app1 -----------
    usageDataset.unregister(flow11.getApplication());

    // There should be no mappings for programs of app1 now
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(service11));

    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow21));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service21));

    // Verify app mappings
    Assert.assertEquals(
        ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11.getApplication()));
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2),
        usageDataset.getDatasets(flow21.getApplication()));

    // Verify dataset mappings
    Assert.assertEquals(ImmutableSet.of(service21), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(flow21), usageDataset.getPrograms(datasetInstance2));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance3));
  }
コード例 #3
0
ファイル: AppFabricTestBase.java プロジェクト: domarps/cdap
 /**
  * Tries to start the given program with the given runtime arguments and expect the call completed
  * with the status.
  */
 protected void startProgram(Id.Program program, Map<String, String> args, int expectedStatusCode)
     throws Exception {
   String path =
       String.format(
           "apps/%s/%s/%s/start",
           program.getApplicationId(), program.getType().getCategoryName(), program.getId());
   HttpResponse response =
       doPost(getVersionedAPIPath(path, program.getNamespaceId()), GSON.toJson(args));
   Assert.assertEquals(expectedStatusCode, response.getStatusLine().getStatusCode());
 }
コード例 #4
0
ファイル: AppFabricTestBase.java プロジェクト: domarps/cdap
 protected List<RunRecord> getProgramRuns(Id.Program program, String status) throws Exception {
   String path =
       String.format(
           "apps/%s/%s/%s/runs?status=%s",
           program.getApplicationId(),
           program.getType().getCategoryName(),
           program.getId(),
           status);
   HttpResponse response = doGet(getVersionedAPIPath(path, program.getNamespaceId()));
   Assert.assertEquals(200, response.getStatusLine().getStatusCode());
   String json = EntityUtils.toString(response.getEntity());
   return GSON.fromJson(json, LIST_RUNRECORD_TYPE);
 }
コード例 #5
0
ファイル: LogHandler.java プロジェクト: ngopina/cdap
 @GET
 @Path(
     "/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs/prev")
 public void runIdPrev(
     HttpRequest request,
     HttpResponder responder,
     @PathParam("namespace-id") String namespaceId,
     @PathParam("app-id") String appId,
     @PathParam("program-type") String programType,
     @PathParam("program-id") String programId,
     @PathParam("run-id") String runId,
     @QueryParam("max") @DefaultValue("50") int maxEvents,
     @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr,
     @QueryParam("escape") @DefaultValue("true") boolean escape,
     @QueryParam("filter") @DefaultValue("") String filterStr,
     @QueryParam("adapterid") String adapterId) {
   LoggingContext loggingContext =
       LoggingContextHelper.getLoggingContextWithRunId(
           namespaceId,
           appId,
           programId,
           ProgramType.valueOfCategoryName(programType),
           runId,
           adapterId);
   RunRecord runRecord =
       programStore.getRun(
           Id.Program.from(
               namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId),
           runId);
   doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord);
 }
コード例 #6
0
ファイル: AppFabricTestBase.java プロジェクト: domarps/cdap
 protected void stopProgram(Id.Program program, int expectedStatusCode, String runId)
     throws Exception {
   String path;
   if (runId == null) {
     path =
         String.format(
             "apps/%s/%s/%s/stop",
             program.getApplicationId(), program.getType().getCategoryName(), program.getId());
   } else {
     path =
         String.format(
             "apps/%s/%s/%s/runs/%s/stop",
             program.getApplicationId(),
             program.getType().getCategoryName(),
             program.getId(),
             runId);
   }
   HttpResponse response = doPost(getVersionedAPIPath(path, program.getNamespaceId()));
   Assert.assertEquals(expectedStatusCode, response.getStatusLine().getStatusCode());
 }
コード例 #7
0
ファイル: LogHandler.java プロジェクト: ngopina/cdap
 @GET
 @Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs")
 public void getRunIdLogs(
     HttpRequest request,
     HttpResponder responder,
     @PathParam("namespace-id") String namespaceId,
     @PathParam("app-id") String appId,
     @PathParam("program-type") String programType,
     @PathParam("program-id") String programId,
     @PathParam("run-id") String runId,
     @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam,
     @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam,
     @QueryParam("escape") @DefaultValue("true") boolean escape,
     @QueryParam("filter") @DefaultValue("") String filterStr,
     @QueryParam("adapterid") String adapterId) {
   LoggingContext loggingContext =
       LoggingContextHelper.getLoggingContextWithRunId(
           namespaceId,
           appId,
           programId,
           ProgramType.valueOfCategoryName(programType),
           runId,
           adapterId);
   RunRecord runRecord =
       programStore.getRun(
           Id.Program.from(
               namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId),
           runId);
   doGetLogs(
       responder,
       loggingContext,
       fromTimeSecsParam,
       toTimeSecsParam,
       escape,
       filterStr,
       runRecord);
 }
コード例 #8
0
ファイル: UsageDatasetTest.java プロジェクト: ngopina/cdap
public class UsageDatasetTest {
  @ClassRule
  public static DatasetFrameworkTestUtil dsFrameworkUtil = new DatasetFrameworkTestUtil();

  private final Id.Program flow11 = Id.Program.from("ns1", "app1", ProgramType.FLOW, "flow11");
  private final Id.Program flow12 = Id.Program.from("ns1", "app1", ProgramType.FLOW, "flow12");
  private final Id.Program service11 =
      Id.Program.from("ns1", "app1", ProgramType.SERVICE, "service11");

  private final Id.Program flow21 = Id.Program.from("ns1", "app2", ProgramType.FLOW, "flow21");
  private final Id.Program flow22 = Id.Program.from("ns1", "app2", ProgramType.FLOW, "flow22");
  private final Id.Program service21 =
      Id.Program.from("ns1", "app2", ProgramType.SERVICE, "service21");

  private final Id.DatasetInstance datasetInstance1 = Id.DatasetInstance.from("ns1", "ds1");
  private final Id.DatasetInstance datasetInstance2 = Id.DatasetInstance.from("ns1", "ds2");
  private final Id.DatasetInstance datasetInstance3 = Id.DatasetInstance.from("ns1", "ds3");

  private final Id.Stream stream1 = Id.Stream.from("ns1", "s1");
  private final Id.Stream stream2 = Id.Stream.from("ns2", "s1");

  private final Id.Adapter adapter1 = Id.Adapter.from("ns1", "adapter1");
  private final Id.Adapter adapter2 = Id.Adapter.from("ns2", "adapter1");

  @Test
  public void testOneMapping() throws Exception {
    UsageDataset usageDataset = getUsageDataset("testOneMapping");

    // Add mapping
    usageDataset.register(flow11, datasetInstance1);

    // Verify mapping
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(flow11));
  }

  @Test
  public void testProgramDatasetMapping() throws Exception {
    UsageDataset usageDataset = getUsageDataset("testProgramDatasetMapping");

    // Add mappings
    usageDataset.register(flow11, datasetInstance1);
    usageDataset.register(flow11, datasetInstance3);
    usageDataset.register(flow12, datasetInstance2);
    usageDataset.register(service11, datasetInstance1);

    usageDataset.register(flow21, datasetInstance2);
    usageDataset.register(service21, datasetInstance1);

    // Verify program mappings
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance3), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service11));

    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow21));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service21));

    // Verify app mappings
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2, datasetInstance3),
        usageDataset.getDatasets(flow11.getApplication()));
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2),
        usageDataset.getDatasets(flow21.getApplication()));

    // Verify dataset mappings
    Assert.assertEquals(
        ImmutableSet.of(flow11, service11, service21), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(
        ImmutableSet.of(flow12, flow21), usageDataset.getPrograms(datasetInstance2));
    Assert.assertEquals(ImmutableSet.of(flow11), usageDataset.getPrograms(datasetInstance3));

    // --------- Delete app1 -----------
    usageDataset.unregister(flow11.getApplication());

    // There should be no mappings for programs of app1 now
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(service11));

    Assert.assertEquals(ImmutableSet.of(datasetInstance2), usageDataset.getDatasets(flow21));
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(service21));

    // Verify app mappings
    Assert.assertEquals(
        ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11.getApplication()));
    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2),
        usageDataset.getDatasets(flow21.getApplication()));

    // Verify dataset mappings
    Assert.assertEquals(ImmutableSet.of(service21), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(flow21), usageDataset.getPrograms(datasetInstance2));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance3));
  }

  @Test
  public void testAllMappings() throws Exception {
    UsageDataset usageDataset = getUsageDataset("testAllMappings");

    // Add mappings
    usageDataset.register(flow11, datasetInstance1);
    usageDataset.register(service21, datasetInstance3);

    usageDataset.register(adapter1, datasetInstance1);
    usageDataset.register(adapter1, datasetInstance2);

    usageDataset.register(flow12, stream1);
    usageDataset.register(adapter2, stream2);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.of(stream1), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.of(flow11), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(adapter1), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(flow12), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete app1 -----------
    usageDataset.unregister(flow11.getApplication());

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(adapter1), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete adapter1 -----------
    usageDataset.unregister(adapter1);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete adapter2 -----------
    usageDataset.unregister(adapter2);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(stream2));

    // --------- Delete app2 -----------
    usageDataset.unregister(flow21.getApplication());
    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(stream2));
  }

  private static UsageDataset getUsageDataset(String instanceId) throws Exception {
    Id.DatasetInstance id =
        Id.DatasetInstance.from(DatasetFrameworkTestUtil.NAMESPACE_ID, instanceId);
    return UsageDatasets.get(dsFrameworkUtil.getFramework(), id);
  }
}
コード例 #9
0
ファイル: UsageDatasetTest.java プロジェクト: ngopina/cdap
  @Test
  public void testAllMappings() throws Exception {
    UsageDataset usageDataset = getUsageDataset("testAllMappings");

    // Add mappings
    usageDataset.register(flow11, datasetInstance1);
    usageDataset.register(service21, datasetInstance3);

    usageDataset.register(adapter1, datasetInstance1);
    usageDataset.register(adapter1, datasetInstance2);

    usageDataset.register(flow12, stream1);
    usageDataset.register(adapter2, stream2);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.of(datasetInstance1), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.of(stream1), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.of(flow11), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(adapter1), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(flow12), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete app1 -----------
    usageDataset.unregister(flow11.getApplication());

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(
        ImmutableSet.of(datasetInstance1, datasetInstance2), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.of(adapter1), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete adapter1 -----------
    usageDataset.unregister(adapter1);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.of(stream2), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.of(adapter2), usageDataset.getAdapters(stream2));

    // --------- Delete adapter2 -----------
    usageDataset.unregister(adapter2);

    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.of(datasetInstance3), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(stream2));

    // --------- Delete app2 -----------
    usageDataset.unregister(flow21.getApplication());
    // Verify app/adapter mappings
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow11));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(flow12));
    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(service21));

    Assert.assertEquals(ImmutableSet.<Id.DatasetInstance>of(), usageDataset.getDatasets(adapter1));

    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow12));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(flow22));
    Assert.assertEquals(ImmutableSet.<Id.Stream>of(), usageDataset.getStreams(adapter2));

    // Verify dataset/stream mappings
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(datasetInstance1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream1));
    Assert.assertEquals(ImmutableSet.<Id.Program>of(), usageDataset.getPrograms(stream2));
    Assert.assertEquals(ImmutableSet.<Id.Adapter>of(), usageDataset.getAdapters(stream2));
  }