
com.annimon.stream.test.mockito.OptionalMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream-test Show documentation
Show all versions of stream-test Show documentation
Hamcrest and Mockito matchers for Lightweight-Stream-API
package com.annimon.stream.test.mockito;
import com.annimon.stream.Optional;
import org.mockito.ArgumentMatcher;
import static org.mockito.Matchers.argThat;
public class OptionalMatcher {
private OptionalMatcher() { }
public static Optional anyPresentOptional() {
return argThat(new PresentOptionalMatcher());
}
public static Optional anyPresentOptional(@SuppressWarnings("UnusedParameters") Class clazz) {
return argThat(new PresentOptionalMatcher());
}
public static Optional anyEmptyOptional() {
return argThat(new EmptyOptionalMatcher());
}
public static Optional anyEmptyOptional(@SuppressWarnings("UnusedParameters") Class clazz) {
return argThat(new EmptyOptionalMatcher());
}
public static class PresentOptionalMatcher implements ArgumentMatcher> {
@Override
public boolean matches(Optional argument) {
return argument != null && argument.isPresent();
}
@Override
public String toString() {
return "anyPresentOptional()";
}
}
public static class EmptyOptionalMatcher implements ArgumentMatcher> {
@Override
public boolean matches(Optional argument) {
return argument != null && !argument.isPresent();
}
@Override
public String toString() {
return "anyEmptyOptional()";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy