use of io.wring.model.Event 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));
}
use of io.wring.model.Event 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);
}
use of io.wring.model.Event in project wring by yegor256.
the class TkEventDelete method act.
@Override
public Response act(final Request req) throws IOException {
final User user = this.base.user(new RqUser(req).urn());
final Href href = new RqHref.Base(req).href();
final Event event = user.events().event(href.param("title").iterator().next());
final String hash = new XePrint(event.asXembly()).text("{/event/md5/text()}");
if (!hash.equals(href.param("hash").iterator().next())) {
throw new RsForward(new RsFlash("Reload the page, the event has changed", Level.WARNING));
}
final String msg = new XePrint(event.asXembly()).text("Event \"{/event/title/text()}\" deleted");
event.delete();
return new RsForward(new RsFlash(msg));
}
use of io.wring.model.Event in project wring by yegor256.
the class TkEventDown method act.
@Override
public Response act(final Request req) throws IOException {
final User user = this.base.user(new RqUser(req).urn());
final Event event = user.events().event(new RqHref.Base(req).href().param("title").iterator().next());
event.vote(-Tv.TEN);
return new RsForward(new RsFlash("Event down-voted"));
}
use of io.wring.model.Event 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());
}
Aggregations