### Question:
AwsEC2Platform extends Platform implements SshBasedExperiment<AwsEC2Container> { String lookupChaosSecurityGroup (String vpcId) { log.debug("Looking up Security Group to use for experiments for VPC {}", v("VPC", vpcId)); return amazonEC2.describeSecurityGroups(new DescribeSecurityGroupsRequest().withFilters(new Filter("vpc-id").withValues(vpcId))) .getSecurityGroups() .stream() .filter(securityGroup -> securityGroup.getVpcId().equals(vpcId)) .filter(securityGroup -> securityGroup.getGroupName().equals(EC2_DEFAULT_CHAOS_SECURITY_GROUP_NAME + "-" + vpcId)) .map(SecurityGroup::getGroupId) .findFirst() .orElseGet(() -> createChaosSecurityGroup(vpcId)); } @Autowired  AwsEC2Platform(AmazonEC2 amazonEC2, ContainerManager containerManager, AwsEC2SelfAwareness awsEC2SelfAwareness); private  AwsEC2Platform(); void setFilter(@NotNull Map<String, List<String>> filter); void setGroupingTags(List<String> groupingTags); void setSSHPrivateKeys(@NotNull Map<String, String> sshPrivateKeys); Map<String, String> getImageIdToUsernameMap(); void setImageIdToUsernameMap(Map<String, String> imageIdToUsernameMap); @Override ApiStatus getApiStatus(); @JsonIgnore Collection<SubnetUtils.SubnetInfo> getRoutableCidrBlocks(); void setRoutableCidrBlocks(Collection<String> routableCidrBlocks); boolean isAddressRoutable(String privateIPAddress); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateRoster(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String instanceId); void stopInstance(String... instanceIds); void terminateInstance(String... instanceIds); void startInstance(String... instanceIds); void restartInstance(String... instanceIds); void setSecurityGroupIds(String networkInterfaceId, Collection<String> securityGroupIds); String getChaosSecurityGroupForInstance(String instanceId); boolean isContainerTerminated(String instanceId); boolean isAutoscalingGroupAtDesiredInstances(String autoScalingGroupName); boolean hasKey(String keyName); @Override void recycleContainer(AwsEC2Container container); void triggerAutoscalingUnhealthy(String instanceId); @Override String getEndpoint(AwsEC2Container container); @Override SSHCredentials getSshCredentials(AwsEC2Container container); boolean isStarted(AwsEC2Container awsEC2Container); Map<String, Set<String>> getNetworkInterfaceToSecurityGroupsMap(String instanceId); boolean verifySecurityGroupIdsOfNetworkInterfaceMap(String instanceId, Map<String, Set<String>> originalSecurityGroups);  }### Answer:
@Test public void lookupChaosSecurityGroup () { String vpcId = randomUUID().toString(); String groupId = randomUUID().toString(); ArgumentCaptor<DescribeSecurityGroupsRequest> captor = ArgumentCaptor.forClass(DescribeSecurityGroupsRequest.class); doReturn(groupId).when(awsEC2Platform).createChaosSecurityGroup(vpcId); doReturn(new DescribeSecurityGroupsResult()).when(amazonEC2).describeSecurityGroups(captor.capture()); assertEquals(groupId, awsEC2Platform.lookupChaosSecurityGroup(vpcId)); verify(awsEC2Platform, times(1)).createChaosSecurityGroup(vpcId); assertThat(captor.getValue().getFilters(), IsIterableContainingInAnyOrder.containsInAnyOrder(new Filter("vpc-id").withValues(vpcId))); }