Search in sources :

Example 6 with SoftAssertions

use of org.assertj.core.api.SoftAssertions in project geode by apache.

the class DataCommandFunctionWithPDXJUnitTest method assertThatRowIsBuiltCorrectly.

private void assertThatRowIsBuiltCorrectly(GfJsonObject table, int rowNum, Customer customer) throws Exception {
    SoftAssertions softly = new SoftAssertions();
    String id = (String) table.getJSONArray("id").get(rowNum);
    String firstName = (String) table.getJSONArray("firstName").get(rowNum);
    String lastName = (String) table.getJSONArray("lastName").get(rowNum);
    softly.assertThat(id).describedAs("Customer ID").isEqualTo(customer.id);
    softly.assertThat(firstName).describedAs("First name").isEqualTo(customer.firstName);
    softly.assertThat(lastName).describedAs("Last name").isEqualTo(customer.lastName);
    GfJsonArray phoneArray = table.getJSONArray("phone");
    if (phoneArray == null) {
        softly.assertThat(customer).describedAs("No phone data").isNotInstanceOf(CustomerWithPhone.class);
    } else {
        String phone = (String) phoneArray.get(rowNum);
        if (customer instanceof CustomerWithPhone) {
            softly.assertThat(phone).describedAs("Phone").isEqualTo(((CustomerWithPhone) customer).phone);
        } else {
            softly.assertThat(phone).describedAs("Phone (missing)").isEqualTo(MISSING_VALUE);
        }
    }
    softly.assertAll();
}
Also used : GfJsonArray(org.apache.geode.management.internal.cli.json.GfJsonArray) SoftAssertions(org.assertj.core.api.SoftAssertions)

Example 7 with SoftAssertions

use of org.assertj.core.api.SoftAssertions in project metrics by dropwizard.

the class GraphiteSanitizeTest method sanitizeGraphiteValues.

@Test
public void sanitizeGraphiteValues() {
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(GraphiteSanitize.sanitize("Foo Bar")).isEqualTo("Foo-Bar");
    softly.assertThat(GraphiteSanitize.sanitize(" Foo Bar ")).isEqualTo("Foo-Bar");
    softly.assertThat(GraphiteSanitize.sanitize(" Foo Bar")).isEqualTo("Foo-Bar");
    softly.assertThat(GraphiteSanitize.sanitize("Foo Bar ")).isEqualTo("Foo-Bar");
    softly.assertThat(GraphiteSanitize.sanitize("  Foo Bar  ")).isEqualTo("Foo-Bar");
    softly.assertThat(GraphiteSanitize.sanitize("Foo@Bar")).isEqualTo("Foo@Bar");
    softly.assertThat(GraphiteSanitize.sanitize("Foó Bar")).isEqualTo("Foó-Bar");
    softly.assertThat(GraphiteSanitize.sanitize("||ó/.")).isEqualTo("||ó/.");
    softly.assertThat(GraphiteSanitize.sanitize("${Foo:Bar:baz}")).isEqualTo("${Foo:Bar:baz}");
    softly.assertThat(GraphiteSanitize.sanitize("St. Foo's of Bar")).isEqualTo("St.-Foo's-of-Bar");
    softly.assertThat(GraphiteSanitize.sanitize("(Foo and (Bar and (Baz)))")).isEqualTo("(Foo-and-(Bar-and-(Baz)))");
    softly.assertThat(GraphiteSanitize.sanitize("Foo.bar.baz")).isEqualTo("Foo.bar.baz");
    softly.assertThat(GraphiteSanitize.sanitize("FooBar")).isEqualTo("FooBar");
    softly.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Example 8 with SoftAssertions

use of org.assertj.core.api.SoftAssertions in project spring-data-jdbc by spring-projects.

the class IterableOfEntryToMapConverterUnitTests method testConversions.

@Test
public void testConversions() {
    Map<Object, Object> map = new HashMap<>();
    map.put("key", "value");
    List<Object[]> testValues = asList(// 
    new Object[] { emptySet(), emptyMap() }, // 
    new Object[] { emptyList(), emptyMap() }, // 
    new Object[] { "string", false }, // 
    new Object[] { asList(new SimpleEntry<>("key", "value")), map }, // 
    new Object[] { asList("string"), IllegalArgumentException.class });
    SoftAssertions softly = new SoftAssertions();
    testValues.forEach(array -> softly.assertThat(tryToConvert(array[0])).isEqualTo(array[1]));
    softly.assertAll();
}
Also used : HashMap(java.util.HashMap) SimpleEntry(java.util.AbstractMap.SimpleEntry) SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Example 9 with SoftAssertions

use of org.assertj.core.api.SoftAssertions in project spring-data-jdbc by spring-projects.

the class JdbcEntityTemplateIntegrationTests method saveAndDeleteAnEntityWithReferencedEntity.

// DATAJDBC-112
@Test
public void saveAndDeleteAnEntityWithReferencedEntity() {
    template.save(legoSet, LegoSet.class);
    template.delete(legoSet, LegoSet.class);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(template.findAll(LegoSet.class)).isEmpty();
    softly.assertThat(template.findAll(Manual.class)).isEmpty();
    softly.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Example 10 with SoftAssertions

use of org.assertj.core.api.SoftAssertions in project spring-data-jdbc by spring-projects.

the class JdbcEntityTemplateIntegrationTests method updateReferencedEntityToNull.

// DATAJDBC-112
@Test
public void updateReferencedEntityToNull() {
    template.save(legoSet, LegoSet.class);
    legoSet.setManual(null);
    template.save(legoSet, LegoSet.class);
    LegoSet reloadedLegoSet = template.findById(legoSet.getId(), LegoSet.class);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(reloadedLegoSet.manual).isNull();
    softly.assertThat(template.findAll(Manual.class)).describedAs("Manuals failed to delete").isEmpty();
    softly.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Aggregations

SoftAssertions (org.assertj.core.api.SoftAssertions)16 Test (org.junit.Test)15 FeedItem (gov.whitehouse.data.model.FeedItem)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 GfJsonArray (org.apache.geode.management.internal.cli.json.GfJsonArray)1 GfJsonObject (org.apache.geode.management.internal.cli.json.GfJsonObject)1 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)1 EventFactHandle (org.drools.core.common.EventFactHandle)1 KieSession (org.kie.api.runtime.KieSession)1 FactHandle (org.kie.api.runtime.rule.FactHandle)1 KieHelper (org.kie.internal.utils.KieHelper)1