@Before public void setUp() { i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK); when(eventBuilder.setOldEntity(any(Consumer.class))).thenReturn(eventBuilder); when(eventBuilder.setNewEntity(any(Consumer.class))).thenReturn(eventBuilder); when(eventFactory.getEventBuilder(any(Target.class), any(Type.class))).thenReturn(eventBuilder); }
@Test public void events() { List<Entitlement> ents = new ArrayList<Entitlement>(); ents.add(mock(Entitlement.class)); ents.add(mock(Entitlement.class)); Event evt1 = mock(Event.class); Event evt2 = mock(Event.class); when(ef.entitlementCreated(any(Entitlement.class))).thenReturn(evt1).thenReturn(evt2); entitler.sendEvents(ents); verify(sink).queueEvent(eq(evt1)); verify(sink).queueEvent(eq(evt2)); }