// Path: matcher-decorators/src/main/java/ru/yandex/qatools/matchers/decorators/MatcherDecoratorsBuilder.java
// @Factory
// public static <T> MatcherDecoratorsBuilder<T> should(final Matcher<? super T> matcher) {
//     return new MatcherDecoratorsBuilder<T>(matcher);
// }


import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import static ru.yandex.qatools.matchers.decorators.MatcherDecoratorsBuilder.should;
package ru.yandex.qatools.matchers.decorators;



/**
 * @author Alexander Tolmachev starlight@yandex-team.ru
 *         Date: 06.03.13
 */
@RunWith(MockitoJUnitRunner.class)
public class ConditionMatcherDecoratorTest {
    @Mock
    private Matcher<Object> condition;

    private final Object itemToMatchCondition = new Object();

    @Mock
    private Matcher<Object> matcher;

    private final Object arbitraryObject = new Object();

    @Test
    public void conditionShouldBeCheckedWhenDecoratedMatcherIsCalled() {
        when(matcher.matches(arbitraryObject)).thenReturn(true);
        when(condition.matches(itemToMatchCondition)).thenReturn(true);

// Path: matcher-decorators/src/main/java/ru/yandex/qatools/matchers/decorators/MatcherDecoratorsBuilder.java
// @Factory
// public static <T> MatcherDecoratorsBuilder<T> should(final Matcher<? super T> matcher) {
//     return new MatcherDecoratorsBuilder<T>(matcher);
// }


// Path: matcher-decorators/src/test/java/ru/yandex/qatools/matchers/decorators/ConditionMatcherDecoratorTest.java
import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import static ru.yandex.qatools.matchers.decorators.MatcherDecoratorsBuilder.should;

package ru.yandex.qatools.matchers.decorators;



/**
 * @author Alexander Tolmachev starlight@yandex-team.ru
 *         Date: 06.03.13
 */
@RunWith(MockitoJUnitRunner.class)
public class ConditionMatcherDecoratorTest {
    @Mock
    private Matcher<Object> condition;

    private final Object itemToMatchCondition = new Object();

    @Mock
    private Matcher<Object> matcher;

    private final Object arbitraryObject = new Object();

    @Test
    public void conditionShouldBeCheckedWhenDecoratedMatcherIsCalled() {
        when(matcher.matches(arbitraryObject)).thenReturn(true);
        when(condition.matches(itemToMatchCondition)).thenReturn(true);

        assertThat(arbitraryObject, should(matcher).inCase(itemToMatchCondition, condition));