mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 09:46:17 +00:00
Order of files attached to document
This commit is contained in:
@@ -204,9 +204,9 @@ public class FileResource extends BaseResource {
|
||||
}
|
||||
|
||||
// Update the file
|
||||
// TODO Reorder files to put the new one at the end
|
||||
file.setDocumentId(documentId);
|
||||
fileDao.updateDocument(file);
|
||||
file.setOrder(fileDao.getByDocumentId(documentId).size());
|
||||
fileDao.update(file);
|
||||
|
||||
// Raise a new file created event (it wasn't sent during file creation)
|
||||
try {
|
||||
|
||||
@@ -238,5 +238,16 @@ public class TestFileResource extends BaseJerseyTest {
|
||||
response = documentResource.post(ClientResponse.class, postParams);
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
json = response.getEntity(JSONObject.class);
|
||||
|
||||
// Get all files from a document
|
||||
fileResource = resource().path("/file/list");
|
||||
fileResource.addFilter(new CookieAuthenticationFilter(file2AuthenticationToken));
|
||||
MultivaluedMapImpl getParams = new MultivaluedMapImpl();
|
||||
getParams.putSingle("id", document1Id);
|
||||
response = fileResource.queryParams(getParams).get(ClientResponse.class);
|
||||
json = response.getEntity(JSONObject.class);
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
JSONArray files = json.getJSONArray("files");
|
||||
Assert.assertEquals(1, files.length());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user