@Test
  public void requestShouldBeSendToGetMachine() throws Exception {
    presenter.onMachineSelected(machineState1);

    verify(machineState1).getId();

    verify(machinePromise).then(operationMachineCaptor.capture());
    operationMachineCaptor.getValue().apply(machineDescriptor1);

    verify(entityFactory).createMachine(machineDescriptor1);
    verify(appliance).showAppliance(machine1);

    assertThat(machineState1, is(equalTo(presenter.getSelectedMachineState())));
    assertThat(presenter.isMachineRunning(), is(true));
  }
  @Test
  public void stubShouldBeDisplayedWhenWeTryGetMachineWhichIsNotCreatedYet() throws Exception {
    PromiseError error = mock(PromiseError.class);

    presenter.onMachineSelected(machineState1);

    verify(machinePromise).catchError(errorPromiseCaptor.capture());
    errorPromiseCaptor.getValue().apply(error);

    verify(machineState1).getName();
    verify(locale).unavailableMachineStarting(anyString());
    verify(appliance).showStub(anyString());

    assertThat(presenter.isMachineRunning(), is(false));
    assertThat(machineState1, is(equalTo(presenter.getSelectedMachineState())));
  }
  @Test
  public void machineShouldBeGotFromCacheWhenWeSelectMachineTheSecondTime() throws Exception {
    presenter.onMachineSelected(machineState1);

    verify(machinePromise).then(operationMachineCaptor.capture());
    operationMachineCaptor.getValue().apply(machineDescriptor1);
    reset(service, appliance);

    presenter.onMachineSelected(machineState1);

    verify(appliance).showAppliance(machine1);

    verify(service, never()).getMachine(anyString());

    assertThat(machineState1, is(equalTo(presenter.getSelectedMachineState())));
    assertThat(presenter.isMachineRunning(), is(true));
  }