Search in sources :

Example 1 with Events

use of io.wring.model.Events in project wring by yegor256.

the class DyEventsITCase method deletesEvent.

/**
 * DyEvents can delete events.
 * @throws Exception If some problem inside
 */
@Test
public void deletesEvent() throws Exception {
    final User user = new DyUser(new Dynamo(), "boris");
    final Events events = user.events();
    events.post("subj", "body");
    final Event event = events.iterate().iterator().next();
    event.delete();
    MatcherAssert.assertThat(Iterables.size(events.iterate()), Matchers.equalTo(0));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Event(io.wring.model.Event) Test(org.junit.Test)

Example 2 with Events

use of io.wring.model.Events in project wring by yegor256.

the class BoostEventsTest method boostsEvents.

/**
 * BoostEvents can boost events.
 * @throws Exception If some problem inside
 */
@Test
public void boostsEvents() 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, "alpha.*").post("x", "an\nalpha one\nhere");
    Mockito.verify(event).vote(Tv.FIVE);
}
Also used : Events(io.wring.model.Events) Event(io.wring.model.Event) Test(org.junit.Test)

Example 3 with Events

use of io.wring.model.Events in project wring by yegor256.

the class BoostEventsTest method ignoresEventsThrough.

/**
 * BoostEvents can ignore events.
 * @throws Exception If some problem inside
 */
@Test
public void ignoresEventsThrough() throws Exception {
    final Events events = Mockito.mock(Events.class);
    new BoostEvents(events, "/beta.*/").post("y", "there is no text here");
}
Also used : Events(io.wring.model.Events) Test(org.junit.Test)

Example 4 with Events

use of io.wring.model.Events 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 5 with Events

use of io.wring.model.Events 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)

Aggregations

Events (io.wring.model.Events)16 Test (org.junit.Test)15 Event (io.wring.model.Event)5 User (io.wring.model.User)5 InputStreamOf (org.cactoos.io.InputStreamOf)3 Xembler (org.xembly.Xembler)3 FkBase (io.wring.fake.FkBase)1 FkPipe (io.wring.fake.FkPipe)1 Base (io.wring.model.Base)1 Pipe (io.wring.model.Pipe)1 XePrint (io.wring.model.XePrint)1 IOException (java.io.IOException)1 Json (javax.json.Json)1 JsonObject (javax.json.JsonObject)1 Proc (org.cactoos.Proc)1 FuncOf (org.cactoos.func.FuncOf)1 FuncWithFallback (org.cactoos.func.FuncWithFallback)1 UncheckedFunc (org.cactoos.func.UncheckedFunc)1 BytesOf (org.cactoos.io.BytesOf)1 ReaderOf (org.cactoos.io.ReaderOf)1