AWSIAMAuthService { public ResponseEntity<String> deleteIAMRole(String token, String role){ Response response = reqProcessor.process("/auth/aws/iam/roles/delete","{\"role\":\""+role+"\"}",token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"IAM Role deleted \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }  ResponseEntity<String> createIAMRole(AWSIAMRole awsiamRole, String token, UserDetails userDetails); ResponseEntity<String> updateIAMRole(String token, AWSIAMRole awsiamRole); ResponseEntity<String> fetchIAMRole(String token, String role); ResponseEntity<String> listIAMRoles(String token); ResponseEntity<String> deleteIAMRole(String token, String role); Response configureAWSIAMRole(String roleName,String policies,String token );  }
@Test public void test_deleteIAMRole_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; Response response = getMockResponse(HttpStatus.NO_CONTENT, true, ""); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"IAM Role deleted \"]}"); when(reqProcessor.process("/auth/aws/iam/roles/delete","{\"role\":\"mytestawsrole\"}",token)).thenReturn(response); ResponseEntity<String> responseEntity = awsIamAuthService.deleteIAMRole(token, "mytestawsrole"); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
@Test public void test_deleteIAMRole_failure_500() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; Response response = getMockResponse(HttpStatus.INTERNAL_SERVER_ERROR, false, "{\"errors\":[\"Internal Server Error\"]}"); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"Internal Server Error\"]}"); when(reqProcessor.process("/auth/aws/iam/roles/delete","{\"role\":\"mytestawsrole\"}",token)).thenReturn(response); ResponseEntity<String> responseEntity = awsIamAuthService.deleteIAMRole(token, "mytestawsrole"); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }