Search in sources :

Example 6 with User

use of io.wring.model.User 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 7 with User

use of io.wring.model.User 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)

Example 8 with User

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

the class DyEventsITCase method appendsToExistingEvents.

/**
 * DyEvents can append text to.
 * @throws Exception If some problem inside
 */
@Test
public void appendsToExistingEvents() throws Exception {
    final User user = new DyUser(new Dynamo(), "peter");
    final Events events = user.events();
    final String title = "a simple title";
    events.post(title, "\n\tfirst body");
    events.post(title, "\n\u0000\u00fdin between");
    events.post(title, "second body\n\n");
    MatcherAssert.assertThat(new Xembler(events.iterate().iterator().next().asXembly()).xml(), XhtmlMatchers.hasXPaths("/event/text[contains(.,'first')]", "/event/text[contains(.,'second body')]", "/event/text[not(contains(.,'first body\n'))]"));
}
Also used : User(io.wring.model.User) Events(io.wring.model.Events) Xembler(org.xembly.Xembler) Test(org.junit.Test)

Example 9 with User

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

the class DyPipesITCase method addsAndRemovePipes.

/**
 * DyPipes can add and remove pipes.
 * @throws Exception If some problem inside
 */
@Test
public void addsAndRemovePipes() throws Exception {
    final User user = new DyUser(new Dynamo(), "jeffrey");
    final Pipes pipes = user.pipes();
    pipes.add("{\"name\": \"hello\"}");
    final Pipe pipe = pipes.iterate().iterator().next();
    MatcherAssert.assertThat(new Xembler(pipe.asXembly()).xml(), XhtmlMatchers.hasXPaths("/pipe/json", "/pipe/id"));
    pipe.delete();
}
Also used : User(io.wring.model.User) Pipe(io.wring.model.Pipe) Xembler(org.xembly.Xembler) Pipes(io.wring.model.Pipes) Test(org.junit.Test)

Example 10 with User

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

the class DyUserITCase method rendersPipes.

/**
 * DyUser can render pipes.
 * @throws Exception If some problem inside
 */
@Test
public void rendersPipes() throws Exception {
    final User user = new DyUser(new Dynamo(), "jeff");
    MatcherAssert.assertThat(user.pipes(), Matchers.notNullValue());
}
Also used : User(io.wring.model.User) Test(org.junit.Test)

Aggregations

User (io.wring.model.User)10 Test (org.junit.Test)8 Events (io.wring.model.Events)5 Event (io.wring.model.Event)4 Xembler (org.xembly.Xembler)4 Pipes (io.wring.model.Pipes)2 RsFlash (org.takes.facets.flash.RsFlash)2 RsForward (org.takes.facets.forward.RsForward)2 RqHref (org.takes.rq.RqHref)2 Pipe (io.wring.model.Pipe)1 XePrint (io.wring.model.XePrint)1 Href (org.takes.misc.Href)1