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

com.github.karsaig.approvalcrest.matcher.MatcherFactory Maven / Gradle / Ivy

The newest version!
package com.github.karsaig.approvalcrest.matcher;

import static org.apache.commons.lang3.ClassUtils.isPrimitiveOrWrapper;

import com.github.karsaig.approvalcrest.FileMatcherConfig;

public class MatcherFactory {

    protected  DiagnosingCustomisableMatcher beanMatcher(T expected) {
        if (expected == null) {
            return new NullMatcher<>(expected);
        }

        if (isPrimitiveOrWrapper(expected.getClass()) || expected.getClass() == String.class
                || expected.getClass().isEnum()) {
            return new IsEqualMatcher<>(expected);
        }

        return new DiagnosingCustomisableMatcher<>(expected);
    }

    protected  JsonMatcher jsonMatcher(TestMetaInformation testMetaInformation, FileMatcherConfig fileMatcherConfig) {
        return new JsonMatcher<>(testMetaInformation, fileMatcherConfig);
    }

    protected  ContentMatcher contentMatcher(TestMetaInformation testMetaInformation, FileMatcherConfig fileMatcherConfig) {
        return new ContentMatcher<>(testMetaInformation, fileMatcherConfig);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy