@Test public void testEmptyConstraints() { Assert.assertEquals("Empty constraints should produce dataset URI", URI.create("dataset:file:/datasets/test"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty) .build()); } }
@Test public void testAddExistsConstraints() { Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?id="), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.with("id")) .build()); Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?id=×tamp="), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.with("id").with("timestamp")) .build()); }
@Test public void testAddRangeConstraints() { Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?color=[green,)"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.from("color", "green")) .build()); Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?color=(,green]"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.to("color", "green")) .build()); Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?timestamp=[0,1405720705333)&color=(green,red]"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty .from("timestamp", 0l).toBefore("timestamp", 1405720705333L) .fromAfter("color", "green").to("color", "red")) .build()); }
@Test public void testAddEqualityConstraints() { Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?id=" + ID), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.with("id", new Utf8(ID))) .build()); Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?id=a,b"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.with("id", new Utf8("a"), new Utf8("b"))) .build()); Assert.assertEquals("Should add equality constraints", URI.create("view:file:/datasets/test?id=" + ID + "×tamp=1405720705333"), new URIBuilder("dataset:file:/datasets/test") .constraints( empty.with("id", new Utf8(ID)).with("timestamp", 1405720705333L)) .build()); Assert.assertEquals("Should add encoded equality constraints", URI.create("view:file:/datasets/test?id=a%2Fb"), new URIBuilder("dataset:file:/datasets/test") .constraints(empty.with("id", new Utf8("a/b"))) .build()); }