Search in sources :

Example 11 with CartoonCharacter

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

the class AtomicReferenceArrayAssert_flatExtracting_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 12 with CartoonCharacter

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

the class AtomicReferenceArrayAssert_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() {
    AtomicReferenceArray<CartoonCharacter> childCharacters = new AtomicReferenceArray<>(array(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) AtomicReferenceArray(java.util.concurrent.atomic.AtomicReferenceArray) ExpectedException(org.assertj.core.test.ExpectedException) Test(org.junit.Test)

Example 13 with CartoonCharacter

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

the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_fields_are_equal_even_if_objects_types_differ.

@Test
public void should_pass_when_fields_are_equal_even_if_objects_types_differ() {
    CartoonCharacter actual = new CartoonCharacter("Homer Simpson");
    Person other = new Person("Homer Simpson");
    objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "children");
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 14 with CartoonCharacter

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

the class Objects_assertIsEqualToIgnoringNullFields_Test method should_pass_when_fields_are_equal_even_if_objects_types_differ.

@Test
public void should_pass_when_fields_are_equal_even_if_objects_types_differ() {
    Person actual = new Person("Homer Simpson");
    CartoonCharacter other = new CartoonCharacter("Homer Simpson");
    objects.assertIsEqualToIgnoringNullFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators());
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 15 with CartoonCharacter

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

the class BDDSoftAssertionsTest method setup.

@Before
public void setup() {
    softly = new BDDSoftAssertions();
    bart = new CartoonCharacter("Bart Simpson");
    lisa = new CartoonCharacter("Lisa Simpson");
    maggie = new CartoonCharacter("Maggie Simpson");
    homer = new CartoonCharacter("Homer Simpson");
    homer.getChildren().add(bart);
    homer.getChildren().add(lisa);
    homer.getChildren().add(maggie);
    CartoonCharacter pebbles = new CartoonCharacter("Pebbles Flintstone");
    fred = new CartoonCharacter("Fred Flintstone");
    fred.getChildren().add(pebbles);
    List<String> names = asList("Dave", "Jeff");
    LinkedHashSet<String> jobs = newLinkedHashSet("Plumber", "Builder");
    Iterable<String> cities = asList("Dover", "Boston", "Paris");
    int[] ranks = { 1, 2, 3 };
    iterableMap = new LinkedHashMap<>();
    iterableMap.put("name", names);
    iterableMap.put("job", jobs);
    iterableMap.put("city", cities);
    iterableMap.put("rank", ranks);
    throwingFirstNameExtractor = Name::getFirst;
    throwingLastNameExtractor = Name::getLast;
    firstNameFunction = Name::getFirst;
    lastNameFunction = Name::getLast;
    firstNameExtractor = Name::getFirst;
    lastNameExtractor = Name::getLast;
    childrenExtractor = CartoonCharacter::getChildren;
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Name(org.assertj.core.test.Name) 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