mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-05 01:59:34 +01:00
Merge "stringWithLength" matcher implementations
- For some reason Hamcrest does not provide a "string with length" matcher -> move our two implementations as one method in AuthMe matchers class
This commit is contained in:
parent
914462fc3f
commit
cf3d84e3c1
@ -81,4 +81,18 @@ public final class AuthMeMatchers {
|
||||
};
|
||||
}
|
||||
|
||||
public static Matcher<String> stringWithLength(final int length) {
|
||||
return new TypeSafeMatcher<String>() {
|
||||
@Override
|
||||
protected boolean matchesSafely(String item) {
|
||||
return item != null && item.length() == length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("String with length " + length);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,9 +11,6 @@ import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -25,6 +22,7 @@ import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static fr.xephi.authme.AuthMeMatchers.stringWithLength;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
@ -199,19 +197,4 @@ public class RecoverEmailCommandTest {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Matcher<String> stringWithLength(final int length) {
|
||||
return new TypeSafeMatcher<String>() {
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("String of length " + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(String s) {
|
||||
return s.length() == length;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -27,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static fr.xephi.authme.AuthMeMatchers.stringWithLength;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
@ -241,19 +240,4 @@ public class RegisterCommandTest {
|
||||
// then
|
||||
verify(management).performRegister(player, "myPass", "", true);
|
||||
}
|
||||
|
||||
|
||||
private static TypeSafeMatcher<String> stringWithLength(final int length) {
|
||||
return new TypeSafeMatcher<String>() {
|
||||
@Override
|
||||
protected boolean matchesSafely(String item) {
|
||||
return item != null && item.length() == length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("String with length " + length);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user