private void checkEvents(String msg, Artifact artifact, boolean failed) {
    List<RepositoryEvent> events = listener.getEvents();
    assertEquals(msg, 2, events.size());
    RepositoryEvent event = events.get(0);
    assertEquals(msg, EventType.ARTIFACT_INSTALLING, event.getType());
    assertEquals(msg, artifact, event.getArtifact());
    assertNull(msg, event.getException());

    event = events.get(1);
    assertEquals(msg, EventType.ARTIFACT_INSTALLED, event.getType());
    assertEquals(msg, artifact, event.getArtifact());
    if (failed) {
      assertNotNull(msg + " > expected exception", event.getException());
    } else {
      assertNull(msg + " > " + event.getException(), event.getException());
    }
  }
  private void checkEvents(String msg, Metadata metadata, boolean failed) {
    List<RepositoryEvent> events = listener.getEvents();
    assertEquals(msg, 2, events.size());
    RepositoryEvent event = events.get(0);
    assertEquals(msg, EventType.METADATA_INSTALLING, event.getType());
    assertEquals(msg, metadata, event.getMetadata());
    assertNull(msg, event.getException());

    event = events.get(1);
    assertEquals(msg, EventType.METADATA_INSTALLED, event.getType());
    assertEquals(msg, metadata, event.getMetadata());
    if (failed) {
      assertNotNull(msg, event.getException());
    } else {
      assertNull(msg, event.getException());
    }
  }