String group = "group";
String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
// create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
KeyPair keyPair = createMock(KeyPair.class);
// setup expectations
expect(options.getLoginPrivateKey()).andReturn(null);
expect(options.getRunScript()).andReturn(Statements.exec("echo hello"));
expect(options.getPublicKey()).andReturn(null).times(2);
expect(options.getKeyPair()).andReturn(systemGeneratedKeyPairName);
expect(strategy.credentialsMap.containsKey(new RegionAndName(region, systemGeneratedKeyPairName)))
.andReturn(true);
// replay mocks
replay(options);