@Test public void should_return_person_with_new_identity() { List<Person> siblings = asList(new Person("John", 10), new Person("Maria", 12)); Person person = new Person("Robert", 25, siblings); Person newPerson = systemUnderTest.generateNewIdentity(person); then(newPerson).isNotEqualTo(person); then(newPerson.getAge()).isNotEqualTo(person.getAge()); then(newPerson.getName()).isNotEqualTo(person.getName()); then(newPerson.getSiblings()).doesNotContainAnyElementsOf(siblings); }
public Person generateNewIdentity(Person person) { NewIdentityCreator newIdentityCreator = new NewIdentityCreator(); String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); return new Person(newName, newAge, newSiblings); }
BadlyDesignedNewPersonGenerator { public Person generateNewIdentity(Person person) { NewIdentityCreator newIdentityCreator = new NewIdentityCreator(); String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); return new Person(newName, newAge, newSiblings); } }
BadlyDesignedNewPersonGenerator { public Person generateNewIdentity(Person person) { NewIdentityCreator newIdentityCreator = new NewIdentityCreator(); String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); return new Person(newName, newAge, newSiblings); }  }
BadlyDesignedNewPersonGenerator { public Person generateNewIdentity(Person person) { NewIdentityCreator newIdentityCreator = new NewIdentityCreator(); String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); return new Person(newName, newAge, newSiblings); }  Person generateNewIdentity(Person person); }
BadlyDesignedNewPersonGenerator { public Person generateNewIdentity(Person person) { NewIdentityCreator newIdentityCreator = new NewIdentityCreator(); String newName = newIdentityCreator.createNewName(person); int newAge = newIdentityCreator.createNewAge(person); List<Person> newSiblings = newIdentityCreator.createNewSiblings(person); return new Person(newName, newAge, newSiblings); }  Person generateNewIdentity(Person person);  }