|
56 | 56 | import java.util.stream.Stream; |
57 | 57 |
|
58 | 58 | import static io.specto.hoverfly.junit.core.HoverflyConfig.localConfigs; |
59 | | -import static io.specto.hoverfly.junit.core.HoverflyMode.CAPTURE; |
60 | | -import static io.specto.hoverfly.junit.core.HoverflyMode.DIFF; |
61 | 59 | import static io.specto.hoverfly.junit.core.HoverflyUtils.checkPortInUse; |
62 | 60 | import static io.specto.hoverfly.junit.core.HoverflyUtils.readSimulationFromString; |
63 | 61 | import static io.specto.hoverfly.junit.dsl.matchers.HoverflyMatchers.any; |
@@ -532,27 +530,30 @@ private void persistSimulation(Path path, Simulation simulation) throws IOExcept |
532 | 530 | private void waitForHoverflyToBecomeHealthy() { |
533 | 531 | final Instant now = Instant.now(); |
534 | 532 |
|
535 | | - while (Duration.between(now, Instant.now()).toMillis() < hoverflyConfig.getHealthCheckTimeout().toMillis()) { |
| 533 | + while (Duration.between(now, Instant.now()).compareTo(hoverflyConfig.getHealthCheckTimeout()) < 0) { |
536 | 534 | if (hoverflyClient.getHealth()) return; |
537 | 535 | try { |
538 | | - // TODO: prefer executors and tasks to threads |
539 | 536 | Thread.sleep(hoverflyConfig.getHealthCheckRetryInterval().toMillis()); |
540 | 537 | } catch (InterruptedException e) { |
541 | 538 | throw new RuntimeException(e); |
542 | 539 | } |
543 | 540 | } |
544 | 541 | throw new IllegalStateException( |
545 | | - "Hoverfly has not become healthy in " + hoverflyConfig.getHealthCheckTimeout().toMillis() + " milliseconds"); |
| 542 | + "Hoverfly has not become healthy in " + hoverflyConfig.getHealthCheckTimeout().getSeconds() + " seconds"); |
546 | 543 | } |
547 | 544 |
|
548 | 545 | private void setModeWithArguments(HoverflyMode mode, HoverflyConfiguration config) { |
549 | | - if (mode == CAPTURE) { |
550 | | - hoverflyClient.setMode(mode, new ModeArguments(config.getCaptureHeaders(), config.isStatefulCapture())); |
551 | | - } else if (mode == DIFF) { |
552 | | - hoverflyClient.setMode(mode, new ModeArguments(config.getCaptureHeaders())); |
553 | | - } else { |
554 | | - hoverflyClient.setMode(mode); |
555 | | - } |
| 546 | + switch (mode) { |
| 547 | + case CAPTURE: |
| 548 | + hoverflyClient.setMode(mode, new ModeArguments(config.getCaptureHeaders(), config.isStatefulCapture())); |
| 549 | + break; |
| 550 | + case DIFF: |
| 551 | + hoverflyClient.setMode(mode, new ModeArguments(config.getCaptureHeaders())); |
| 552 | + break; |
| 553 | + default: |
| 554 | + hoverflyClient.setMode(mode); |
| 555 | + break; |
| 556 | + } |
556 | 557 | } |
557 | 558 |
|
558 | 559 | private void cleanUp() { |
|
0 commit comments