### Question:
PathParser { public static PrestoContextField getContextField(Presto session, String path) { PrestoDataProvider dataProvider = session.getDataProvider(); PrestoSchemaProvider schemaProvider = session.getSchemaProvider(); String[] traverse = path.split(FIELD_PATH_SEPARATOR_REGEX); if (traverse.length % 3 != 0) { throw new RuntimeException("Invalid field path: " + path); } int steps = traverse.length / 3; String startTopicId = PathParser.deskull(traverse[0]); String startViewId = traverse[1]; String startFieldId = traverse[2]; boolean isNewTopic = PrestoContext.isNewTopic(startTopicId); PrestoTopic currentTopic; String startTypeId; if (isNewTopic) { currentTopic = null; startTypeId = PrestoContext.getTypeId(startTopicId); } else { currentTopic = dataProvider.getTopicById(startTopicId); if (currentTopic == null) { return null; } startTypeId = currentTopic.getTypeId(); } PrestoType currentType = schemaProvider.getTypeById(startTypeId); PrestoView currentView = currentType.getViewById(startViewId); PrestoField currentField = currentType.getFieldById(startFieldId, currentView); PrestoContext currentContext; if (isNewTopic) { currentContext = PrestoContext.create(session.getResolver(), currentType, currentView); } else { currentContext = PrestoContext.create(session.getResolver(), currentTopic, currentType, currentView); } for (int i=1; i < steps; i++) { String topicId = PathParser.deskull(traverse[i*3]); String viewId = traverse[i*3+1]; String fieldId = traverse[i*3+2]; if (PrestoContext.isNewTopic(topicId)) { currentTopic = null; currentType = PrestoContext.getTypeOfNewTopic(topicId, schemaProvider); currentView = currentType.getViewById(viewId); currentContext = PrestoContext.createSubContext(currentContext, currentField, topicId, viewId); } else { currentTopic = findInParentField(currentContext, currentField, topicId); if (currentTopic == null) { return null; } String typeId = currentTopic.getTypeId(); currentType = schemaProvider.getTypeById(typeId); currentView = currentType.getViewById(viewId); currentContext = PrestoContext.createSubContext(currentContext, currentField, currentTopic, currentType, currentView); } currentField = currentType.getFieldById(fieldId, currentView); } return new PrestoContextField(currentContext, currentField); }  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 testGetContextField() { PrestoContextField contextField = PathParser.getContextField(session, "o:root$pinfo$children$o:child1$cinfo$grandchildren"); PrestoContext context = contextField.getContext(); PrestoTopic topic = context.getTopic(); Assert.assertEquals(topic.getId(), "o:child1"); PrestoField field = contextField.getField(); Assert.assertEquals(field.getId(), "grandchildren"); }