Java Code Examples for org.assertj.core.api.SoftAssertions#assertSoftly()

The following examples show how to use org.assertj.core.api.SoftAssertions#assertSoftly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuotaMonitorTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void reaches90() {
    add(2700);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold90PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
    add(-1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
}
 
Example 2
Source File: DefaultInvestmentShareTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void shareBoundaries() {
    assertThatThrownBy(() -> new DefaultInvestmentShare(-1))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> new DefaultInvestmentShare(101))
        .isInstanceOf(IllegalArgumentException.class);
    final DefaultInvestmentShare s = new DefaultInvestmentShare(0);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(s.getMinimumShareInPercent())
            .isEqualTo(0);
        softly.assertThat(s.getMaximumShareInPercent())
            .isEqualTo(0);
    });
    final DefaultInvestmentShare s2 = new DefaultInvestmentShare(100);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(s2.getMinimumShareInPercent())
            .isEqualTo(0);
        softly.assertThat(s2.getMaximumShareInPercent())
            .isEqualTo(100);
    });
}
 
Example 3
Source File: QuotaMonitorTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void reaches99() {
    add(2970);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold90PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold99PercentReached())
            .isTrue();
    });
    add(-1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold90PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
}
 
Example 4
Source File: Tuple2Test.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void equals() {
    Tuple2 tuple = Tuple.of(1, 1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(null);
        softly.assertThat(tuple)
            .isNotEqualTo("");
    });
    Tuple2 tuple2 = Tuple.of(1, 1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isNotSameAs(tuple2);
        softly.assertThat(tuple)
            .isEqualTo(tuple2);
    });
    Tuple2 tuple3 = Tuple.of(1, 2);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple3)
            .isNotEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(tuple3);
    });
}
 
Example 5
Source File: RatingTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void allRatingsNowAvailable() {
    SoftAssertions.assertSoftly(softly -> {
        for (final Rating r : Rating.values()) {
            softly.assertThat(r.getMaximalRevenueRate())
                .as("Max revenue rate for " + r)
                .isGreaterThan(Ratio.ZERO);
            softly.assertThat(r.getMinimalRevenueRate())
                .as("Min revenue rate for " + r)
                .isGreaterThan(Ratio.ZERO);
            softly.assertThat(r.getFee())
                .as("Fee for " + r)
                .isGreaterThan(Ratio.ZERO);
            softly.assertThat(r.getInterestRate())
                .as("Interest rate for " + r)
                .isGreaterThan(Ratio.ZERO);
        }
    });
}
 
Example 6
Source File: RatingTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void someRatingsUnavailableBefore2019() {
    final Instant ratingsChange = Rating.MIDNIGHT_2019_03_18.minusSeconds(1);
    SoftAssertions.assertSoftly(softly -> {
        for (final Rating r : new Rating[] { Rating.AAE, Rating.AE }) {
            softly.assertThat(r.getMaximalRevenueRate(ratingsChange))
                .as("Max revenue rate for " + r)
                .isEqualTo(Ratio.ZERO);
            softly.assertThat(r.getMinimalRevenueRate(ratingsChange))
                .as("Min revenue rate for " + r)
                .isEqualTo(Ratio.ZERO);
            softly.assertThat(r.getFee(ratingsChange))
                .as("Fee for " + r)
                .isEqualTo(Ratio.ZERO);
        }
    });
}
 
Example 7
Source File: QuotaMonitorTest.java    From robozonky with Apache License 2.0 6 votes vote down vote up
@Test
void reaches50() {
    add(1500);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
    add(-1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold75PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
}
 
Example 8
Source File: SummarizerJobTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void basics() {
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(summarizer.payload())
            .isInstanceOf(Summarizer.class);
        softly.assertThat(summarizer.killIn())
            .isGreaterThanOrEqualTo(Duration.ofHours(1));
        softly.assertThat(summarizer.repeatEvery())
            .isEqualTo(Duration.ofDays(7));
    });
}
 
Example 9
Source File: RatingTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void feesBefore2018() {
    final Instant ratingsChange = Rating.MIDNIGHT_2017_09_01.minusSeconds(1);
    SoftAssertions.assertSoftly(softly -> {
        for (final Rating r : new Rating[] { Rating.AAAAA, Rating.AAAA, Rating.AAA, Rating.AA, Rating.A, Rating.B,
                Rating.C, Rating.D }) {
            softly.assertThat(r.getFee(ratingsChange))
                .as("Fee for " + r)
                .isEqualTo(Ratio.fromPercentage(1));
        }
    });
}
 
Example 10
Source File: RecommendedLoanTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void constructor() {
    final LoanDescriptor ld = RecommendedLoanTest.mockLoanDescriptor();
    final int amount = 200;
    final RecommendedLoan r = new RecommendedLoan(ld, Money.from(amount));
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(r.descriptor())
            .isSameAs(ld);
        softly.assertThat(r.amount())
            .isEqualTo(Money.from(amount));
    });
}
 
Example 11
Source File: QuotaMonitorTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void emptyAtStart() {
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold75PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
}
 
