Search in sources :

Example 1 with FlagTrigger

use of org.mamute.model.flag.FlagTrigger in project mamute by caelum.

the class FlagTriggerTest method should_trigger_correct_actions.

@Test
public void should_trigger_correct_actions() {
    FlagAction neverExecuteAction = mock(FlagAction.class);
    FlagAction alwaysExecuteAction = mock(FlagAction.class);
    Flaggable flaggable = mock(Flaggable.class);
    when(neverExecuteAction.shouldHandle(Mockito.any(Flaggable.class))).thenReturn(false);
    when(alwaysExecuteAction.shouldHandle(Mockito.any(Flaggable.class))).thenReturn(true);
    FlagTrigger flagTrigger = new FlagTrigger(Arrays.asList(neverExecuteAction, alwaysExecuteAction));
    flagTrigger.fire(flaggable);
    verify(neverExecuteAction, never()).fire(flaggable);
    verify(alwaysExecuteAction, times(1)).fire(flaggable);
}
Also used : Flaggable(org.mamute.model.interfaces.Flaggable) FlagTrigger(org.mamute.model.flag.FlagTrigger) FlagAction(org.mamute.model.flag.FlagAction) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FlagAction (org.mamute.model.flag.FlagAction)1 FlagTrigger (org.mamute.model.flag.FlagTrigger)1 Flaggable (org.mamute.model.interfaces.Flaggable)1