@Test
public void testReportArchiveUsage() {

    ServiceResource serviceResource = new ServiceResource();
    serviceResource.setId("service1");
    serviceResource.setName("service name 1");
    serviceResource.setDependency(new CSARDependency("org.alien4cloud.archives:my-archive", "1.0.0-SNAPSHOT"));
    alienDao.save(serviceResource);
    ArchiveUsageRequestEvent archiveUsageRequestEvent = new ArchiveUsageRequestEvent(this, "org.alien4cloud.archives:my-archive", "1.0.0-SNAPSHOT");
    serviceResourceService.reportArchiveUsage(archiveUsageRequestEvent);
    Assert.assertEquals(1, archiveUsageRequestEvent.getUsages().size());
    Assert.assertEquals("service1", archiveUsageRequestEvent.getUsages().get(0).getResourceId());
    Assert.assertEquals("serviceresource", archiveUsageRequestEvent.getUsages().get(0).getResourceType());
    Assert.assertEquals("service name 1", archiveUsageRequestEvent.getUsages().get(0).getResourceName());
    archiveUsageRequestEvent = new ArchiveUsageRequestEvent(this, "org.alien4cloud.archives:other-archive", "1.0.0-SNAPSHOT");
    serviceResourceService.reportArchiveUsage(archiveUsageRequestEvent);
    Assert.assertEquals(0, archiveUsageRequestEvent.getUsages().size());
    archiveUsageRequestEvent = new ArchiveUsageRequestEvent(this, "org.alien4cloud.archives:my-archive", "1.0.1-SNAPSHOT");
    serviceResourceService.reportArchiveUsage(archiveUsageRequestEvent);
    Assert.assertEquals(0, archiveUsageRequestEvent.getUsages().size());
}