diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-03-10 13:46:18 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2021-03-10 18:16:20 +0300 |
commit | 0fad669dc96db0ec1fa0d8b4f596251088c7b437 (patch) | |
tree | 24b7446346ecd0926d1ae1c02c4aa8c8649d253f /app | |
parent | 181b2ff9950e0d15e1d2a99808f6164f5616ba18 (diff) |
Fix unit tests
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java b/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java index 020063c7b..6273379e3 100644 --- a/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java +++ b/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java @@ -8,6 +8,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import it.niedermann.nextcloud.deck.model.Attachment; +import it.niedermann.nextcloud.deck.model.enums.EAttachmentType; import it.niedermann.nextcloud.deck.model.ocs.Version; import static org.junit.Assert.assertEquals; @@ -22,21 +23,22 @@ public class AttachmentUtilTest { final Version versionThatDoesNotSupportFileAttachments = new Version("1.2.0", 1, 2, 0); final String accountUrl = "https://example.com"; - // TODO depends on https://github.com/nextcloud/deck/pull/2638 -// final Attachment attachment1 = new Attachment(); -// attachment1.setFileId("1337"); -// final String thumbnailUrl1 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, -1L, attachment1, 500); -// assertEquals("https://example.com/index.php/core/preview?fileId=1337&x=500&y=500", thumbnailUrl1); -// -// final Attachment attachment2 = new Attachment(); -// attachment2.setFileId("0815"); -// final String thumbnailUrl2 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, 0L, attachment2, 4711); -// assertEquals("https://example.com/index.php/core/preview?fileId=0815&x=4711&y=4711", thumbnailUrl2); + final Attachment attachment1 = new Attachment(); + attachment1.setFileid(1337L); + attachment1.setType(EAttachmentType.FILE); + final String thumbnailUrl1 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, -1L, attachment1, 500); + assertEquals("https://example.com/index.php/core/preview?fileId=1337&x=500&y=500", thumbnailUrl1); + + final Attachment attachment2 = new Attachment(); + attachment2.setFileid(815L); + attachment2.setType(EAttachmentType.FILE); + final String thumbnailUrl2 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, 0L, attachment2, 4711); + assertEquals("https://example.com/index.php/core/preview?fileId=815&x=4711&y=4711", thumbnailUrl2); // Given there is an invalid fileId... final Attachment attachment3 = new Attachment(); attachment3.setId(999L); - attachment3.setFileid(""); + attachment3.setFileid(null); final String thumbnailUrl3 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, 15L, attachment3, 205); // ... a fallback to the attachment itself should be returned assertEquals("https://example.com/index.php/apps/deck/cards/15/attachment/999", thumbnailUrl3); @@ -44,7 +46,7 @@ public class AttachmentUtilTest { // Given the server version does not support file attachments yet... final Attachment attachment4 = new Attachment(); attachment4.setId(111L); - attachment4.setFileid("222"); + attachment4.setFileid(222L); final String thumbnailUrl4 = AttachmentUtil.getThumbnailUrl(versionThatDoesNotSupportFileAttachments, accountUrl, 333L, attachment4, 444); // ... a fallback to the attachment itself should be returned assertEquals("https://example.com/index.php/apps/deck/cards/333/attachment/111", thumbnailUrl4); |