Search in sources :

Example 11 with Events

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

the class IgnoreEventsTest method passesEventsThrough.

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

Example 12 with Events

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

the class IgnoreEventsTest method filtersEventsOut.

/**
 * IgnoreEvents can filter out events.
 * @throws Exception If some problem inside
 */
@Test
public void filtersEventsOut() throws Exception {
    final Events events = Mockito.mock(Events.class);
    new IgnoreEvents(events, "/alpha.*/").post("x", "an\nalpha one\nhere");
    Mockito.verify(events, Mockito.never()).post(Mockito.anyString(), Mockito.anyString());
}
Also used : Events(io.wring.model.Events) Test(org.junit.Test)

Example 13 with Events

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

the class DyEventITCase method upvotes.

/**
 * DyEvent can up-vote.
 * @throws Exception If some problem inside
 */
@Test
public void upvotes() throws Exception {
    final User user = new DyUser(new Dynamo(), "nick");
    final Events events = user.events();
    events.post("hey you", "some text [test](http://a.com/$t)!");
    final Event event = events.iterate().iterator().next();
    event.vote(Tv.FIFTEEN);
    MatcherAssert.assertThat(new Xembler(events.iterate().iterator().next().asXembly()).xml(), XhtmlMatchers.hasXPaths("/event[title='hey you']", "/event[rank=16]"));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Event(io.wring.model.Event) Xembler(org.xembly.Xembler) Test(org.junit.Test)

Example 14 with Events

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

the class DyEventsITCase method addsManyEvents.

/**
 * DyEvents can add many events.
 * @throws Exception If some problem inside
 */
@Test
public void addsManyEvents() throws Exception {
    final User user = new DyUser(new Dynamo(), "william");
    final Events events = user.events();
    for (int idx = 0; idx < Tv.FIVE; ++idx) {
        events.post(String.format("event #%d", idx), "some text");
    }
    MatcherAssert.assertThat(Iterables.size(events.iterate()), Matchers.equalTo(Tv.FIVE));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Test(org.junit.Test)

Example 15 with Events

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

the class DyEventsITCase method postsAndVotes.

/**
 * DyEvents can post and vote.
 * @throws Exception If some problem inside
 */
@Test
public void postsAndVotes() throws Exception {
    final User user = new DyUser(new Dynamo(), "erikk");
    final Events events = user.events();
    final String title = "the title of the Event --+";
    events.post(title, "some body text of the event");
    events.event(title).vote(1);
    MatcherAssert.assertThat(new Xembler(events.event(title).asXembly()).xml(), XhtmlMatchers.hasXPaths("/event[rank=2]"));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Xembler(org.xembly.Xembler) 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