AWSIAMAuthService { public Response configureAWSIAMRole(String roleName,String policies,String token ){ ObjectMapper objMapper = new ObjectMapper(); Map<String,String>configureRoleMap = new HashMap<String,String>(); configureRoleMap.put("role", roleName); configureRoleMap.put("policies", policies); String awsConfigJson =""; try { awsConfigJson = objMapper.writeValueAsString(configureRoleMap); } catch (JsonProcessingException e) { logger.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "configureAWSIAMRole"). put(LogMessage.MESSAGE, String.format ("Unable to create awsConfigJson with message [%s] for roleName [%s] policies [%s] ", e.getMessage(), roleName, policies)). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } return reqProcessor.process("/auth/aws/iam/roles/update",awsConfigJson,token); }  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_configureAWSIAMRole_successfully() { String roleName = "role1"; String policies = "{\"default\"}"; String token = "7QPMPIGiyDFlJkrK3jFykUqa"; Response responsemock = getMockResponse(HttpStatus.NO_CONTENT, true, ""); when(reqProcessor.process(eq("/auth/aws/iam/roles/update"),Mockito.any(),eq(token))).thenReturn(responsemock); Response response = awsIamAuthService.configureAWSIAMRole(roleName, policies, token); assertEquals(HttpStatus.NO_CONTENT, response.getHttpstatus()); }