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());
}
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());
}
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]"));
}
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));
}
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]"));
}
Aggregations