### Question:
PathParser { public static PrestoContext getTopicByPath(Presto session, String path, String topicId, String viewId) { if (path == null || path.equals("_")) { return PrestoContext.create(session.getResolver(), PathParser.deskull(topicId), viewId); } PrestoContextField contextField = getContextField(session, path); PrestoContext currentContext = contextField.getContext(); PrestoField currentField = contextField.getField(); if (PrestoContext.isNewTopic(topicId)) { return PrestoContext.createSubContext(currentContext, currentField, PathParser.deskull(topicId), viewId); } else { PrestoTopic resultTopic = findInParentField(currentContext, currentField, topicId); if (resultTopic == null) { return null; } else { String resultTypeId = resultTopic.getTypeId(); PrestoType resultType = session.getSchemaProvider().getTypeById(resultTypeId); PrestoView resultView = resultType.getViewById(viewId); return PrestoContext.createSubContext(currentContext, currentField, resultTopic, resultType, resultView); } } }  static PrestoContextField getContextField(Presto session, String path); static PrestoContext getTopicByPath(Presto session, String path, String topicId, String viewId); static String getInlineTopicPath(PrestoContext context, PrestoField field); static String skull(String u); static String deskull(String u); static String replaceUriPattern(String template, Map<String, String> values); static void main(String[] args);  }### Answer:
@Test public void testGetTopicByPathRoot() { PrestoContext topic = PathParser.getTopicByPath(session, "_", "o:root", "pinfo"); Assert.assertEquals(topic.getTopicId(), "o:root"); }
@Test public void testGetTopicByPathChild() { PrestoContext topic = PathParser.getTopicByPath(session, "o:root$pinfo$children", "o:child1", "cinfo"); Assert.assertEquals(topic.getTopicId(), "o:child1"); }
@Test public void testGetTopicByPathChildDirect() { PrestoContext topic = PathParser.getTopicByPath(session, "_", "o:child1", "cinfo"); Assert.assertEquals(topic.getTopicId(), "o:child1"); }
@Test public void testGetTopicByPathGrandchild() { PrestoContext topic = PathParser.getTopicByPath(session, "o:root$pinfo$children$o:child1$cinfo$grandchildren", "o:grandchild1", "ginfo"); Assert.assertEquals(topic.getTopicId(), "o:grandchild1"); }
@Test public void testGetTopicByPathGrandchildViaChild() { PrestoContext topic = PathParser.getTopicByPath(session, "o:child1$cinfo$grandchildren", "o:grandchild1", "ginfo"); Assert.assertEquals(topic.getTopicId(), "o:grandchild1"); }