Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-11-16 11:28:53 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-11-16 14:24:39 +0300
commit236924118f271d8cab19a5bcc8e4837c7886bef9 (patch)
tree912d720d801ac80bf8889a179abdef2010522943 /app
parent4663a0fbf62b730b71cc84717a44472beedcf9a6 (diff)
#707 Add some unit tests for cases where the URL doesn't contain a # character
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app')
-rw-r--r--app/src/test/java/it/niedermann/nextcloud/deck/ProjectUtilTest.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/app/src/test/java/it/niedermann/nextcloud/deck/ProjectUtilTest.java b/app/src/test/java/it/niedermann/nextcloud/deck/ProjectUtilTest.java
index 2c03f5952..1c8062051 100644
--- a/app/src/test/java/it/niedermann/nextcloud/deck/ProjectUtilTest.java
+++ b/app/src/test/java/it/niedermann/nextcloud/deck/ProjectUtilTest.java
@@ -10,7 +10,7 @@ import static org.junit.Assert.assertThrows;
public class ProjectUtilTest {
@Test
public void extractBoardIdAndCardIdFromUrl() {
- // Valid board URLs
+ // Valid board URLs with #
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("index.php/apps/deck/#/board/4"), new long[]{4});
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board/4"), new long[]{4});
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("example.com/index.php/apps/deck/#/board/4"), new long[]{4});
@@ -22,7 +22,28 @@ public class ProjectUtilTest {
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/#/board/4/card/0"), new long[]{4});
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/#/board/4/foo"), new long[]{4});
- // Valid card URLs
+ // Valid board URLs without #
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("example.com/index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("http://example.com/index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/board/4"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/board/4/card"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/board/4/card/"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/board/4/card/0"), new long[]{4});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/board/4/foo"), new long[]{4});
+
+ // Valid card URLs with #
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("example.com/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("http://example.com/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/index.php/apps/deck/#/board/4/card/6/"), new long[]{4, 6});
+ assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
+
+ // Valid card URLs without #
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
assertArrayEquals(ProjectUtil.extractBoardIdAndCardIdFromUrl("example.com/index.php/apps/deck/#/board/4/card/6"), new long[]{4, 6});
@@ -48,11 +69,13 @@ public class ProjectUtilTest {
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("https://example.com/nextcloud/index.php/call/qkzhe5k2"));
// Invalid URLs
- //noinspection ConstantConditions
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl(null));
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl(""));
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board/0"));
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board/0/card/3"));
assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/#/board//card/3"));
+ assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/board/0"));
+ assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/board/0/card/3"));
+ assertThrows(IllegalArgumentException.class, () -> ProjectUtil.extractBoardIdAndCardIdFromUrl("/index.php/apps/deck/board//card/3"));
}
}