### Question:
ExtrasHandler { List<Person> getPersonsFromExtras(RelationshipStatus relStatus, Sex sex, AgeRange ageRange, int count) { return getPersonsFromExtras(relStatus == null ? null : Collections.singletonList(relStatus), sex == null ? null : Collections.singletonList(sex), ageRange == null ? null : Collections.singletonList(ageRange), count); } ExtrasHandler(List<IndRecord> indRecords, Random random);   }### Answer:
@Test public void testGetPersonsFromExtras() throws NoSuchFieldException, IllegalAccessException { int startExtrasCount = extrasHandler.remainingExtras(); List<Person> pl = extrasHandler.getPersonsFromExtras(RelationshipStatus.LONE_PARENT, Sex.Female, AgeRange.A40_54, 1); Assert.assertTrue("Person taken from extras - count", startExtrasCount - 1 == extrasHandler.remainingExtras()); Assert.assertEquals("Person taken from extras - age", pl.get(0).getAgeRange(), AgeRange.A40_54); Assert.assertEquals("Person taken from extras - sex", pl.get(0).getSex(), Sex.Female); Assert.assertEquals("Person taken from extras - relationship status", pl.get(0).getRelationshipStatus(), RelationshipStatus.LONE_PARENT); Person p = new Person(); p.setRelationshipStatus(RelationshipStatus.RELATIVE); p.setAgeRange(AgeRange.A25_39); p.setSex(Sex.Male); extrasHandler.addToExtras(new ArrayList<>(Collections.singleton(p))); pl = extrasHandler.getPersonsFromExtras(RelationshipStatus.RELATIVE, Sex.Male, AgeRange.A25_39, 1); Field field = ExtrasHandler.class.getDeclaredField("extras"); field.setAccessible(true); List<Person> extras = (List<Person>) field.get(extrasHandler); Assert.assertTrue("All persons in extras have no sex", extras.stream().filter(e -> e.getSex() == null).count() == extrasHandler.remainingExtras()); Assert.assertTrue("All persons in extras have no age range", extras.stream().filter(e -> e.getAgeRange() == null).count() == extrasHandler.remainingExtras()); Assert.assertTrue("All persons in extras have no relationship status", extras.stream().filter(e -> e.getRelationshipStatus() == null).count() == extrasHandler.remainingExtras()); }