Graph { public JobDetail executeJob(final Operation operation, final User user) throws OperationException { return executeJob(new GraphRequest<>(operation, user)).getResult(); } private  Graph(final GraphConfig config, final Store store); void execute(final Operation operation, final User user); void execute(final Operation operation, final Context context); O execute(final Output<O> operation, final User user); O execute(final Output<O> operation, final Context context); GraphResult<O> execute(final GraphRequest<O> request); JobDetail executeJob(final Operation operation, final User user); JobDetail executeJob(final Operation operation, final Context context); GraphResult<JobDetail> executeJob(final GraphRequest<?> request); JobDetail executeJob(final Job job, final User user); JobDetail executeJob(final Job job, final Context context); boolean isSupported(final Class<? extends Operation> operationClass); Set<Class<? extends Operation>> getSupportedOperations(); Set<Class<? extends Operation>> getNextOperations(final Class<? extends Operation> operation); View getView(); Schema getSchema(); String getDescription(); boolean hasTrait(final StoreTrait storeTrait); Set<StoreTrait> getStoreTraits(); String getGraphId(); StoreProperties getStoreProperties(); List<Class<? extends GraphHook>> getGraphHooks(); GraphLibrary getGraphLibrary();  }
@Test public void shouldThrowExceptionOnExecuteJobWithANullContext() throws OperationException { final Context context = null; final OperationChain opChain = mock(OperationChain.class); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); try { graph.executeJob(opChain, context); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("A context containing a user is required", e.getMessage()); } }
@Test public void shouldThrowExceptionOnExecuteJobWithANullUser() throws OperationException { final User user = null; final OperationChain opChain = mock(OperationChain.class); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); try { graph.executeJob(opChain, user); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("A user is required", e.getMessage()); } }
@Test public void shouldThrowExceptionOnExecuteJobUsingJobWithANullContext() throws OperationException { final Context context = null; final OperationChain opChain = mock(OperationChain.class); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); final Job job = new Job(null, opChain); try { graph.executeJob(job, context); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("A context is required", e.getMessage()); } }
@Test public void shouldThrowExceptionOnExecuteJobUsingJobWithANullOperation() throws OperationException { final Context context = new Context(); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); final Job job = new Job(new Repeat(), new OperationChain<>()); try { graph.executeJob(job, context); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("An operation is required", e.getMessage()); } }
@Test public void shouldThrowExceptionOnExecuteJobUsingJobWithANullJob() throws OperationException { final Context context = new Context(); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); final Job job = null; try { graph.executeJob(job, context); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("A job is required", e.getMessage()); } }
@Test public void shouldThrowExceptionOnExecuteJobUsingJobWithANullUser() throws OperationException { final User user = null; final OperationChain opChain = mock(OperationChain.class); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) .build()) .storeProperties(StreamUtil.storeProps(getClass())) .addSchemas(StreamUtil.schemas(getClass())) .build(); final Job job = new Job(null, opChain); try { graph.executeJob(job, user); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertEquals("User is required", e.getMessage()); } }