### Question:
DatasetUtil { public static URI mapResourceForDataset(Dataset dataset, URI resourceName) throws IOException { URI mappedResource = getNamedResourceURI(dataset, resourceName); return ResourceUtil.getAbsoluteResourceURI(dataset.getArchiveURI(), mappedResource); }  static URI getNamedResourceURI(Dataset dataset, URI resourceName); static String getValueOrDefault(JsonNode config, String key, String defaultValue); static boolean shouldResolveReferences(Dataset dataset); static URI mapResourceNameIfRequested(URI resourceName, JsonNode config); static URI mapResourceForDataset(Dataset dataset, URI resourceName);  }### Answer:
@Test public void lookupMappedResourceRelative() throws IOException { Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); dataset.setConfig(new ObjectMapper().readTree("{\"resources\": { \"previous/path.txt\": \"current/path.txt\" } }")); assertThat(DatasetUtil.mapResourceForDataset(dataset, URI.create("previous/path.txt")).toString(), is("some:uri/current/path.txt")); }
@Test public void lookupMappedResourceAbsoluteToRelative() throws IOException { Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); dataset.setConfig(new ObjectMapper().readTree("{\"resources\": { \"http: assertThat(DatasetUtil.mapResourceForDataset(dataset, URI.create("http: }
@Test public void lookupMappedResourceAbsoluteToAbsolute() throws IOException { Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); dataset.setConfig(new ObjectMapper().readTree("{\"resources\": { \"http: assertThat(DatasetUtil.mapResourceForDataset(dataset,URI.create("http: }
@Test public void lookupNonMappedResourceRelative() throws IOException { Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); assertThat(DatasetUtil.mapResourceForDataset(dataset,URI.create("previous/path.txt")).toString(), is("some:uri/previous/path.txt")); }
@Test public void lookupNonMappedResourceAbsolute() throws IOException { Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); assertThat(DatasetUtil.mapResourceForDataset(dataset,URI.create("http: is("http: }