@Test public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() { AWSEC2Api client = createMock(AWSEC2Api.class); AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class); expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce(); expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( new IllegalStateException()); expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of()); expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( new IllegalStateException()); expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of(pair)); replay(client); replay(keyApi); ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client); assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint); verify(client); verify(keyApi); }
@Inject public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) { this.ec2Api = ec2Api; }
ImportOrReturnExistingKeypair implements Function<RegionNameAndPublicKeyMaterial, KeyPair> { @Inject public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) { this.ec2Api = ec2Api; } }
ImportOrReturnExistingKeypair implements Function<RegionNameAndPublicKeyMaterial, KeyPair> { @Inject public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) { this.ec2Api = ec2Api; } @Inject  ImportOrReturnExistingKeypair(AWSEC2Api ec2Api); }
ImportOrReturnExistingKeypair implements Function<RegionNameAndPublicKeyMaterial, KeyPair> { @Inject public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) { this.ec2Api = ec2Api; } @Inject  ImportOrReturnExistingKeypair(AWSEC2Api ec2Api); @Override KeyPair apply(RegionNameAndPublicKeyMaterial from); KeyPair addFingerprintToKeyPair(String publicKeyMaterial, KeyPair keyPair); }
ImportOrReturnExistingKeypair implements Function<RegionNameAndPublicKeyMaterial, KeyPair> { @Inject public ImportOrReturnExistingKeypair(AWSEC2Api ec2Api) { this.ec2Api = ec2Api; } @Inject  ImportOrReturnExistingKeypair(AWSEC2Api ec2Api); @Override KeyPair apply(RegionNameAndPublicKeyMaterial from); KeyPair addFingerprintToKeyPair(String publicKeyMaterial, KeyPair keyPair);  }