@Test void expandLinkWithSameAttributeAtTwoPlaces() throws Exception { Link link = Link.create("reference", "https://example.com/{a}/2/{a}"); link.resolve(); Map<String, String> map = new LinkedHashMap<>(); map.put("a", "test"); map.put("b", "another"); assertThat(link.expand(map)) .isEqualTo(new URI("https://example.com/test/2/test")); }
@Test void expandLink() throws Exception { Link link = Link.create("reference", "https://example.com/{a}/2/{b}"); link.resolve(); Map<String, String> map = new LinkedHashMap<>(); map.put("a", "test"); map.put("b", "another"); assertThat(link.expand(map)) .isEqualTo(new URI("https://example.com/test/2/another")); }
@Test void expandLinkMissingVariable() { Link link = Link.create("reference", "https://example.com/{a}/2/{b}"); link.resolve(); assertThatIllegalArgumentException() .isThrownBy(() -> link.expand(Collections.singletonMap("a", "test"))) .withMessageContaining("missing value for 'b'"); }