Java Code Examples for org.assertj.core.api.SoftAssertions

The following examples show how to use org.assertj.core.api.SoftAssertions. These examples are extracted from open source projects. 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 Project: quickperf   Source File: JvmOptionConverterTest.java    License: Apache License 2.0 7 votes vote down vote up
@Test public void
should_return_jvm_option_objects_from_jvm_options_as_a_string() {

    // GIVEN
    JvmOptions jvmOptionsAsAnnotation = mock(JvmOptions.class);
    when(jvmOptionsAsAnnotation.value()).thenReturn(" -XX:+UseCompressedOops   -XX:+UseCompressedClassPointers  ");

    // WHEN
    List<JvmOption> jvmOptions = jvmOptionConverter.jvmOptionFrom(jvmOptionsAsAnnotation);

    // THEN
    SoftAssertions softAssertions = new SoftAssertions();
    softAssertions.assertThat(jvmOptions).hasSize(2);

    JvmOption firstJvmOption = jvmOptions.get(0);
    softAssertions.assertThat(firstJvmOption.asString())
                  .isEqualTo("-XX:+UseCompressedOops");

    JvmOption secondJvmOption = jvmOptions.get(1);
    softAssertions.assertThat(secondJvmOption.asString())
                  .isEqualTo("-XX:+UseCompressedClassPointers");

    softAssertions.assertAll();

}
 
Example 2
Source Project: quickperf   Source File: AbstractJUnit4SpringTestBase.java    License: Apache License 2.0 6 votes vote down vote up
@Test public void
two_tests_having_performance_and_functional_issues() {

    // GIVEN
    Class<?> testClass = aClassWithTwoMethodsHavingFunctionnalAndPerfIssues();

    // WHEN
    PrintableResult printableResult = testResult(testClass);

    // THEN
    SoftAssertions softAssertions = new SoftAssertions();
    softAssertions.assertThat(printableResult.failureCount()).isEqualTo(2);

    softAssertions.assertThat(printableResult.toString())
                  .contains("java.lang.AssertionError: Performance and functional properties not respected")
                  .contains("Failing assertion of first test!")
                  .contains("Failing assertion of second test!");

    softAssertions.assertAll();

}
 
Example 3
Source Project: rabbitmq-mock   Source File: MockConnectionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void connectionParams_are_default_ones() {
    Connection connection = new MockConnectionFactory().newConnection();

    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(connection.getAddress().getHostAddress()).isEqualTo("127.0.0.1");
    softly.assertThat(connection.getPort()).isEqualTo(ConnectionFactory.DEFAULT_AMQP_PORT);
    softly.assertThat(connection.getChannelMax()).isEqualTo(0);
    softly.assertThat(connection.getFrameMax()).isEqualTo(0);
    softly.assertThat(connection.getHeartbeat()).isEqualTo(0);
    softly.assertThat(connection.getClientProperties()).isEqualTo(AMQConnection.defaultClientProperties());
    softly.assertThat(connection.getClientProvidedName()).isNull();
    softly.assertThat(connection.getServerProperties().get("version"))
        .isEqualTo(LongStringHelper.asLongString(new Version(AMQP.PROTOCOL.MAJOR, AMQP.PROTOCOL.MINOR).toString()));
    softly.assertThat(connection.getExceptionHandler()).isExactlyInstanceOf(DefaultExceptionHandler.class);
    softly.assertAll();
}
 
Example 4
Source Project: banking-swift-messages-java   Source File: UserHeaderBlockTest.java    License: MIT License 6 votes vote down vote up
@Test
public void of_WHEN_valid_block_is_passed_RETURN_new_block() throws Exception {

    // Given
    GeneralBlock generalBlock = new GeneralBlock(UserHeaderBlock.BLOCK_ID_3, "{113:SEPA}{108:ILOVESEPA}");

    // When
    UserHeaderBlock block = UserHeaderBlock.of(generalBlock);

    // Then
    assertThat(block).isNotNull();
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(block.getBankingPriorityCode()).contains("SEPA");
    softly.assertThat(block.getMessageUserReference()).contains("ILOVESEPA");
    softly.assertAll();
}
 
