GraphConfigurationService implements IGraphConfigurationService { @Override public Set<Class> getNextOperations(final String operationClassName) { Class<? extends Operation> opClass; try { opClass = Class.forName(SimpleClassNameIdResolver.getClassName(operationClassName)).asSubclass(Operation.class); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException("Operation class was not found: " + operationClassName, e); } catch (final ClassCastException e) { throw new IllegalArgumentException(operationClassName + " does not extend Operation", e); } return (Set) graphFactory.getGraph().getNextOperations(opClass); } GraphConfigurationService(); static void initialise(); @Override Schema getSchema(); @Override String getDescription(); @Override Set<Class> getFilterFunctions(); @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "Need to wrap all runtime exceptions before they are given to the user") @Override Set<Class> getFilterFunctions(final String inputClass); @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "Need to wrap all runtime exceptions before they are given to the user") @Override Set<String> getSerialisedFields(final String className); @Override Set<Class> getTransformFunctions(); @Override Set<StoreTrait> getStoreTraits(); @Override Set<Class> getNextOperations(final String operationClassName); @Override Set<Class> getElementGenerators(); @Override Set<Class> getObjectGenerators(); @Override Set<Class> getOperations(); @Override Boolean isOperationSupported(final Class operation);  }
@Test public void shouldGetNextOperations() throws IOException { final Set<Class<? extends Operation>> expectedNextOperations = mock(Set.class); lenient().when(store.getNextOperations(GetElements.class)).thenReturn(expectedNextOperations); final Set<Class> nextOperations = service.getNextOperations(GetElements.class.getName()); assertSame(expectedNextOperations, nextOperations); }
@Test public void shouldThrowExceptionWhenGetNextOperationsWithUnknownClassName() throws IOException { try { service.getNextOperations("an unknown class name"); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("Operation class was not found")); } }
@Test public void shouldThrowExceptionWhenGetNextOperationsWithNonOperationClassName() throws IOException { try { service.getNextOperations(String.class.getName()); fail("Exception expected"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("does not extend Operation")); } }