ResourceTagMaintainer extends ControllerMaintainer { @Override public boolean maintain() { controller().zoneRegistry().zones() .ofCloud(CloudName.from("aws")) .reachable() .zones().forEach(zone -> { Map<HostName, ApplicationId> applicationOfHosts = getTenantOfParentHosts(zone.getId()); int taggedResources = resourceTagger.tagResources(zone, applicationOfHosts); if (taggedResources > 0) log.log(Level.INFO, "Tagged " + taggedResources + " resources in " + zone.getId()); }); return true; } ResourceTagMaintainer(Controller controller, Duration interval, ResourceTagger resourceTagger); @Override boolean maintain();  }
@Test public void maintain() { setUpZones(); MockResourceTagger mockResourceTagger = new MockResourceTagger(); ResourceTagMaintainer resourceTagMaintainer = new ResourceTagMaintainer(tester.controller(), Duration.ofMinutes(5), mockResourceTagger); resourceTagMaintainer.maintain(); assertEquals(2, mockResourceTagger.getValues().size()); Map<HostName, ApplicationId> applicationForHost = mockResourceTagger.getValues().get(ZoneId.from("prod.region-2")); assertEquals(ApplicationId.from("tenant1", "app1", "default"), applicationForHost.get(HostName.from("parentHostA"))); assertEquals(ApplicationId.from("tenant2", "app2", "default"), applicationForHost.get(HostName.from("parentHostB"))); }