3636import com .amazonaws .services .iot .model .DescribeEndpointRequest ;
3737import com .amazonaws .services .iot .model .DescribeEndpointResult ;
3838import com .amazonaws .services .iot .model .DetachPolicyRequest ;
39+ import com .amazonaws .services .iot .model .ResourceAlreadyExistsException ;
3940import com .amazonaws .services .iot .model .UpdateCertificateRequest ;
4041
4142import org .junit .After ;
@@ -1124,8 +1125,7 @@ private void createAndAttachPolicy() {
11241125 createPolicyRequest .setPolicyDocument (policyDocument );
11251126 this .createPolicyResult = iotClient .createPolicy (createPolicyRequest );
11261127 } catch (Exception ex ) {
1127- assertTrue ("Error in creating the policy. " ,
1128- ex .getMessage ().startsWith ("Policy cannot be created - name already exists " ));
1128+ assertEquals (ex .getClass (), ResourceAlreadyExistsException .class );
11291129 }
11301130
11311131 AttachPolicyRequest attachPolicyRequest = new AttachPolicyRequest ();
@@ -1135,13 +1135,13 @@ private void createAndAttachPolicy() {
11351135 }
11361136
11371137 /**
1138- * Detatch the policy from the certificate.
1138+ * Detach the policy from the certificate.
11391139 * Delete the policy.
11401140 * Update certificate status as inactive.
11411141 * Delete the certificate.
11421142 */
11431143 private void deletePolicyAndCertificate () {
1144- Log .d (TAG , "Detatching the policy from the certificate." );
1144+ Log .d (TAG , "Detaching the policy from the certificate." );
11451145 DetachPolicyRequest detachPolicyRequest = new DetachPolicyRequest ();
11461146 detachPolicyRequest .setPolicyName (IOT_POLICY_NAME );
11471147 detachPolicyRequest .setTarget (this .certResult .getCertificateArn ());
0 commit comments