OperationProcessorImpl implements OperationProcessor { @Override public <I, O> Optional<O> process(Cloud cloud, OperationType operationType, Supplier<I> supplier) { Operation operation = doChecks(operationType, supplier); if (operation instanceof ProcessingOperation) { @SuppressWarnings("unchecked") O result = ((ProcessingOperation<I, O>) operation).perform(cloud, supplier); return Optional.ofNullable(result); } else { LOG.error("Operation {} should be a processing operation", operationType); return Optional.empty(); } } @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 public void testProcess() { assertThat( operationProcessor.process(CLOUD, DELETE_INSTANCE, () -> TEST_STRING), equalTo(Optional.of(TEST_STRING)) ); }
@Test public void testProcessNotProcessingOperation() { assertThat( operationProcessor.process(CLOUD, ADD_INSTANCE, () -> TEST_STRING), equalTo(Optional.empty()) ); }