Search in sources :

Example 16 with Jedi

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

the class ObjectAssert_hasFieldOrPropertyWithValue_Test method should_pass_if_both_are_null.

@Test
public void should_pass_if_both_are_null() {
    Jedi jedi = new Jedi(null, "Blue");
    assertThat(jedi).hasFieldOrPropertyWithValue(FIELD_NAME, null);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 17 with Jedi

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

the class ObjectAssert_hasFieldOrPropertyWithValue_Test method should_fail_if_field_or_property_value_is_not_equal_to_the_expected_value.

@Test
public void should_fail_if_field_or_property_value_is_not_equal_to_the_expected_value() {
    thrown.expectAssertionError("%nExpecting%n  <Yoda the Jedi>%nto have a property or a field named <\"name\"> with value%n  <1000>%nbut value was:%n  <\"Yoda\">");
    Jedi jedi = new Jedi("Yoda", "Blue");
    assertThat(jedi).hasFieldOrPropertyWithValue(FIELD_NAME, 1000);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 18 with Jedi

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

the class ObjectAssert_hasFieldOrPropertyWithValue_Test method should_fail_if_given_field_or_property_does_not_exist.

@Test
public void should_fail_if_given_field_or_property_does_not_exist() {
    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).hasFieldOrPropertyWithValue("not_exists_in_jedi_object", FIELD_VALUE);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 19 with Jedi

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

the class ObjectAssert_hasFieldOrPropertyWithValue_Test method should_fail_if_given_field_or_property_name_is_null.

@Test
public void should_fail_if_given_field_or_property_name_is_null() {
    thrown.expectIllegalArgumentException("The name of the property/field to read should not be null");
    Jedi jedi = new Jedi("Yoda", "Blue");
    assertThat(jedi).hasFieldOrPropertyWithValue(null, FIELD_VALUE);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 20 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_fields.

@Test
public void should_be_able_to_use_a_comparator_for_specified_fields() {
    Jedi actual = new Jedi("Yoda", "Green");
    Jedi other = new Jedi("Luke", "Blue");
    assertThat(actual).usingComparatorForFields(ALWAY_EQUALS_STRING, "name").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