Example 12
Source File: BuildResultAssert.java    From curiostack with MIT License 5 votes vote down vote up
/** Asserts that the {@code tasks} succeeded during the build. */
public BuildResultAssert tasksDidRun(Iterable<String> tasks) {
  SoftAssertions.assertSoftly(
      softly -> {
        for (var task : tasks) {
          BuildTask result = actual.task(task);
          softly.assertThat(result).as("Task %s did not run", task).isNotNull();
        }
      });
  return this;
}
 
Example 13
Source File: PurchaseResultTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void success() {
    final PurchaseResult result = PurchaseResult.success();
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(result.isSuccess())
            .isTrue();
        softly.assertThat(result.getFailureType())
            .isEmpty();
        softly.assertThat(result)
            .isSameAs(PurchaseResult.success());
    });
}
 
Example 14
Source File: AuditTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void getters() {
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(Audit.investing())
            .isNotNull();
        softly.assertThat(Audit.purchasing())
            .isNotNull();
        softly.assertThat(Audit.selling())
            .isNotNull();
        softly.assertThat(Audit.reservations())
            .isNotNull();
    });
}
 
Example 15
Source File: InvestmentImplTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void deserialize() throws Exception {
    try (Jsonb jsonb = JsonbBuilder.create()) {
        Investment investment = jsonb.fromJson(INVESTMENT_JSON, InvestmentImpl.class);
        SoftAssertions.assertSoftly(softly -> {
            softly.assertThat(investment.getId())
                .isEqualTo(12851390);
            softly.assertThat(investment.getLoanId())
                .isEqualTo(311149);
            softly.assertThat(investment.getLoanName())
                .isNotBlank();
            softly.assertThat(investment.getInvestmentDate())
                .isNotNull();
            softly.assertThat(investment.getAmount())
                .isEqualTo(Money.from(200));
            softly.assertThat(investment.getPurchasePrice())
                .isEqualTo(Money.from(143.7));
            softly.assertThat(investment.getRating())
                .isEqualTo(Rating.A);
            softly.assertThat(investment.getInterestRate())
                .isEqualTo(Rating.A.getInterestRate());
            softly.assertThat(investment.getRevenueRate())
                .hasValue(Rating.A.getMaximalRevenueRate());
            softly.assertThat(investment.getLoanHealthInfo())
                .hasValue(LoanHealth.HEALTHY);
            softly.assertThat(investment.getPaymentStatus())
                .hasValue(PaymentStatus.OK);
            softly.assertThat(investment.getInsuranceStatus())
                .isEqualTo(InsuranceStatus.NOT_INSURED);
            softly.assertThat(investment.getStatus())
                .isEqualTo(InvestmentStatus.ACTIVE);
            softly.assertThat(investment.getLegalDpd())
                .hasValue(0);
            softly.assertThat(investment.getCurrentTerm())
                .hasValue(54);
        });
    }
}
 
Example 16
Source File: RegexValidatorTest.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Test
void testRegexValidator() {
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThatCode(() -> RegexValidator.of("foo").assertValid("foo")).doesNotThrowAnyException();
        // checking for nullness is not the responsibility of the validator, but it must be null safe
        softly.assertThatCode(() -> RegexValidator.of("foo").assertValid(null)).doesNotThrowAnyException();
        softly.assertThatCode(() -> RegexValidator.of("foo").assertValid("bar"))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessage("Value \"bar\" does not match regex foo");
        softly.assertThatCode(() -> RegexValidator.of("foo", "{0} is not {1}").assertValid("bar"))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessage("bar is not foo");
    });
}
 
Example 17
Source File: InvestmentImplTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void deserializeDefaulted() throws Exception {
    try (Jsonb jsonb = JsonbBuilder.create()) {
        Investment investment = jsonb.fromJson(DEFAULTED_INVESTMENT_JSON, InvestmentImpl.class);
        SoftAssertions.assertSoftly(softly -> {
            softly.assertThat(investment.getId())
                .isEqualTo(414819);
            softly.assertThat(investment.getLoanId())
                .isEqualTo(42122);
            softly.assertThat(investment.getCurrentTerm())
                .isEmpty();
        });
    }
}
 
Example 18
Source File: RemoteDataTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void getters() {
    final Zonky zonky = harmlessZonky();
    final Tenant tenant = mockTenant(zonky);
    final RemoteData data = RemoteData.load(tenant);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(data.getStatistics())
            .isNotNull();
        softly.assertThat(data.getBlocked())
            .isEmpty();
        softly.assertThat(data.getRetrievedOn())
            .isBeforeOrEqualTo(OffsetDateTime.now());
    });
}
 
Example 19
Source File: InvestmentResultTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void equality() {
    final InvestmentResult result = InvestmentResult.success();
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(result)
            .isEqualTo(result);
        softly.assertThat(result)
            .isNotEqualTo(null);
        softly.assertThat(result)
            .isNotEqualTo(InvestmentResult.failure(mock(ClientErrorException.class)));
        softly.assertThat(result)
            .isNotEqualTo(PurchaseResult.success());
    });
}
 
Example 20
Source File: SupportedListenerTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@Test
void nullity() {
    SoftAssertions.assertSoftly(softly -> Stream.of(SupportedListener.values())
        .forEach(l -> {
            softly.assertThat(l.createSampleEvent())
                .isNotNull();
            softly.assertThat(l.getListener(new EmailHandler(null)))
                .isNotNull();
        }));
}