All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.annimon.stream.test.mockito.OptionalMatcher Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
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