1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-17 11:41:41 +00:00

#55: Export document in PDF (REST resource + export options UI)

This commit is contained in:
jendib
2016-01-01 01:56:54 +01:00
parent 25a17ae2da
commit 2c791f5123
4 changed files with 111 additions and 16 deletions

View File

@@ -196,6 +196,14 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals(1, tags.size());
Assert.assertEquals(tag1Id, tags.getJsonObject(0).getString("id"));
// Export a document in PDF format
Response response = target().path("/document/" + document1Id).request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
.get();
InputStream is = (InputStream) response.getEntity();
byte[] pdfBytes = ByteStreams.toByteArray(is);
Assert.assertTrue(pdfBytes.length > 0);
// Create a tag
json = target().path("/tag").request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
@@ -244,7 +252,7 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertFalse(thumbnailFile.exists());
// Get a document (KO)
Response response = target().path("/document/" + document1Id).request()
response = target().path("/document/" + document1Id).request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
.get();
Assert.assertEquals(Status.NOT_FOUND, Status.fromStatusCode(response.getStatus()));