Search in sources :

Example 6 with Event

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]"));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Event(io.wring.model.Event) Xembler(org.xembly.Xembler) Test(org.junit.jupiter.api.Test)

Example 7 with Event

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));
}
Also used : RqHref(org.takes.rq.RqHref) User(io.wring.model.User) RsFlash(org.takes.facets.flash.RsFlash) RqHref(org.takes.rq.RqHref) Href(org.takes.misc.Href) Event(io.wring.model.Event) XePrint(io.wring.model.XePrint) RsForward(org.takes.facets.forward.RsForward)

Aggregations

Event (io.wring.model.Event)7 Events (io.wring.model.Events)5 Test (org.junit.jupiter.api.Test)5 User (io.wring.model.User)4 RsFlash (org.takes.facets.flash.RsFlash)2 RsForward (org.takes.facets.forward.RsForward)2 RqHref (org.takes.rq.RqHref)2 XePrint (io.wring.model.XePrint)1 InputStreamOf (org.cactoos.io.InputStreamOf)1 Href (org.takes.misc.Href)1 Xembler (org.xembly.Xembler)1