use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_pass_when_selected_fields_and_nested_fields_accessed_with_getters_are_equal.
@Test
public void should_pass_when_selected_fields_and_nested_fields_accessed_with_getters_are_equal() {
Player rose = new Player(new Name("Derrick", "Rose"), "Chicago Bulls");
Player jalen = new Player(new Name("Derrick", "Coleman"), "Chicago Bulls");
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), rose, jalen, noFieldComparators(), defaultTypeComparators(), "team", "name.first");
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class SoftAssertionsTest method setup.
@Before
public void setup() {
softly = new SoftAssertions();
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;
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class AtomicReferenceArrayAssert_extractingResultOf_Test method should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable.
@Test
public void should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable() {
// extract method result
assertThat(jedis).extractingResultOf("age").containsOnly(800, 50);
// extract if method result is primitive
assertThat(jedis).extractingResultOf("darkSide").containsOnly(false, true);
// extract if method result is also a property
assertThat(jedis).extractingResultOf("name").containsOnly(new Name("Yoda"), new Name("Darth Vader"));
// extract toString method result
assertThat(jedis).extractingResultOf("toString").containsOnly("Yoda", "Darth Vader");
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class AtomicReferenceArrayAssert_extracting_Test method should_allow_assertions_on_field_values_extracted_from_given_iterable.
@Test
public void should_allow_assertions_on_field_values_extracted_from_given_iterable() {
// basic types
assertThat(employees).extracting("id").containsOnly(1L, 2L);
// object
assertThat(employees).extracting("name").containsOnly(new Name("Yoda"), new Name("Luke", "Skywalker"));
// nested property
assertThat(employees).extracting("name.first").containsOnly("Yoda", "Luke");
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class AtomicReferenceArrayAssert_extracting_Test method setUpOnce.
@BeforeClass
public static void setUpOnce() {
yoda = new Employee(1L, new Name("Yoda"), 800);
luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
employees = new AtomicReferenceArray<>(array(yoda, luke));
}
Aggregations