Search in sources :

Example 1 with CartoonCharacter

use of org.assertj.core.test.CartoonCharacter in project assertj-core by joel-costigliola.

the class IterableAssert_flatExtracting_Test method should_rethrow_throwing_extractor_checked_exception_as_a_runtime_exception.

@Test
public void should_rethrow_throwing_extractor_checked_exception_as_a_runtime_exception() {
    List<CartoonCharacter> childCharacters = newArrayList(bart, lisa, maggie);
    thrown.expect(RuntimeException.class, "java.lang.Exception: no children");
    assertThat(childCharacters).flatExtracting(cartoonCharacter -> {
        if (cartoonCharacter.getChildren().isEmpty())
            throw new Exception("no children");
        return cartoonCharacter.getChildren();
    });
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) ExpectedException(org.assertj.core.test.ExpectedException) Test(org.junit.Test)

Example 2 with CartoonCharacter

use of org.assertj.core.test.CartoonCharacter in project assertj-core by joel-costigliola.

the class IterableAssert_flatExtracting_with_String_parameter_Test method setUp.

@Before
public void setUp() {
    bart = new CartoonCharacter("Bart Simpson");
    lisa = new CartoonCharacter("Lisa Simpson");
    maggie = new CartoonCharacter("Maggie Simpson");
    homer = new CartoonCharacter("Homer Simpson");
    homer.addChildren(bart, lisa, maggie);
    pebbles = new CartoonCharacter("Pebbles Flintstone");
    fred = new CartoonCharacter("Fred Flintstone");
    fred.addChildren(pebbles);
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Before(org.junit.Before)

Example 3 with CartoonCharacter

use of org.assertj.core.test.CartoonCharacter in project assertj-core by joel-costigliola.

the class ObjectArrayAssert_flatExtracting_with_String_parameter_Test method setUp.

@Before
public void setUp() {
    bart = new CartoonCharacter("Bart Simpson");
    lisa = new CartoonCharacter("Lisa Simpson");
    maggie = new CartoonCharacter("Maggie Simpson");
    homer = new CartoonCharacter("Homer Simpson");
    homer.addChildren(bart, lisa, maggie);
    pebbles = new CartoonCharacter("Pebbles Flintstone");
    fred = new CartoonCharacter("Fred Flintstone");
    fred.addChildren(pebbles);
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Before(org.junit.Before)

Example 4 with CartoonCharacter

use of org.assertj.core.test.CartoonCharacter in project assertj-core by joel-costigliola.

the class AtomicReferenceArrayAssert_flatExtracting_Test method should_allow_assertions_on_joined_lists_when_extracting_children_with_anonymous_class_throwing_extractor.

@Test
public void should_allow_assertions_on_joined_lists_when_extracting_children_with_anonymous_class_throwing_extractor() {
    AtomicReferenceArray<CartoonCharacter> cartoonCharacters = new AtomicReferenceArray<>(array(homer, fred));
    assertThat(cartoonCharacters).flatExtracting(new ThrowingExtractor<CartoonCharacter, List<CartoonCharacter>, Exception>() {

        @Override
        public List<CartoonCharacter> extractThrows(CartoonCharacter cartoonCharacter) throws Exception {
            if (cartoonCharacter.getChildren().isEmpty())
                throw new Exception("no children");
            return cartoonCharacter.getChildren();
        }
    }).containsOnly(bart, lisa, maggie, pebbles);
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) AtomicReferenceArray(java.util.concurrent.atomic.AtomicReferenceArray) ThrowingExtractor(org.assertj.core.api.iterable.ThrowingExtractor) ExpectedException(org.assertj.core.test.ExpectedException) Test(org.junit.Test)

Example 5 with CartoonCharacter

use of org.assertj.core.test.CartoonCharacter in project assertj-core by joel-costigliola.

the class AtomicReferenceArrayAssert_flatExtracting_with_String_parameter_Test method setUp.

@Before
public void setUp() {
    bart = new CartoonCharacter("Bart Simpson");
    lisa = new CartoonCharacter("Lisa Simpson");
    maggie = new CartoonCharacter("Maggie Simpson");
    homer = new CartoonCharacter("Homer Simpson");
    homer.addChildren(bart, lisa, maggie);
    pebbles = new CartoonCharacter("Pebbles Flintstone");
    fred = new CartoonCharacter("Fred Flintstone");
    fred.addChildren(pebbles);
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Before(org.junit.Before)

Aggregations

CartoonCharacter (org.assertj.core.test.CartoonCharacter)20 Before (org.junit.Before)10 Test (org.junit.Test)9 ExpectedException (org.assertj.core.test.ExpectedException)6 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)3 Person (org.assertj.core.test.Person)3 AtomicReferenceArray (java.util.concurrent.atomic.AtomicReferenceArray)2 ThrowingExtractor (org.assertj.core.api.iterable.ThrowingExtractor)2 Name (org.assertj.core.test.Name)2 SoftAssertions (org.assertj.core.api.SoftAssertions)1 TolkienCharacter (org.assertj.core.data.TolkienCharacter)1 Jedi (org.assertj.core.test.Jedi)1