### Question:
Ec2SecurityGroupService implements SecurityGroupService { @Override public ImmutableSet<SecurityGroupPermission> getPermissions(String groupName, String dataCenter) { Optional<SecurityGroup> securityGroup = getSecurityGroup(groupName, dataCenter); if (securityGroup.isPresent()) { return fromIpPermissions(securityGroup.get().getIpPermissions()); } return ImmutableSet.of(); } @Inject  Ec2SecurityGroupService(Provider<AmazonEC2> amazonEC2Provider,
      @Named(SecurityGroupModule.SECURITY_GROUP_DATACENTERS_PROPERTY) Map<String, Region> regions); @Override boolean exists(String groupName, String dataCenter); @Override void create(String groupName, String dataCenter); @Override ImmutableSet<SecurityGroupPermission> getPermissions(String groupName, String dataCenter); @Override void authorizeIngressRules(String groupName, String dataCenter, SecurityGroupPermission permission); @Override void revokeIngressRules(String groupName, String dataCenter, SecurityGroupPermission permission);  }### Answer:
@Test public void getPermissions_groupDoesNotExist() { amazonEc2.setRegion(region); expect(amazonEc2.describeSecurityGroups()) .andReturn(new DescribeSecurityGroupsResult() .withSecurityGroups(ImmutableList.<SecurityGroup>of())); replayAll(); assertEquals(ImmutableSet.of(), service().getPermissions("securityGroupName", "dc1")); }
@Test public void getPermissions_noneExisting() { securityGroupStartingRules(); replayAll(); assertEquals(ImmutableSet.of(), service().getPermissions("securityGroupName", "dc1")); }
@Test public void getPermissions() { securityGroupStartingRules(ipPermission(8888, "111.0.0.0/8"), ipPermission(7000, "222.0.0.0/8")); replayAll(); assertEquals(ImmutableSet.of(groupPermission(8888, "111.0.0.0/8"), groupPermission(7000, "222.0.0.0/8")), service().getPermissions("securityGroupName", "dc1")); }