### Question:
Util { public static Resource[] getContexts(String[] tokens, int pos, Repository repository) throws IllegalArgumentException { Resource[] contexts = new Resource[] {}; if (tokens.length > pos) { contexts = new Resource[tokens.length - pos]; for (int i = pos; i < tokens.length; i++) { contexts[i - pos] = getContext(repository, tokens[i]); } } return contexts; }  static Resource getContext(Repository repository, String ctxID); static Resource[] getContexts(String[] tokens, int pos, Repository repository); static Path getPath(String file); static String getPrefixedValue(Value value, Map<String, String> namespaces); @Deprecated static String formatToWidth(int width, String padding, String str, String separator);  }### Answer:
@Test public final void testContextsTwo() { String ONE = "http: String TWO = "_:two"; ValueFactory f = repo.getValueFactory(); Resource[] check = new Resource[] { f.createIRI(ONE), f.createBNode(TWO.substring(2)) }; String[] tokens = { "command", ONE, TWO }; Resource[] ctxs = Util.getContexts(tokens, 1, repo); assertTrue("Not equal", Arrays.equals(check, ctxs)); }
@Test public final void testContextsNull() { String[] tokens = { "command", "command2", "NULL" }; Resource[] ctxs = Util.getContexts(tokens, 2, repo); assertTrue("Not null", ctxs[0] == null); }
@Test public final void testContextsInvalid() { String[] tokens = { "command", "invalid" }; try { Resource[] ctxs = Util.getContexts(tokens, 1, repo); fail("No exception generated"); } catch (IllegalArgumentException expected) { } }