Search in sources :

Example 1 with InputStreamOf

use of org.cactoos.io.InputStreamOf in project wring by yegor256.

the class IgnoreEventsTest method filtersEventsOutByJsonConfig.

/**
 * IgnoreEvents can filter out events.
 * @throws Exception If some problem inside
 */
@Test
public void filtersEventsOutByJsonConfig() throws Exception {
    final Events events = Mockito.mock(Events.class);
    new IgnoreEvents(events, Json.createReader(new InputStreamOf("{\"ignore\":[\"/gamma.*/\"]}")).readObject()).post("xx", "an\ngamma\nhere");
    Mockito.verify(events, Mockito.never()).post(Mockito.anyString(), Mockito.anyString());
}
Also used : Events(io.wring.model.Events) InputStreamOf(org.cactoos.io.InputStreamOf) Test(org.junit.Test)

Example 2 with InputStreamOf

use of org.cactoos.io.InputStreamOf in project wring by yegor256.

the class IgnoreEventsTest method passesEventsThroughByJsonConfig.

/**
 * IgnoreEvents can filter out events.
 * @throws Exception If some problem inside
 */
@Test
public void passesEventsThroughByJsonConfig() throws Exception {
    final Events events = Mockito.mock(Events.class);
    new IgnoreEvents(events, Json.createReader(new InputStreamOf("{}")).readObject()).post("xxy", "a\nbeta\nhere");
    Mockito.verify(events).post(Mockito.anyString(), Mockito.anyString());
}
Also used : Events(io.wring.model.Events) InputStreamOf(org.cactoos.io.InputStreamOf) Test(org.junit.Test)

Example 3 with InputStreamOf

use of org.cactoos.io.InputStreamOf in project wring by yegor256.

the class BoostEventsTest method passesEventsThroughByJsonConfig.

/**
 * IgnoreEvents can filter out events.
 * @throws Exception If some problem inside
 */
@Test
public void passesEventsThroughByJsonConfig() throws Exception {
    final Events events = Mockito.mock(Events.class);
    final Event event = Mockito.mock(Event.class);
    Mockito.doReturn(event).when(events).event(Mockito.anyString());
    new BoostEvents(events, Json.createReader(new InputStreamOf("{}")).readObject()).post("the title", "the body");
    Mockito.verify(event, Mockito.never()).vote(Mockito.anyInt());
}
Also used : Events(io.wring.model.Events) Event(io.wring.model.Event) InputStreamOf(org.cactoos.io.InputStreamOf) Test(org.junit.Test)

Aggregations

Events (io.wring.model.Events)3 InputStreamOf (org.cactoos.io.InputStreamOf)3 Test (org.junit.Test)3 Event (io.wring.model.Event)1