public class FindSecurityGroupOrCreateTest {
@Test
public void testLoad() throws UnknownHostException {
final CloudStackClient client = createMock(CloudStackClient.class);
SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
ZoneClient zoneClient = createMock(ZoneClient.class);
AsyncJobClient jobClient = createMock(AsyncJobClient.class);
SecurityGroup group = createMock(SecurityGroup.class);
Zone zone = createMock(Zone.class);
expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
expect(group.getId()).andReturn("sec-1234").anyTimes();
expect(zone.isSecurityGroupsEnabled()).andReturn(true);
expect(client.getSecurityGroupClient()).andReturn(secClient)
.anyTimes();
expect(client.getZoneClient()).andReturn(zoneClient);
expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();
expect(zoneClient.getZone("zone-1")).andReturn(zone);
expect(secClient.getSecurityGroupByName("group-1")).andReturn(null);
expect(secClient.createSecurityGroup("group-1")).andReturn(group);
expect(secClient.authorizeIngressPortsToCIDRs("sec-1234",
"TCP",
22,
22,
ImmutableSet.of("0.0.0.0/0"))).andReturn("job-1234");