package org.mutabilitydetector;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.mutabilitydetector.checkers.IMutabilityChecker;

/*
 * Mutability Detector
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Further licensing information for this project can be found in 
 * 		license/LICENSE.txt
 */

public class TestMatchers {

	
	public static Matcher<? super IMutabilityChecker> hasReasons() {
		return new TypeSafeDiagnosingMatcher<IMutabilityChecker>() {

			@Override protected boolean matchesSafely(IMutabilityChecker item, Description mismatchDescription) {
				
				mismatchDescription.appendText(" got a checker (" + item.toString() + ") containing zero reasons ");
				return !(item.reasons().isEmpty());
			}

			@Override public void describeTo(Description description) {
				description.appendText(" got a checker reporting at least one reason ");
			}

		};
	}
	
}

Add a matcher for testing that a checker reports reasons - currently the AnalysisResult will prevent this in practice, with an IllegalArgumentException, but that may not always be the case, so keep the check.
Add a matcher for testing that a checker reports reasons - currently the AnalysisResult will prevent this in practice, with an IllegalArgumentException, but that may not always be the case, so keep the check.

git-svn-id: ed609ce04ec9e3c0bc25e071e87814dd6d976548@228 c7a0535c-eda6-11de-83d8-6d5adf01d787
