expectedObjectMetadata.put("targetFuid", tAccount.getFuid());
expectedObjectMetadata.put("targetName", tAccount.getName());
} else if (expectedTarget instanceof InventoryItem) {
InventoryItem tInventoryItem = (InventoryItem) expectedTarget;
Connection tConnection = tInventoryItem.getConnection();
ConnectionProvider tConnectionProvider =
applicationManager.getConnectionProviderFactory()
.connectionProviderFromId(tConnection.getProviderId());
Map<String, Object> expectedInventoryItemMetadata = new HashMap<>();
InventoryService inventoryService = applicationManager.getInventoryService();
expectedObjectMetadata.put("targetExternalId", tInventoryItem.getExternalId());
expectedInventoryItemMetadata.put("targetConnectionId", tConnection.getId());
expectedInventoryItemMetadata.put("targetConnectionAlias", tConnection.getAlias());
expectedInventoryItemMetadata.put("targetConnectionHashtags", tConnection.getHashtags());
expectedInventoryItemMetadata.put("targetConnectionVersion", tConnection.getVersion());
expectedInventoryItemMetadata.put("targetProviderId", tConnectionProvider.getId());
expectedInventoryItemMetadata.put("targetProviderDisplayName", tConnectionProvider.getDisplayName());
expectedInventoryItemMetadata.put("targetProviderType", tConnectionProvider.getType());
if (tInventoryItem.getConnection().getProviderId().equals(ProviderIdConstants.AWS_PROVIDER_ID)) {
Location zone = inventoryService.getLocationByScope(tInventoryItem, LocationScope.ZONE);
Location region = inventoryService.getLocationByScope(tInventoryItem, LocationScope.REGION);
Set<String> iso3166Codes = zone != null ? zone.getIso3166Codes() : null;
String iso3166Code = iso3166Codes != null && iso3166Codes.size() >= 1 ?
iso3166Codes.iterator().next() :
null;
if (tInventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE)) {
expectedObjectMetadata.put("targetIP",
inventoryService.getComputeInstanceIPAddress(tInventoryItem));
expectedObjectMetadata.put("targetOS",
inventoryService.getComputeInstanceOSName(tInventoryItem));
}
if (iso3166Code != null) {
expectedObjectMetadata.put("targetISO3166Code", iso3166Code);
}
if (zone != null) {
expectedObjectMetadata.put("targetZone", zone.getId());
}
if (region != null) {
expectedObjectMetadata.put("targetRegion", region.getId());
}
}
validateEventMetadata(eventMetadata, expectedInventoryItemMetadata, true);
} else if (expectedTarget instanceof Connection) {
Connection tConnection = (Connection) expectedTarget;
ConnectionProvider tConnectionProvider = applicationManager.getConnectionProviderFactory()
.connectionProviderFromId(
tConnection.getProviderId());
expectedObjectMetadata.put("targetProviderId", tConnectionProvider.getId());
expectedObjectMetadata.put("targetProviderDisplayName", tConnectionProvider.getDisplayName());
expectedObjectMetadata.put("targetProviderType", tConnectionProvider.getType());
} else if (expectedTarget instanceof User) {
User tUser = (User) expectedTarget;
expectedObjectMetadata.put("targetFuid", tUser.getFuid());
expectedObjectMetadata.put("targetFullname", tUser.getFullname());