|
17 | 17 | */ |
18 | 18 | package com.fusiondb.studio.api; |
19 | 19 |
|
| 20 | +import io.restassured.http.Header; |
20 | 21 | import io.restassured.response.ExtractableResponse; |
21 | 22 | import io.restassured.response.Response; |
22 | 23 | import org.junit.jupiter.api.Assumptions; |
|
27 | 28 | import static com.evolvedbinary.j8fu.tuple.Tuple.Tuple; |
28 | 29 | import static com.fusiondb.studio.api.API.*; |
29 | 30 | import static io.restassured.RestAssured.given; |
| 31 | +import static io.restassured.RestAssured.when; |
30 | 32 | import static io.restassured.http.ContentType.JSON; |
31 | 33 | import static io.restassured.http.ContentType.XML; |
32 | 34 | import static io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.BINARY; |
@@ -87,6 +89,31 @@ public void createBinary() { |
87 | 89 | assertTrue(documentResponse.jsonPath().getBoolean("binaryDoc")); |
88 | 90 | } |
89 | 91 |
|
| 92 | + @Test |
| 93 | + public void deleteDocument() { |
| 94 | + final String documentPath = "/db/fusion-studio-api-test-document-it-col-6"; |
| 95 | + |
| 96 | + // 1. create a document |
| 97 | + final long now = System.currentTimeMillis(); |
| 98 | + ExtractableResponse<Response> collectionResponse = createXml(documentPath, "<time>" + now + "</time>"); |
| 99 | + assertEquals(documentPath, collectionResponse.jsonPath().getString("uri")); |
| 100 | + |
| 101 | + // 2. delete the document |
| 102 | + given(). |
| 103 | + auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD). |
| 104 | + header(new Header("x-fs-move-source", documentPath)). |
| 105 | + when(). |
| 106 | + delete(getApiBaseUri() + "/document?uri=" + documentPath). |
| 107 | + then(). |
| 108 | + statusCode(SC_NO_CONTENT); |
| 109 | + |
| 110 | + // 3. check the document no longer exists |
| 111 | + when(). |
| 112 | + get(getApiBaseUri() + "/explorer?uri=" + documentPath). |
| 113 | + then(). |
| 114 | + statusCode(SC_FORBIDDEN); //TODO(AR) should this be SC_NOT_FOUND? |
| 115 | + } |
| 116 | + |
90 | 117 | @Test |
91 | 118 | public void updateOwnerAndGroup() { |
92 | 119 | final String docPath = "/db/fusion-studio-api-test-document-it-3.xml"; |
|
0 commit comments