### Question:
BlueprintsGraphMetaverseReader implements IMetaverseReader { @Override public Graph search( List<String> resultTypes, List<String> startNodeIDs, boolean shortestOnly ) { Graph g = new TinkerGraph(); for ( String startNodeID : startNodeIDs ) { if ( graph != null ) { Vertex startVertex = graph.getVertex( startNodeID ); GraphPath path = new GraphPath(); Set<Object> done = new HashSet<Object>(); Map<Object, GraphPath> shortestPaths = new HashMap<Object, GraphPath>(); traverseGraph( startVertex, graph, resultTypes, path, done, shortestPaths, Direction.IN, shortestOnly ); done = new HashSet<Object>(); traverseGraph( startVertex, graph, resultTypes, path, done, shortestPaths, Direction.OUT, shortestOnly ); Iterator<Map.Entry<Object, GraphPath>> paths = shortestPaths.entrySet().iterator(); while ( paths.hasNext() ) { Map.Entry<Object, GraphPath> entry = paths.next(); GraphPath shortPath = entry.getValue(); shortPath.addToGraph( g ); } } } g = enhanceGraph( g ); return g; } BlueprintsGraphMetaverseReader( Graph graph ); @Override IMetaverseNode findNode( String id ); @Override List<IMetaverseNode> findNodes( String property, String value ); @Override IMetaverseLink findLink( String leftNodeID, String linkType, String rightNodeID, Direction direction ); @Override Graph getMetaverse(); @Override String exportToXml(); @Override String exportFormat( String format ); void exportToStream( String format, OutputStream out ); @Override Graph search( List<String> resultTypes, List<String> startNodeIDs, boolean shortestOnly ); @Override Graph getGraph( String id );  }### Answer:
@Test public void testSearch() throws Exception { BlueprintsGraphMetaverseReader metaverseReader = new BlueprintsGraphMetaverseReader( graph ); List<String> types = new ArrayList<String>(); types.add( DictionaryConst.NODE_TYPE_TRANS ); List<String> ids = new ArrayList<String>(); ids.add( "datasource1.table1.field1" ); Graph graph = metaverseReader.search( types, ids, true ); assertNotNull( "Node is null", graph ); GraphMLWriter writer = new GraphMLWriter(); writer.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch1.graphml" ) ); GraphSONWriter writerJson = new GraphSONWriter(); writerJson.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch1.json" ) ); assertEquals( "Vertex count is wrong", 9, countVertices( graph ) ); assertEquals( "Edge count is wrong", 8, countEdges( graph ) ); types = new ArrayList<String>(); types.add( DictionaryConst.NODE_TYPE_FILE ); types.add( DictionaryConst.NODE_TYPE_DATA_TABLE ); ids = new ArrayList<String>(); ids.add( "datasource1.table1.field1" ); graph = metaverseReader.search( types, ids, true ); assertNotNull( "Node is null", graph ); writer.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch2.graphml" ) ); writerJson.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch2.json" ) ); assertEquals( "Vertex count is wrong", 8, countVertices( graph ) ); assertEquals( "Edge count is wrong", 7, countEdges( graph ) ); types = new ArrayList<>(); ids = new ArrayList<>(); ids.add( "datasource1.table2.field1" ); graph = metaverseReader.search( types, ids, false ); assertNotNull( "Node is null", graph ); writer.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch3.graphml" ) ); writerJson.outputGraph( graph, new FileOutputStream( OUTPUT_FOLDER + "testSearch3.json" ) ); assertEquals( "Vertex count is wrong", 14, countVertices( graph ) ); assertEquals( "Edge count is wrong", 15, countEdges( graph ) ); }