Example 5
@Test
@Parameters(method = "getPosServices")
public void testPosConformity(LappsGridService aService) throws Exception
{
    CAS cas = loadData();
    
    predict(aService.getUrl(), cas);

    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(JCasUtil.select(cas.getJCas(), Token.class))
            .as("Prediction should contain Tokens")
            .isNotEmpty();
    softly.assertThat(JCasUtil.select(cas.getJCas(), POS.class))
            .as("Prediction should contain POS tags")
            .isNotEmpty();

    softly.assertAll();
}
 
Example 6
Source Project: banking-swift-messages-java   Source File: BasicHeaderBlockTest.java    License: MIT License 6 votes vote down vote up
@Test
public void of_WHEN_valid_block_is_passed_RETURN_new_block() throws Exception {

    // Given
    GeneralBlock generalBlock = new GeneralBlock(BasicHeaderBlock.BLOCK_ID_1, "F01YOURCODEZABC2222777777");

    // When
    BasicHeaderBlock block = BasicHeaderBlock.of(generalBlock);

    // Then
    assertThat(block).isNotNull();
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(block.getApplicationId()).isEqualTo("F");
    softly.assertThat(block.getServiceId()).isEqualTo("01");
    softly.assertThat(block.getLogicalTerminalAddress()).isEqualTo("YOURCODEZABC");
    softly.assertThat(block.getSessionNumber()).isEqualTo("2222");
    softly.assertThat(block.getSequenceNumber()).isEqualTo("777777");
    softly.assertAll();
}
 
Example 7
/**
 * SoftAssertions are used to group assertions with different assertion bases and force all of them to run even if a previous assertion failed.
 */
@Test
void softAssertion() {
    SoftAssertions.assertSoftly(soft -> {
        // Base dummyFruits
        soft.assertThat(dummyFruits)
                .hasSize(3)
                .containsExactly(babyBanana, grannySmithApple, grapefruit);
        // Base otherDummyFruitList
        soft.assertThat(otherDummyFruitList)
                .hasSize(4)
                .containsAll(dummyFruits)
                .containsExactly(babyBanana, grannySmithApple, grapefruit, redBanana);
        // Base
        soft.assertThat(grapefruit).extracting(DummyFruit::getType).allMatch(DummyFruit.TYPE.ORANGE::equals);
    });
}
 
Example 8
Source Project: jig   Source File: GradleProjectTest.java    License: Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("fixtures")
public void 依存関係にあるすべてのJavaPluginが適用されたプロジェクトのクラスパスとソースパスが取得できること(
        String name,
        String[] classPathSuffixes,
        String[] sourcePathSuffixes) throws Exception {

    Method projectMethod = GradleProjectTest.class.getDeclaredMethod("_" + name, Path.class);
    projectMethod.setAccessible(true);
    Project project = (Project) projectMethod.invoke(null, tempDir);

    SourcePaths sourcePaths = new GradleProject(project).rawSourceLocations();

    List<Path> binarySourcePaths = sourcePaths.binarySourcePaths();
    List<Path> textSourcePaths = sourcePaths.textSourcePaths();

    Fixture fixture = new Fixture(classPathSuffixes, sourcePathSuffixes);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(fixture.classPathContains(new HashSet<>(binarySourcePaths))).isTrue();
    softly.assertThat(fixture.sourcePathContains(new HashSet<>(textSourcePaths))).isTrue();
    softly.assertAll();
}
 
