@Test
public void test_deleteAppRole_successfully() throws Exception{

    String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
    String appRoleId = "approle1";
    Response response =getMockResponse(HttpStatus.NO_CONTENT, true, "");
    Response responseOK =getMockResponse(HttpStatus.OK, true, "{\"createdBy\":\"safeadmin\"}");
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"AppRole deleted\"]}");
    AppRole appRole = new AppRole();
    appRole.setRole_name(appRoleId);
    String jsonStr = "{\"role_name\":\"approle1\",\"policies\":null,\"bind_secret_id\":false,\"secret_id_num_uses\":null,\"secret_id_ttl\":null,\"token_num_uses\":null,\"token_ttl\":null,\"token_max_ttl\":null}";
    when(JSONUtil.getJSON(appRole)).thenReturn(jsonStr);
    when(reqProcessor.process("/auth/approle/role/delete",jsonStr,token)).thenReturn(response);
    UserDetails userDetails = getMockUser(true);
    when(reqProcessor.process(eq("/read"),Mockito.any(),eq(token))).thenReturn(responseOK);
    Map<String, Object> responseMap = new HashMap<>();
    responseMap.put("createdBy", "safeadmin");
    when(ControllerUtil.parseJson(Mockito.any())).thenReturn(responseMap);
    when(reqProcessor.process(eq("/delete"),Mockito.any(),eq(token))).thenReturn(response);
    // START - isAllowed
    String approleusername="safeadmin";
    String role_name=appRole.getRole_name();
    String path = TVaultConstants.APPROLE_METADATA_MOUNT_PATH + "/" + role_name;
    Response approleMetadataResponse = getMockResponse(HttpStatus.OK, true, getAppRoleMetadataJSON(path, approleusername, role_name));
    when(reqProcessor.process("/read","{\"path\":\""+path+"\"}",userDetails.getSelfSupportToken())).thenReturn(approleMetadataResponse);
	String appRoleResponseJspn = "{\"path\":\"metadata/approle/approle1\",\"data\":{\"name\":\"approle1\",\"createdBy\":\"safeadmin\"}}";
    Map<String, Object> appRoleResponseMap = new HashMap<>();
    Map<String, Object> appRoleMetadataMap = new HashMap<>();
    appRoleMetadataMap.put("createdBy",approleusername);
    appRoleResponseMap.put ("data", appRoleMetadataMap);
    when(ControllerUtil.parseJson(appRoleResponseJspn)).thenReturn(appRoleResponseMap);
    // END - isAllowed
    Response permissionResponse =getMockResponse(HttpStatus.OK, true, "");
    when(ControllerUtil.canDeleteRole(appRole.getRole_name(), token, userDetails, TVaultConstants.APPROLE_METADATA_MOUNT_PATH)).thenReturn(permissionResponse);
    ResponseEntity<String> responseEntityActual = appRoleService.deleteAppRole(token, appRole, userDetails);
    assertEquals(HttpStatus.OK, responseEntityActual.getStatusCode());
    assertEquals(responseEntityExpected, responseEntityActual);
}