@Test public void should_update_data_for_a_single_generated_mature_person() { Person robert = new Person("Robert", 25); Person anna = new Person("Anna", 35); List<Person> oldPeople = asList(robert, anna); given(newIdentityCreator.createNewAge(argThat(hasAgeGreaterThan(30)))).willReturn(18); systemUnderTest.generateNewIdentities(oldPeople); verify(newIdentityCreator).updateDataFor(numberOfMaturePeople(1)); }
public List<Person> generateNewIdentities(List<Person> people) { List<Person> newPeople = new ArrayList<Person>(); for(Person person : people) { String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); Person newPerson = new Person(newName, newAge, newSiblings); newPeople.add(newPerson); } newIdentityCreator.updateDataFor(newPeople); return newPeople; }
NewPersonGenerator { public List<Person> generateNewIdentities(List<Person> people) { List<Person> newPeople = new ArrayList<Person>(); for(Person person : people) { String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); Person newPerson = new Person(newName, newAge, newSiblings); newPeople.add(newPerson); } newIdentityCreator.updateDataFor(newPeople); return newPeople; } }
NewPersonGenerator { public List<Person> generateNewIdentities(List<Person> people) { List<Person> newPeople = new ArrayList<Person>(); for(Person person : people) { String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); Person newPerson = new Person(newName, newAge, newSiblings); newPeople.add(newPerson); } newIdentityCreator.updateDataFor(newPeople); return newPeople; } NewPersonGenerator(NewIdentityCreator newIdentityCreator); }
NewPersonGenerator { public List<Person> generateNewIdentities(List<Person> people) { List<Person> newPeople = new ArrayList<Person>(); for(Person person : people) { String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); Person newPerson = new Person(newName, newAge, newSiblings); newPeople.add(newPerson); } newIdentityCreator.updateDataFor(newPeople); return newPeople; } NewPersonGenerator(NewIdentityCreator newIdentityCreator); List<Person> generateNewIdentities(List<Person> people); }
NewPersonGenerator { public List<Person> generateNewIdentities(List<Person> people) { List<Person> newPeople = new ArrayList<Person>(); for(Person person : people) { String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); Person newPerson = new Person(newName, newAge, newSiblings); newPeople.add(newPerson); } newIdentityCreator.updateDataFor(newPeople); return newPeople; } NewPersonGenerator(NewIdentityCreator newIdentityCreator); List<Person> generateNewIdentities(List<Person> people);  }