@Test
public void test_AssociateAppRole_succssfully() throws Exception {

    Response response = getMockResponse(HttpStatus.OK, true, "");
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Approle associated to SDB\"]}");
    String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
    SafeAppRoleAccess safeAppRoleAccess = new SafeAppRoleAccess("approle1", "shared/mysafe01", "write");
    String jsonStr = "{\"role_name\":\"approle1\",\"path\":\"shared/mysafe01\",\"access\":\"write\"}";
    Map<String, Object> requestMap = new ObjectMapper().readValue(jsonStr, new TypeReference<Map<String, Object>>(){});
    Response configureAppRoleResponse = getMockResponse(HttpStatus.OK, true, "");
    Response updateMetadataResponse = getMockResponse(HttpStatus.NO_CONTENT, true, "");
    when(ControllerUtil.parseJson(Mockito.anyString())).thenReturn(requestMap);
    when(reqProcessor.process(any(String.class),any(String.class),any(String.class))).thenReturn(response);
    when(ControllerUtil.isValidSafePath(Mockito.anyString())).thenReturn(true);
    when(ControllerUtil.isValidSafe(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
    when(reqProcessor.process(eq("/auth/approle/role/create"),Mockito.any(),eq(token))).thenReturn(configureAppRoleResponse);
    when(ControllerUtil.areSafeAppRoleInputsValid(Mockito.anyMap())).thenReturn(true);
    when(ControllerUtil.canAddPermission(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
    when(ControllerUtil.updateMetadata(Mockito.anyMap(),Mockito.anyString())).thenReturn(updateMetadataResponse);
    Response appRoleResponse = getMockResponse(HttpStatus.OK, true, "{\"data\": {\"policies\":\"w_shared_mysafe01\"}}");
    when(reqProcessor.process("/auth/approle/role/read","{\"role_name\":\"approle1\"}",token)).thenReturn(appRoleResponse);
    ResponseEntity<String> responseEntityActual =  appRoleService.associateApprole(token, safeAppRoleAccess);
    
    assertEquals(HttpStatus.OK, responseEntityActual.getStatusCode());
    assertEquals(responseEntityExpected, responseEntityActual);
}