@Test
public void test_write_successfully() {

    String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
    String jsonStr = "{\"path\":\"shared/mysafe01/myfolder\",\"data\":{\"secret1\":\"value1\",\"secret2\":\"value2\"}}";
    HashMap<String, String> data = new HashMap<>();
    data.put("secret1", "value1");
    Secret secret = new Secret("shared/mysafe01/myfolder", data);
    Response response = getMockResponse(HttpStatus.NO_CONTENT, true, "");
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Secret saved to vault\"]}");
    when(ControllerUtil.addDefaultSecretKey(jsonStr)).thenReturn("{\"path\":\"shared/mysafe01/myfolder\",\"data\":{\"secret1\":\"value1\",\"secret2\":\"value2\"}}");
    when(ControllerUtil.areSecretKeysValid(jsonStr)).thenReturn(true);
    when(ControllerUtil.isPathValid("shared/mysafe01/myfolder")).thenReturn(true);
    when(reqProcessor.process("/write",jsonStr,token)).thenReturn(response);
    String path ="shared/mysafe01/myfolder";
    when(ControllerUtil.getSafeType(path)).thenReturn("shared");
    when(ControllerUtil.getSafeName(path)).thenReturn("mysafe01");
    String policies[] = {"w_shared_mysafe01"};
    UserDetails userDetails = getMockUser(false);
    userDetails.setPolicies(policies);
    when(JSONUtil.getJSON(secret)).thenReturn(jsonStr);
    ResponseEntity<String> responseEntity = secretService.write(token, secret, userDetails);
    assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
    assertEquals(responseEntityExpected, responseEntity);
}