Closes #620: delete a non-existing document should return 404

This commit is contained in:
bgamard 2022-04-17 13:35:29 +02:00
parent e6cfd899e5
commit c6a685d7c0

View File

@ -401,6 +401,12 @@ public class TestDocumentResource extends BaseJerseyTest {
.delete(JsonObject.class); .delete(JsonObject.class);
Assert.assertEquals("ok", json.getString("status")); Assert.assertEquals("ok", json.getString("status"));
// Deletes a non-existing document
response = target().path("/document/69b79238-84bb-4263-a32f-9cbdf8c92188").request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
.delete();
Assert.assertEquals(Status.NOT_FOUND, Status.fromStatusCode(response.getStatus()));
// Check that the associated files are deleted from FS // Check that the associated files are deleted from FS
java.io.File storedFile = DirectoryUtil.getStorageDirectory().resolve(file1Id).toFile(); java.io.File storedFile = DirectoryUtil.getStorageDirectory().resolve(file1Id).toFile();
java.io.File webFile = DirectoryUtil.getStorageDirectory().resolve(file1Id + "_web").toFile(); java.io.File webFile = DirectoryUtil.getStorageDirectory().resolve(file1Id + "_web").toFile();