package sklep.test_helpers;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;

import sklep.model.Katalog;

public class MatcherZdefiniowany extends BaseMatcher<String> {
	private Katalog katalog;

	private MatcherZdefiniowany(Katalog kat) {
		katalog = kat;
	}

	public static MatcherZdefiniowany jestZdefiniowanyW(Katalog kat) {
		return new MatcherZdefiniowany(kat);
	}

	@Override
	public boolean matches(Object arg) {
		if(arg instanceof String)
			return katalog.jestTowar((String)arg);
		else
			return false;
	}

	@Override
	public void describeTo(Description desc) {
		desc.appendText(" towar należący do katalogu ");
		desc.appendValue(katalog);
	}

	@Override
	public void describeMismatch(Object item, Description description) {
		description.appendText("było");
		description.appendValue(item);
	}
	
	
}