Example 9
Source Project: banking-swift-messages-java   Source File: UserTrailerBlockTest.java    License: MIT License 6 votes vote down vote up
@Test
public void of_WHEN_valid_block_is_passed_RETURN_new_block() throws Exception {

    // Given
    GeneralBlock generalBlock = new GeneralBlock(UserTrailerBlock.BLOCK_ID_5, "{CHK:F7C4F89AF66D}{TNG:}");

    // When
    UserTrailerBlock block = UserTrailerBlock.of(generalBlock);

    // Then
    assertThat(block).isNotNull();
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(block.getChecksum()).contains("F7C4F89AF66D");
    softly.assertThat(block.getTraining()).contains("");
    softly.assertAll();
}
 
Example 10
Source Project: prebid-server-java   Source File: MetricsTest.java    License: Apache License 2.0 6 votes vote down vote up
private void verifyCreatesConfiguredCounterType(Consumer<Metrics> metricsConsumer) {
    final EnumMap<CounterType, Class<? extends Metric>> counterTypeClasses = new EnumMap<>(CounterType.class);
    counterTypeClasses.put(CounterType.counter, Counter.class);
    counterTypeClasses.put(CounterType.flushingCounter, ResettingCounter.class);
    counterTypeClasses.put(CounterType.meter, Meter.class);

    final SoftAssertions softly = new SoftAssertions();

    for (CounterType counterType : CounterType.values()) {
        // given
        metricRegistry = new MetricRegistry();

        // when
        metricsConsumer.accept(new Metrics(metricRegistry, CounterType.valueOf(counterType.name()),
                accountMetricsVerbosity, bidderCatalog));

        // then
        softly.assertThat(metricRegistry.getMetrics()).hasValueSatisfying(new Condition<>(
                metric -> metric.getClass() == counterTypeClasses.get(counterType),
                null));
    }

    softly.assertAll();
}
 
Example 11
@Test
public void shouldGenerateAtlasmapSchemaSetForUpdatePetRequest() throws IOException {
    final Oas20Operation openApiOperation = OasModelHelper.getOperationMap(openApiDoc.paths.getPathItem(path), Oas20Operation.class).get(operation);

    final DataShape shape = generator.createShapeFromRequest(json, openApiDoc, openApiOperation);

    final SoftAssertions softly = new SoftAssertions();
    softly.assertThat(shape.getKind()).isEqualTo(DataShapeKinds.XML_SCHEMA);
    softly.assertThat(shape.getName()).isEqualTo("Request");
    softly.assertThat(shape.getDescription()).isEqualTo("API request payload");
    softly.assertThat(shape.getExemplar()).isNotPresent();
    softly.assertAll();

    final String expectedSpecification;
    try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/openapi/v2/" + schemaset)) {
        expectedSpecification = IOUtils.toString(in, StandardCharsets.UTF_8);
    }

    final String specification = shape.getSpecification();

    assertThat(specification).isXmlEqualTo(expectedSpecification);
}
 
Example 12
@Test
public void shouldGenerateAtlasmapSchemaSetForUpdatePetRequest() throws IOException {
    final Oas30Operation openApiOperation = OasModelHelper.getOperationMap(openApiDoc.paths.getPathItem(path), Oas30Operation.class).get(operation);

    final DataShape shape = generator.createShapeFromRequest(json, openApiDoc, openApiOperation);

    final SoftAssertions softly = new SoftAssertions();
    softly.assertThat(shape.getKind()).isEqualTo(DataShapeKinds.XML_SCHEMA);
    softly.assertThat(shape.getName()).isEqualTo("Request");
    softly.assertThat(shape.getDescription()).isEqualTo("API request payload");
    softly.assertThat(shape.getExemplar()).isNotPresent();
    softly.assertAll();

    final String expectedSpecification;
    try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/openapi/v3/" + schemaset)) {
        expectedSpecification = IOUtils.toString(in, StandardCharsets.UTF_8);
    }

    final String specification = shape.getSpecification();

    assertThat(specification).isXmlEqualTo(expectedSpecification);
}
 
