Source:
<code>public void testDkim() throws Exception { String testDomain = "android-integ-test-dkim-" + new Date().getTime() + ".com"; try { email.verifyDomainIdentity(new VerifyDomainIdentityRequest().withDomain(testDomain)); Thread.sleep(20 * 1000); GetIdentityDkimAttributesResult result = email .getIdentityDkimAttributes(new GetIdentityDkimAttributesRequest() .withIdentities(testDomain)); assertTrue(result.getDkimAttributes().size() == 1); IdentityDkimAttributes attributes = result.getDkimAttributes().get(testDomain); assertFalse(attributes.getDkimEnabled()); assertTrue(attributes.getDkimVerificationStatus().equals("NotStarted")); assertTrue(attributes.getDkimTokens().size() == 0); VerifyDomainDkimResult dkim = email.verifyDomainDkim(new VerifyDomainDkimRequest() .withDomain(testDomain)); Thread.sleep(20 * 1000); result = email.getIdentityDkimAttributes(new GetIdentityDkimAttributesRequest() .withIdentities(testDomain)); assertTrue(result.getDkimAttributes().size() == 1); attributes = result.getDkimAttributes().get(testDomain); assertTrue(attributes.getDkimEnabled()); assertTrue(attributes.getDkimVerificationStatus().equals("Pending")); assertTrue(attributes.getDkimTokens().size() == dkim.getDkimTokens().size()); List verifyDomainResultTokens = dkim.getDkimTokens(); for (String token : attributes.getDkimTokens()) { <START> assertTrue(verifyDomainResultTokens.contains(token)); <END> } try { SetIdentityDkimEnabledResult setIdentityDkimEnabledResult = email.setIdentityDkimEnabled(new SetIdentityDkimEnabledRequest() .withIdentity(testDomain)); assertNotNull(setIdentityDkimEnabledResult); } catch (AmazonServiceException exception) { fail("Exception encountered during enable"); } } finally { email.deleteIdentity(new DeleteIdentityRequest().withIdentity(testDomain)); Thread.sleep(20 * 1000); } }</code><technical_language>This is more succinct. Minor suggestion: assertTrue(dkim.getDkimTokens().containsAll(attributes.getDkimTokens()))</technical_language>

Target:
public void testDkim() throws Exception { String testDomain = "android-integ-test-dkim-" + new Date().getTime() + ".com"; try { email.verifyDomainIdentity(new VerifyDomainIdentityRequest().withDomain(testDomain)); Thread.sleep(20 * 1000); GetIdentityDkimAttributesResult result = email .getIdentityDkimAttributes(new GetIdentityDkimAttributesRequest() .withIdentities(testDomain)); assertTrue(result.getDkimAttributes().size() == 1); IdentityDkimAttributes attributes = result.getDkimAttributes().get(testDomain); assertFalse(attributes.getDkimEnabled()); assertTrue(attributes.getDkimVerificationStatus().equals("NotStarted")); assertTrue(attributes.getDkimTokens().size() == 0); VerifyDomainDkimResult dkim = email.verifyDomainDkim(new VerifyDomainDkimRequest() .withDomain(testDomain)); Thread.sleep(20 * 1000); result = email.getIdentityDkimAttributes(new GetIdentityDkimAttributesRequest() .withIdentities(testDomain)); assertTrue(result.getDkimAttributes().size() == 1); attributes = result.getDkimAttributes().get(testDomain); assertTrue(attributes.getDkimEnabled()); assertTrue(attributes.getDkimVerificationStatus().equals("Pending")); assertTrue(attributes.getDkimTokens().size() == dkim.getDkimTokens().size()); List verifyDomainResultTokens = dkim.getDkimTokens(); List attributeTokens = attributes.getDkimTokens(); assertTrue(verifyDomainResultTokens.containsAll(attributeTokens)); try { SetIdentityDkimEnabledResult setIdentityDkimEnabledResult = email.setIdentityDkimEnabled(new SetIdentityDkimEnabledRequest() .withIdentity(testDomain)); assertNotNull(setIdentityDkimEnabledResult); } catch (AmazonServiceException exception) { fail("Exception encountered during enable"); } } finally { email.deleteIdentity(new DeleteIdentityRequest().withIdentity(testDomain)); Thread.sleep(20 * 1000); } }