/** * Create a graph instance that uses the supplied repository and {@link ExecutionContext context}. * * @param sourceName the name of the source that should be used * @param connectionFactory the factory of repository connections * @param context the context in which all executions should be performed * @return the new graph * @throws IllegalArgumentException if the source or context parameters are null * @throws RepositorySourceException if a source with the supplied name does not exist */ public static Graph create( String sourceName, RepositoryConnectionFactory connectionFactory, ExecutionContext context ) { return new Graph(sourceName, connectionFactory, context); }
/** * Create a graph instance that uses the supplied {@link RepositoryConnection} and {@link ExecutionContext context}. * * @param source the source that should be used * @param context the context in which all executions should be performed * @return the new graph * @throws IllegalArgumentException if the connection or context parameters are null */ public static Graph create( final RepositorySource source, ExecutionContext context ) { CheckArg.isNotNull(source, "source"); final String connectorSourceName = source.getName(); RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() { public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException { if (connectorSourceName.equals(sourceName)) return source.getConnection(); return null; } }; return new Graph(connectorSourceName, connectionFactory, context); }
/** * Create a graph instance that uses the supplied {@link RepositoryConnection} and {@link ExecutionContext context}. * * @param connection the connection that should be used * @param context the context in which all executions should be performed * @return the new graph * @throws IllegalArgumentException if the connection or context parameters are null */ public static Graph create( final RepositoryConnection connection, ExecutionContext context ) { CheckArg.isNotNull(connection, "connection"); final String connectorSourceName = connection.getSourceName(); RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() { public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException { if (connectorSourceName.equals(sourceName)) return connection; return null; } }; return new Graph(connectorSourceName, connectionFactory, context); }
@Before public void beforeEach() { MockitoAnnotations.initMocks(this); executedRequests = new LinkedList<Request>(); sourceName = "Source"; context = new ExecutionContext(); connection = new MockRepositoryConnection(); when(connectionFactory.createConnection(sourceName)).thenReturn(connection); graph = new Graph(sourceName, connectionFactory, context); validPathString = "/a/b/c"; validUuid = UUID.randomUUID(); validPath = createPath(validPathString); validNameString = "theName"; validName = createName(validNameString); Name idProperty1Name = createName("id1"); Name idProperty2Name = createName("id2"); validIdProperty1 = context.getPropertyFactory().create(idProperty1Name, "1"); validIdProperty2 = context.getPropertyFactory().create(idProperty2Name, "2"); validLocation = Location.create(validPath); properties = new HashMap<Location, Collection<Property>>(); children = new HashMap<Location, List<Location>>(); nextColumns = null; nextTuples = null; nextStatistics = null; }