Example 13
@Test
public void of_WHEN_valid_input_block_is_passed_RETURN_new_block() throws Exception {

    // Given
    GeneralBlock generalBlock = new GeneralBlock(ApplicationHeaderBlock.BLOCK_ID_2, "I101YOURBANKXJKLU3003");

    // When
    ApplicationHeaderBlock block = ApplicationHeaderBlock.of(generalBlock);

    // Then
    assertThat(block).isNotNull();
    assertThat(block.getInput()).isPresent();
    if (block.getInput().isPresent()) {
        SoftAssertions softly = new SoftAssertions();
        ApplicationHeaderInputBlock inputBlock = block.getInput().get();
        softly.assertThat(inputBlock.getMessageType()).isEqualTo("101");
        softly.assertThat(inputBlock.getReceiverAddress()).isEqualTo("YOURBANKXJKL");
        softly.assertThat(inputBlock.getMessagePriority()).isEqualTo(MessagePriority.URGENT);
        softly.assertThat(inputBlock.getDeliveryMonitoring()).contains("3");
        softly.assertThat(inputBlock.getObsolescencePeriod()).contains("003");
        softly.assertAll();
    }

    assertThat(block.getOutput()).isNotPresent();
}
 
Example 14
Source Project: robozonky   Source File: RatingTest.java    License: 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 15
Source Project: robozonky   Source File: RatingTest.java    License: 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 16
Source Project: robozonky   Source File: Tuple1Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void equals() {
    Tuple1 tuple = Tuple.of(1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(null);
        softly.assertThat(tuple)
            .isNotEqualTo("");
    });
    Tuple1 tuple2 = Tuple.of(1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isNotSameAs(tuple2);
        softly.assertThat(tuple)
            .isEqualTo(tuple2);
    });
    Tuple1 tuple3 = Tuple.of(2);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple3)
            .isNotEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(tuple3);
    });
}
 
Example 17
Source Project: robozonky   Source File: Tuple2Test.java    License: 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 18
Source Project: robozonky   Source File: Tuple3Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void equals() {
    Tuple3 tuple = Tuple.of(1, 1, 1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(null);
        softly.assertThat(tuple)
            .isNotEqualTo("");
    });
    Tuple3 tuple2 = Tuple.of(1, 1, 1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple)
            .isNotSameAs(tuple2);
        softly.assertThat(tuple)
            .isEqualTo(tuple2);
    });
    Tuple3 tuple3 = Tuple.of(1, 2, 3);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(tuple3)
            .isNotEqualTo(tuple);
        softly.assertThat(tuple)
            .isNotEqualTo(tuple3);
    });
}
 
Example 19
@Test
public void of_WHEN_valid_block_is_passed_RETURN_new_block() throws Exception {

    // Given
    GeneralBlock generalBlock = new GeneralBlock(SystemTrailerBlock.BLOCK_ID_S, "{CHK:F7C4F89AF66D}{TNG:}{SAC:}{COP:P}");

    // When
    SystemTrailerBlock block = SystemTrailerBlock.of(generalBlock);

    // Then
    assertThat(block).isNotNull();
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(block.getChecksum()).contains("F7C4F89AF66D");
    softly.assertThat(block.getTraining()).contains("");
    softly.assertThat(block.getAdditionalSubblocks("COP").getContent()).isEqualTo("P");
    softly.assertAll();
}
 
Example 20
Source Project: robozonky   Source File: QuotaMonitorTest.java    License: 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 21
Source Project: robozonky   Source File: QuotaMonitorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void reaches75() {
    add(2250);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
    add(-1);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(monitor.threshold50PercentReached())
            .isTrue();
        softly.assertThat(monitor.threshold75PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold90PercentReached())
            .isFalse();
        softly.assertThat(monitor.threshold99PercentReached())
            .isFalse();
    });
}
 
