diff options
author | Henrik <henrik.hoiness@online.no> | 2018-07-06 15:37:22 +0200 |
---|---|---|
committer | Henrik <henrik.hoiness@online.no> | 2018-07-06 15:37:22 +0200 |
commit | e3d200c2f2bb004a808ea82d03d3f4f496469607 (patch) | |
tree | 6b7f69a8e20b30492fec773db2896e157511f1d5 /container-core | |
parent | 1c604359c6a432685b6edbb3e721aa9af91a518e (diff) |
Added Copyrigths and changes a few things for ids on HTMLElements
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/test/java/com/yahoo/restapi/PathTest.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/restapi/PathTest.java b/container-core/src/test/java/com/yahoo/restapi/PathTest.java new file mode 100644 index 00000000000..9e77dc7b3f0 --- /dev/null +++ b/container-core/src/test/java/com/yahoo/restapi/PathTest.java @@ -0,0 +1,62 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.restapi; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * @author bratseth + */ +public class PathTest { + + @Test + public void testPath() { + assertFalse(new Path("").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///foo").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///bar/").matches("/a/{foo}/bar/{b}")); + Path path = new Path("/a/1/bar/fuz"); + assertTrue(path.matches("/a/{foo}/bar/{b}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + } + + @Test + public void testPathWithRest() { + { + Path path = new Path("/a/1/bar/fuz/"); + assertTrue(path.matches("/a/{foo}/bar/{b}/{*}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + assertEquals("", path.getRest()); + } + + { + Path path = new Path("/a/1/bar/fuz/kanoo"); + assertTrue(path.matches("/a/{foo}/bar/{b}/{*}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + assertEquals("kanoo", path.getRest()); + } + + { + Path path = new Path("/a/1/bar/fuz/kanoo/trips"); + assertTrue(path.matches("/a/{foo}/bar/{b}/{*}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + assertEquals("kanoo/trips", path.getRest()); + } + + { + Path path = new Path("/a/1/bar/fuz/kanoo/trips/"); + assertTrue(path.matches("/a/{foo}/bar/{b}/{*}")); + assertEquals("1", path.get("foo")); + assertEquals("fuz", path.get("b")); + assertEquals("kanoo/trips/", path.getRest()); + } + } + +} |