use of io.wring.model.Event 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.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));
}
Aggregations