@Test public void testMoveToNextPhaseWithoutError() { IntentData pending = new IntentData(input, INSTALL_REQ, version); expect(processor.compile(input, null)).andReturn(Collections.singletonList(compiled)); replay(processor); Compiling sut = new Compiling(processor, pending, Optional.empty()); Optional<IntentProcessPhase> output = sut.execute(); verify(processor); assertThat(output.get(), is(instanceOf(Installing.class))); }
@Override public Optional<IntentProcessPhase> execute() { try { List<Intent> compiled = processor.compile(data.intent(), stored.map(IntentData::installables).orElse(null)); return Optional.of(new Installing(processor, new IntentData(data, compiled), stored)); } catch (IntentException e) { log.debug("Unable to compile intent {} due to: {}", data.intent(), e); if (stored.filter(x -> !x.installables().isEmpty()).isPresent()) { return Optional.of(new Withdrawing(processor, new IntentData(data, stored.get().installables()))); } else { return Optional.of(new Failed(data)); } } }
Compiling implements IntentProcessPhase { @Override public Optional<IntentProcessPhase> execute() { try { List<Intent> compiled = processor.compile(data.intent(), stored.map(IntentData::installables).orElse(null)); return Optional.of(new Installing(processor, new IntentData(data, compiled), stored)); } catch (IntentException e) { log.debug("Unable to compile intent {} due to: {}", data.intent(), e); if (stored.filter(x -> !x.installables().isEmpty()).isPresent()) { return Optional.of(new Withdrawing(processor, new IntentData(data, stored.get().installables()))); } else { return Optional.of(new Failed(data)); } } } }
Compiling implements IntentProcessPhase { @Override public Optional<IntentProcessPhase> execute() { try { List<Intent> compiled = processor.compile(data.intent(), stored.map(IntentData::installables).orElse(null)); return Optional.of(new Installing(processor, new IntentData(data, compiled), stored)); } catch (IntentException e) { log.debug("Unable to compile intent {} due to: {}", data.intent(), e); if (stored.filter(x -> !x.installables().isEmpty()).isPresent()) { return Optional.of(new Withdrawing(processor, new IntentData(data, stored.get().installables()))); } else { return Optional.of(new Failed(data)); } } } Compiling(IntentProcessor processor, IntentData data, Optional<IntentData> stored); }
Compiling implements IntentProcessPhase { @Override public Optional<IntentProcessPhase> execute() { try { List<Intent> compiled = processor.compile(data.intent(), stored.map(IntentData::installables).orElse(null)); return Optional.of(new Installing(processor, new IntentData(data, compiled), stored)); } catch (IntentException e) { log.debug("Unable to compile intent {} due to: {}", data.intent(), e); if (stored.filter(x -> !x.installables().isEmpty()).isPresent()) { return Optional.of(new Withdrawing(processor, new IntentData(data, stored.get().installables()))); } else { return Optional.of(new Failed(data)); } } } Compiling(IntentProcessor processor, IntentData data, Optional<IntentData> stored); @Override Optional<IntentProcessPhase> execute(); }
Compiling implements IntentProcessPhase { @Override public Optional<IntentProcessPhase> execute() { try { List<Intent> compiled = processor.compile(data.intent(), stored.map(IntentData::installables).orElse(null)); return Optional.of(new Installing(processor, new IntentData(data, compiled), stored)); } catch (IntentException e) { log.debug("Unable to compile intent {} due to: {}", data.intent(), e); if (stored.filter(x -> !x.installables().isEmpty()).isPresent()) { return Optional.of(new Withdrawing(processor, new IntentData(data, stored.get().installables()))); } else { return Optional.of(new Failed(data)); } } } Compiling(IntentProcessor processor, IntentData data, Optional<IntentData> stored); @Override Optional<IntentProcessPhase> execute();  }