BAEL-1579: Renaming custom matcher and handling corner case. (#3928)

This commit is contained in:
Magdalena Krause
2018-04-03 18:41:09 -03:00
committed by maibin
parent ad40040852
commit 2e1949b898
3 changed files with 12 additions and 11 deletions
@@ -3,7 +3,7 @@ package org.baeldung.hamcrest;
import org.junit.Test;
import static org.baeldung.hamcrest.custommatchers.IsDivisibleBy.divisibleBy;
import static org.baeldung.hamcrest.custommatchers.IsOnlyNumbers.onlyNumbers;
import static org.baeldung.hamcrest.custommatchers.IsOnlyDigits.onlyDigits;
import static org.baeldung.hamcrest.custommatchers.IsUppercase.uppercase;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -12,17 +12,17 @@ import static org.hamcrest.Matchers.not;
public class HamcrestCustomUnitTest {
@Test
public final void givenAString_whenIsOnlyNumbers_thenCorrect() {
String numbers = "123";
public final void givenAString_whenIsOnlyDigits_thenCorrect() {
String digits = "123";
assertThat(numbers, is(onlyNumbers()));
assertThat(digits, is(onlyDigits()));
}
@Test
public final void givenAString_whenIsNotOnlyNumbers_thenCorrect() {
String numbers = "123ABC";
public final void givenAString_whenIsNotOnlyDigits_thenCorrect() {
String aphanumeric = "123ABC";
assertThat(numbers, is(not(onlyNumbers())));
assertThat(aphanumeric, is(not(onlyDigits())));
}
@Test