/** * Verifies that the actual value is greater than or equal to the given one. * <p> * Example: * <pre><code class='java'> // assertions will pass * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(BigDecimal.ZERO); * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(BigDecimal.ONE); * // comparison is performed without scale consideration: * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(new BigDecimal("1.00")); * * // assertions will fail * assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE);</code></pre> * * Note that comparison of {@link BigDecimal} is done by value without scale consideration, i.e 2.0 and 2.00 are * considered equal in value unlike {@link BigDecimal#equals(Object)}. * * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ @Override public SELF isGreaterThanOrEqualTo(BigDecimal other) { return super.isGreaterThanOrEqualTo(other); } }
/** * Verifies that the actual value is greater than or equal to the given one. * <p> * Example: * <pre><code class='java'> // assertions will pass * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(BigDecimal.ZERO); * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(BigDecimal.ONE); * // comparison is performed without scale consideration: * assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(new BigDecimal("1.00")); * * // assertions will fail * assertThat(BigDecimal.ZERO).isGreaterThanOrEqualTo(BigDecimal.ONE);</code></pre> * * Note that comparison of {@link BigDecimal} is done by value without scale consideration, i.e 2.0 and 2.00 are * considered equal in value unlike {@link BigDecimal#equals(Object)}. * * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ @Override public SELF isGreaterThanOrEqualTo(BigDecimal other) { return super.isGreaterThanOrEqualTo(other); } }
@Test public void monoProcessorBlockIsUnbounded() { long start = System.nanoTime(); String result = Mono.just("foo") .delayElement(Duration.ofMillis(500)) .toProcessor() .block(); assertThat(result).isEqualTo("foo"); assertThat(Duration.ofNanos(System.nanoTime() - start)) .isGreaterThanOrEqualTo(Duration.ofMillis(500)); }
/** * Verifies that the elapsed time is in given range. * * @param start the start value of range (inclusive). * @param end the end value of range (exclusive). * @return this instance. * @see IAccessEvent#getElapsedTime() */ public S hasElapsedTime(LocalDateTime start, LocalDateTime end) { long actualElapsedTimeAsLong = actual.getElapsedTime(); Duration actualElapsedTime = Duration.ofMillis(actualElapsedTimeAsLong); Assertions.assertThat(actualElapsedTime) .isGreaterThanOrEqualTo(Duration.ofMillis(0L)) .isLessThanOrEqualTo(Duration.between(start, end)); return myself; }
/** * Verifies that the elapsed seconds is in given range. * * @param start the start value of range (inclusive). * @param end the end value of range (exclusive). * @return this instance. * @see IAccessEvent#getElapsedSeconds() */ public S hasElapsedSeconds(LocalDateTime start, LocalDateTime end) { long actualElapsedSecondsAsLong = actual.getElapsedSeconds(); Duration actualElapsedSeconds = Duration.ofSeconds(actualElapsedSecondsAsLong); Assertions.assertThat(actualElapsedSeconds) .isGreaterThanOrEqualTo(Duration.ofSeconds(0L)) .isLessThanOrEqualTo(Duration.between(start, end)); return myself; }
@Test public void testTimeout() { Instant start = Instant.now(); Thread exhauster = exhaust(); Futures.getUnchecked(limiters.acquireLimiterInternal(KEY).acquire()); Instant end = Instant.now(); exhauster.interrupt(); assertThat(Duration.between(start, end)).isGreaterThanOrEqualTo(TIMEOUT); }
@Test public void shouldTriggerTimer() { // given testClient.deploy(SINGLE_TIMER_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then final Record<TimerRecordValue> triggeredEvent = RecordingExporter.timerRecords(TimerIntent.TRIGGERED).getFirst(); assertThat(triggeredEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(triggeredEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(Duration.between(createdEvent.getTimestamp(), triggeredEvent.getTimestamp())) .isGreaterThanOrEqualTo(Duration.ofMillis(100)); }
@Test public void shouldTriggerTimer() { // given testClient.deploy(SINGLE_TIMER_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then final Record<TimerRecordValue> triggeredEvent = RecordingExporter.timerRecords(TimerIntent.TRIGGERED).getFirst(); assertThat(triggeredEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(triggeredEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(Duration.between(createdEvent.getTimestamp(), triggeredEvent.getTimestamp())) .isGreaterThanOrEqualTo(Duration.ofMillis(100)); }
@Test void defaults() { final Job j = new MyJob(); assertSoftly(softly -> { softly.assertThat(j.startIn()).isGreaterThanOrEqualTo(Duration.ZERO); softly.assertThat(j.repeatEvery()).isEqualTo(Duration.ZERO); softly.assertThat(j.killIn()).isGreaterThan(Duration.ZERO); }); }