Micha Kops avatar Micha Kops committed 5e5eab3 Draft

Maven dependencies fixed, verbosity for book matcher added.

Comments (0)

Files changed (4)

 
 	<dependencies>
 		<dependency>
+			<groupId>org.hamcrest</groupId>
+			<artifactId>hamcrest-all</artifactId>
+			<version>1.3</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<version>4.10</version>
 			<scope>test</scope>
 		</dependency>
-		<dependency>
-			<groupId>org.hamcrest</groupId>
-			<artifactId>hamcrest-all</artifactId>
-			<version>1.3</version>
-			<scope>test</scope>
-		</dependency>
 	</dependencies>
 
 	<build>

src/main/java/com/hascode/entity/Book.java

 		return title;
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#toString()
-	 */
 	@Override
 	public String toString() {
 		return "Book [id=" + id + ", isbn=" + isbn + ", title=" + title + "]";

src/test/java/com/hascode/entity/BookTest.java

 
 import static com.hascode.matcher.BookMatcher.hasId;
 import static com.hascode.matcher.BookMatcher.hasIsbn;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.junit.Test;
 

src/test/java/com/hascode/matcher/BookMatcher.java

 			@Override
 			public void describeMismatchSafely(final Book book,
 					final Description mismatchDescription) {
-				mismatchDescription.appendText(" but was ").appendValue(
+				mismatchDescription.appendText("was ").appendValue(
 						book.getIsbn());
 			}
 
 			protected boolean matchesSafely(final Book book) {
 				return id == book.getId();
 			}
+
+			@Override
+			public void describeMismatchSafely(final Book book,
+					final Description mismatchDescription) {
+				mismatchDescription.appendText("was ")
+						.appendValue(book.getId());
+			}
 		};
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.