BdioMetadata extends BdioObject { public Map<String, Object> asNamedGraph(Object graph, String... keys) { Objects.requireNonNull(graph); Map<String, Object> namedGraph = new LinkedHashMap<>(this); if (keys.length > 0) { namedGraph.keySet().retainAll(Arrays.asList(keys)); } namedGraph.put(JsonLdConsts.GRAPH, graph); return namedGraph; } BdioMetadata();  BdioMetadata(Map<String, Object> other);  BdioMetadata(Throwable error); static BdioMetadata createRandomUUID(); Optional<Throwable> getThrowable(); Map<String, Object> asNamedGraph(Object graph, String... keys); Map<String, Object> asNamedGraph(); BdioMetadata merge(Map<String, Object> other); BdioMetadata id(@Nullable String id); BdioMetadata name(@Nullable String name); BdioMetadata captureOptions(@Nullable List<String> captureOptions); BdioMetadata captureInterval(@Nullable String captureInterval); BdioMetadata captureInterval(@Nullable ZonedDateTime start, @Nullable ZonedDateTime end); BdioMetadata creationDateTime(@Nullable ZonedDateTime creation); BdioMetadata creator(@Nullable String creator); BdioMetadata creator(@Nullable String user, @Nullable String host); BdioMetadata platform(@Nullable ProductList platform); BdioMetadata publisher(@Nullable ProductList publisher); BdioMetadata buildDetails(@Nullable String buildDetails); BdioMetadata buildNumber(@Nullable String buildNumber); BdioMetadata sourceRepository(@Nullable String sourceRepository); BdioMetadata sourceRevision(@Nullable String sourceRevision); BdioMetadata sourceBranch(@Nullable String sourceBranch); BdioMetadata sourceTag(@Nullable String sourceTag);  }
@Test public void generateNamedGraphAllKeysEmptyList() { BdioMetadata metadata = new BdioMetadata(); metadata.put("test1", "foo"); metadata.put("test2", "bar"); assertThat(metadata.asNamedGraph()).containsExactly( "test1", "foo", "test2", "bar", "@graph", Lists.newArrayList()); }
@Test public void generateNamedGraphAllKeys() { BdioMetadata metadata = new BdioMetadata(); metadata.put("test1", "foo"); metadata.put("test2", "bar"); assertThat(metadata.asNamedGraph(Lists.newArrayList("foobar"))).containsExactly( "test1", "foo", "test2", "bar", "@graph", Lists.newArrayList("foobar")); }
@Test public void generateNamedGraphSomeKeys() { BdioMetadata metadata = new BdioMetadata(); metadata.put("test1", "foo"); metadata.put("test2", "bar"); assertThat(metadata.asNamedGraph(Lists.newArrayList("foobar"), "test1")).containsExactly( "test1", "foo", "@graph", Lists.newArrayList("foobar")); }
@Test(expected = NullPointerException.class) public void generateNamedGraphNull() { new BdioMetadata().asNamedGraph(null); }