Example 22
Source Project: robozonky   Source File: QuotaMonitorTest.java    License: 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 23
Source Project: robozonky   Source File: QuotaMonitorTest.java    License: 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 24
Source Project: robozonky   Source File: DefaultInvestmentShareTest.java    License: 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 25
Source Project: apm-agent-java   Source File: RegexValidatorTest.java    License: 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 26
Source Project: doov   Source File: SampleModelCollectorTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void should_collect_all_values_when_collect(FieldModel target, FieldModel source) {
    SoftAssertions softly = new SoftAssertions();
    SampleFieldInfo.stream().forEach(info -> {
        Object after = target.get(info.id());
        Object before = source.get(info.id());
        softly.assertThat(after).describedAs(info.id().code()).isEqualTo(before);
    });
    softly.assertAll();
}
 
Example 27
Source Project: doov   Source File: SampleFieldIdInfoTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void should_have_field_info() {
    SoftAssertions softAssertions = new SoftAssertions();

    Arrays.stream(SampleFieldId.values()).forEach(id -> {
        softAssertions.assertThat(fieldInfo(id)).isPresent();
        softAssertions.assertThat(fieldInfo(id))
                .isNotEmpty()
                .hasValueSatisfying(info -> assertThat(info.type()).isNotNull());
    });

    softAssertions.assertAll();
}
 
Example 28
Source Project: doov   Source File: SampleModelSerializationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void should_write_fields_to_csv_and_parse_back() {
    ByteArrayOutputStream csvResult = new ByteArrayOutputStream();
    Writer outputWriter = new OutputStreamWriter(csvResult);
    CsvWriter csvWriter = new CsvWriter(outputWriter, new CsvWriterSettings());
    wrapper.getFieldInfos().stream()
                    .filter(f -> !f.isTransient())
                    .forEach(f -> {
                        FieldId fieldId = f.id();
                        csvWriter.writeRow(fieldId.code(), wrapper.getAsString(fieldId));
                    });
    csvWriter.close();
    System.out.println(csvResult.toString());

    SampleModelWrapper copy = new SampleModelWrapper();

    ByteArrayInputStream csvInput = new ByteArrayInputStream(csvResult.toByteArray());
    CsvParser csvParser = new CsvParser(new CsvParserSettings());
    csvParser.parseAll(csvInput).forEach(record -> {
        FieldInfo fieldInfo = fieldInfoByName(record[0], wrapper);
        copy.setAsString(fieldInfo, record[1]);
    });

    SoftAssertions softly = new SoftAssertions();
    wrapper.getFieldInfos().stream()
                    .filter(f -> !f.isTransient())
                    .forEach(f -> {
                        Object value = copy.get(f.id());
                        softly.assertThat(value).isEqualTo(wrapper.get(f.id()));
                    });
    softly.assertAll();
}
 
Example 29
Source Project: doov   Source File: SampleModelCollectorTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void should_collect_all_values_when_collect(FieldModel target, FieldModel source) {
    SoftAssertions softly = new SoftAssertions();
    SampleFieldInfo.stream().forEach(info -> {
        Object after = target.get(info.id());
        Object before = source.get(info.id());
        softly.assertThat(after).describedAs(info.id().code()).isEqualTo(before);
    });
    softly.assertAll();
}
 
Example 30
Source Project: jig   Source File: IntegrationTest.java    License: Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@EnumSource(GradleVersions.class)
void スタブプロジェクトへの適用でパッケージ図と機能一覧が出力されること(GradleVersions version) throws IOException, URISyntaxException {
    BuildResult result = runner.executeGradleTasks(version, "clean", "compileJava", ":sub-project:jigReports", "--stacktrace");

    System.out.println(result.getOutput());
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(result.getOutput()).contains("BUILD SUCCESSFUL");
    softly.assertThat(outputDir.resolve("package-relation-depth4.svg")).exists();
    softly.assertThat(outputDir.resolve("application.xlsx")).exists();
    softly.assertAll();
}