Search in sources :

Example 51 with Jedi

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

the class ObjectAssert_hasFieldOrProperty_Test method should_fail_if_field_or_property_does_not_exists.

@Test
public void should_fail_if_field_or_property_does_not_exists() {
    thrown.expectAssertionError("%nExpecting%n  <Yoda the Jedi>%nto have a property or a field named <\"not_exists_in_jedi_object\">");
    Jedi jedi = new Jedi("Yoda", "Blue");
    assertThat(jedi).hasFieldOrProperty("not_exists_in_jedi_object");
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 52 with Jedi

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

the class ObjectAssert_hasNoNullFieldsOrProperties_Test method should_fail_if_a_public_field_is_null.

@Test
public void should_fail_if_a_public_field_is_null() {
    Jedi jedi = new Jedi("Yoda", null);
    thrown.expectAssertionError("%n" + "Expecting%n" + "  <Yoda the Jedi>%n" + "not to have any null property or field, but <\"lightSaberColor\"> was null.%n" + "Check was performed on all fields/properties except: <[\"name\", \"strangeNotReadablePrivateField\"]>");
    assertThat(jedi).hasNoNullFieldsOrPropertiesExcept("name", "strangeNotReadablePrivateField");
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 53 with Jedi

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

the class ObjectAssert_hasNoNullFieldsOrProperties_Test method should_pass_if_all_fields_or_properties_but_the_ignored_ones_are_set.

@Test
public void should_pass_if_all_fields_or_properties_but_the_ignored_ones_are_set() {
    Jedi jedi = new Jedi("Yoda", null);
    assertThat(jedi).hasNoNullFieldsOrPropertiesExcept("lightSaberColor", "strangeNotReadablePrivateField");
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 54 with Jedi

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

the class ObjectAssert_hasNoNullFieldsOrProperties_Test method should_fail_if_a_private_field_is_null.

@Test
public void should_fail_if_a_private_field_is_null() {
    Jedi jedi = new Jedi("Yoda", "Blue");
    thrown.expectAssertionError("%n" + "Expecting%n" + "  <Yoda the Jedi>%n" + "not to have any null property or field, but <\"strangeNotReadablePrivateField\"> was null.%n" + "Check was performed on all fields/properties");
    assertThat(jedi).hasNoNullFieldsOrProperties();
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 55 with Jedi

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

the class ObjectAssert_isEqualToComparingOnlyGivenFields_Test method should_be_able_to_use_a_comparator_for_specified_type.

@Test
public void should_be_able_to_use_a_comparator_for_specified_type() {
    Jedi actual = new Jedi("Yoda", "green");
    Jedi other = new Jedi("Luke", "blue");
    assertThat(actual).usingComparatorForType(ALWAY_EQUALS_STRING, String.class).isEqualToComparingOnlyGivenFields(other, "name");
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Aggregations

Jedi (org.assertj.core.test.Jedi)108 Test (org.junit.Test)104 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)30 ObjectAssertBaseTest (org.assertj.core.api.ObjectAssertBaseTest)26 Comparator (java.util.Comparator)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 ALWAY_EQUALS_STRING (org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING)13 Before (org.junit.Before)13 AssertionInfo (org.assertj.core.api.AssertionInfo)10 AtomicReferenceArrayAssertBaseTest (org.assertj.core.api.AtomicReferenceArrayAssertBaseTest)9 IterableAssertBaseTest (org.assertj.core.api.IterableAssertBaseTest)9 ObjectArrayAssertBaseTest (org.assertj.core.api.ObjectArrayAssertBaseTest)9 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)9 Lists.newArrayList (org.assertj.core.util.Lists.newArrayList)7 TextDescription (org.assertj.core.description.TextDescription)6 ExtendedByTypesComparator (org.assertj.core.internal.ExtendedByTypesComparator)6 ObjectArrays (org.assertj.core.internal.ObjectArrays)6 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)6 List (java.util.List)5 TypeComparators.defaultTypeComparators (org.assertj.core.internal.TypeComparators.defaultTypeComparators)5