CloudTrailEventSupport { public static List<String> getInstanceIds(final CloudTrailEvent event) { final CloudTrailEventData eventData = getEventData(event); final String responseElements = eventData.getResponseElements(); if (isNullOrEmpty(responseElements)) { return newArrayList(); } return read(responseElements, INSTANCE_ID_JSON_PATH); }  static List<String> getInstanceIds(final CloudTrailEvent event); static String getEventId(final CloudTrailEvent event); static String getAccountId(final CloudTrailEvent event); static List<String> read(final String responseElements, final String pattern,
                                    final boolean emptyListOnNullOrEmptyResponse); static List<String> read(final String responseElements, final String pattern); static List<String> read(final CloudTrailEvent cloudTrailEvent, final String pattern,
                                    final boolean emptyListOnNullOrEmptyResponse); static List<String> getInstanceLaunchTime(CloudTrailEvent cloudTrailEvent); static Region getRegion(final CloudTrailEvent cloudTrailEvent); static String getRegionAsString(final CloudTrailEvent event); static ViolationBuilder violationFor(final CloudTrailEvent cloudTrailEvent); static String getUsernameAsString(final CloudTrailEvent cloudTrailEvent); static List<String> getInstances(final CloudTrailEvent event); static DateTime getRunInstanceTime(final String instance); static DateTime getEventTime(CloudTrailEvent event); static List<String> readSecurityGroupIds(final CloudTrailEvent cloudTrailEvent); static final String INSTANCE_ID_JSON_PATH; static final String INSTANCE_JSON_PATH; static final String RUN_INSTANCE_DATE_JSON_PATH; static final String SECURITY_GROUP_IDS_JSON_PATH; static final String INSTANCES_SECURITY_GROUP_IDS_JSON_PATH; static final String INSTANCE_LAUNCH_TIME; }
@Test public void getInstanceIdsTest() { final List<String> instanceIds = getInstanceIds(createCloudTrailEvent("/responseElements.json")); assertThat(instanceIds).isNotEmpty(); }
@Test(expected = NullPointerException.class) public void getInstanceIdsNullEvent() { final List<String> instanceIds = getInstanceIds(null); assertThat(instanceIds).isNotEmpty(); }
@Test(expected = NullPointerException.class) public void getInstanceIdsNullEventData() { final List<String> instanceIds = getInstanceIds(new CloudTrailEvent(null, null)); assertThat(instanceIds).isNotEmpty(); }
@Test public void testNullResponseElementsAmis() { final List<String> instanceIds = getInstanceIds(createCloudTrailEvent("/empty-responseElements.json")); assertThat(instanceIds).isEmpty(); }