Skip to content

Commit

Permalink
Merge pull request #320 from uhafner/EqualsVerifier
Browse files Browse the repository at this point in the history
Use EqualsVerifier to ensure that equals has been implemented correctly
  • Loading branch information
uhafner authored Mar 20, 2021
2 parents fc1be88 + ceaf1aa commit 47a4e2c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -62,6 +62,7 @@
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>

<!-- Project Test Dependencies Configuration -->
<equalsverifier.version>3.5.5</equalsverifier.version>
<junit.version>5.7.1</junit.version>
<junit-platform-launcher.version>1.7.1</junit-platform-launcher.version>
<mockito.version>3.8.0</mockito.version>
Expand Down Expand Up @@ -103,7 +104,6 @@

<!-- Maven Surefire ArgLine -->
<argLine>-Djava.util.logging.config.file=logging.properties</argLine>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -144,6 +144,12 @@
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>${equalsverifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/edu/hm/hafner/util/FilteredLogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.jupiter.api.Test;

import nl.jqno.equalsverifier.EqualsVerifier;

import static edu.hm.hafner.util.assertions.Assertions.*;

/**
Expand Down Expand Up @@ -125,4 +127,9 @@ void shouldManuallyUseSerializationHelpers() {

assertThat(restored).isEqualTo(serializable);
}

@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple().forClass(FilteredLog.class).verify();
}
}
10 changes: 10 additions & 0 deletions src/test/java/edu/hm/hafner/util/TreeStringBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import org.junit.jupiter.api.Test;

import nl.jqno.equalsverifier.EqualsVerifier;

import static org.assertj.core.api.Assertions.*;

/**
Expand Down Expand Up @@ -115,4 +117,12 @@ void shouldCreateRandomTreeStrings() {
assertThat(o.get(i)).hasToString(a.get(i));
}
}

@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple()
.withPrefabValues(TreeString.class, TreeString.valueOf("One"), TreeString.valueOf("Teo"))
.forClass(TreeString.class)
.verify();
}
}

0 comments on commit 47a4e2c

Please sign in to comment.