@Test
public void test_write_failure_invalidPath() {

    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);
    ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid path\"]}");
    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(false);
    when(JSONUtil.getJSON(secret)).thenReturn(jsonStr);
    ResponseEntity<String> responseEntity = secretService.write(token, secret, getMockUser(false));
    assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
    assertEquals(responseEntityExpected, responseEntity);
}