}
@Test
public void testCreateSecurityGroupWithExistingSecurityGroup() throws Exception {
DelegateExecution execution = mock(DelegateExecution.class);
Pool pool = mock(Pool.class);
when(pool.getProvider()).thenReturn(provider);
when(execution.getVariable(CoreProcessVariables.POOL)).thenReturn(pool);
when(execution.getProcessBusinessKey()).thenReturn(BUSINESS_KEY);
// create the SecurityGroup with an extra Network Rule, then call the activity
when(pool.getNetwork()).thenReturn(network.toBuilder().addRules(
Rule.builder().anySource().tcp().port(80).createRule()).createNetwork());
activity.execute(execution);
// call the process again with the old network rules and check the rules
when(pool.getNetwork()).thenReturn(network);
activity.execute(execution);
assertSecurityGroupExistsWithRules(SecurityGroups.getByName(context.getApi(),
SECURITY_GROUP_NAME), ingressRules);