AWSIAMAuthService { public ResponseEntity<String> fetchIAMRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/iam/roles",jsoninput,token); 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_fetchIAMRole_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String jsoninput= "{\"role\":\"mytestawsrole\"}"; String jsonGetStr = "{\"bound_ami_id\": [\"ami-fce3c696\"],\"role_tag\": \"\",\"policies\": " + "[\"\\\"[prod\", \"dev\\\"]\" ],\"bound_iam_principal_arn\": [],\"bound_iam_role_arn\":" + "[ \"arn:aws:iam::8987887:role/test-role\"],\"max_ttl\": 0,\"disallow_reauthentication\": " + "false,\"allow_instance_migration\": false}"; Response getResponse = getMockResponse(HttpStatus.OK, true, jsonGetStr); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(jsonGetStr); when(reqProcessor.process("/auth/aws/iam/roles",jsoninput,token)).thenReturn(getResponse); ResponseEntity<String> responseEntity = awsIamAuthService.fetchIAMRole(token, "mytestawsrole"); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }