OperationProcessorImpl implements OperationProcessor { @Override public <T> boolean consume(Cloud cloud, OperationType operationType, Consumer<T> consumer) { return consumeImpl(cloud, operationType, Collections.emptySet(), consumer); } @Autowired  OperationProcessorImpl(OperationsAware operationsAware); @Override boolean consume(Cloud cloud, OperationType operationType, Consumer<T> consumer); @Override boolean consume(Cloud cloud, OperationType operationType, Set<String> ids, Consumer<T> consumer); @Override boolean supply(Cloud cloud, OperationType operationType, Supplier<T> supplier); @Override Optional<O> process(Cloud cloud, OperationType operationType, Supplier<I> supplier);  }
@Test(expected = IllegalArgumentException.class) public void testNoAction() { operationProcessor.consume(CLOUD, LIST_INSTANCES, null); }
@Test(expected = UnsupportedOperationException.class) public void testNoOperation() { operationProcessor.<String>consume(CLOUD, LIST_PROJECTS, anything -> {}); }
@Test public void testConsume() { List<String> results = new ArrayList<>(); assertThat( operationProcessor.<String>consume(CLOUD, LIST_INSTANCES, results::add), is(true) ); assertThat( operationProcessor.<String>consume( CLOUD, LIST_INSTANCES, Collections.singleton("some-id"), results::add ), is(true) ); assertThat(results, contains(TEST_STRING, TEST_STRING)); }
@Test public void testConsumeNotSupplyingOperation() { assertThat( operationProcessor.consume(CLOUD, ADD_INSTANCE, anything -> {}), is(false) ); }