Add additional tests

This commit is contained in:
Grzegorz Piwowarek
2016-07-30 12:08:27 +02:00
parent eff343b596
commit 591e3507fb
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package com.baeldung.immutable.auxiliary;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class ImmutablePersonAuxiliaryTest {
@Test
public void whenComparing_shouldIgnore() throws Exception {
final com.baeldung.immutable.auxiliary.ImmutablePerson john1 = com.baeldung.immutable.auxiliary.ImmutablePerson.builder()
.name("John")
.age(42)
.auxiliaryField("Value1")
.build();
final com.baeldung.immutable.auxiliary.ImmutablePerson john2 = com.baeldung.immutable.auxiliary.ImmutablePerson.builder()
.name("John")
.age(42)
.auxiliaryField("Value2")
.build();
assertThat(john1.equals(john2))
.isTrue();
assertThat(john1.toString())
.isEqualTo(john2.toString());
assertThat(john1.hashCode())
.isEqualTo(john2.hashCode());
}
}