Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Piwowarek committed Jul 30, 2016
1 parent eff343b commit 591e350
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

public class ValueObject {
public ValueObject() {


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.baeldung.immutable.auxiliary;


import org.immutables.value.Value;

@Value.Immutable
public abstract class Person {
abstract String getName();
abstract Integer getAge();

@Value.Auxiliary
abstract String getAuxiliaryField();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void whenModifying_shouldCreateNewInstance() throws Exception {

assertThat(john)
.isNotSameAs(john43);

assertThat(john.getAge())
.isEqualTo(42);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 591e350

Please sign in to comment.