@Test
public void testWithRandomClosedPort() throws Exception {

    DelegateExecution execution = mock(DelegateExecution.class);
    when(execution.getVariable(eq(IsMachinePortOpen.MACHINE)))
        .thenReturn(Machine.builder().localhost().createMachine());
    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);
    JavaDelegate delegate = new IsMachinePortOpen(RESULT, findRandomNotUsedPort());
    delegate.execute(execution);
    assertThat((Boolean) collector.getVariable(RESULT)).isFalse();
}