Search in sources :

Example 6 with ContextResourceClient

use of org.qi4j.library.rest.client.api.ContextResourceClient in project qi4j-sdk by Qi4j.

the class ContextResourceClientFactoryTest method testQueryListAndCommandProgressive.

@Test
public void testQueryListAndCommandProgressive() {
    //START SNIPPET: query-list-and-command-progressive
    crc.onResource(new ResultHandler<Resource>() {

        @Override
        public HandlerCommand handleResult(Resource result, ContextResourceClient client) {
            return query("commandwithvalue").onSuccess(new ResultHandler<Links>() {

                @Override
                public HandlerCommand handleResult(Links result, ContextResourceClient client) {
                    Link link = LinksUtil.withId("right", result);
                    return command(link).onSuccess(new ResponseHandler() {

                        @Override
                        public HandlerCommand handleResponse(Response response, ContextResourceClient client) {
                            System.out.println("Done");
                            return null;
                        }
                    });
                }
            });
        }
    });
    crc.start();
//END SNIPPET: query-list-and-command-progressive
}
Also used : HandlerCommand(org.qi4j.library.rest.client.api.HandlerCommand) Response(org.restlet.Response) ResponseHandler(org.qi4j.library.rest.client.spi.ResponseHandler) SubResource(org.qi4j.library.rest.server.api.SubResource) ContextResource(org.qi4j.library.rest.server.api.ContextResource) Resource(org.qi4j.library.rest.common.Resource) Links(org.qi4j.library.rest.common.link.Links) ResultHandler(org.qi4j.library.rest.client.spi.ResultHandler) ContextResourceClient(org.qi4j.library.rest.client.api.ContextResourceClient) Link(org.qi4j.library.rest.common.link.Link) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 7 with ContextResourceClient

use of org.qi4j.library.rest.client.api.ContextResourceClient in project qi4j-sdk by Qi4j.

the class ContinuousIntegrationTest method testRunBuild.

@Test
public void testRunBuild() {
    //START SNIPPET: query-list-and-command
    crc.onResource(new ResultHandler<Resource>() {

        @Override
        public HandlerCommand handleResult(Resource result, ContextResourceClient client) {
            return query("runbuild");
        }
    }).onQuery("runbuild", new ResultHandler<Links>() {

        @Override
        public HandlerCommand handleResult(Links result, ContextResourceClient client) {
            Link link = LinksUtil.withId("any", result);
            return command(link);
        }
    }).onCommand("runbuild", new ResponseHandler() {

        @Override
        public HandlerCommand handleResponse(Response response, ContextResourceClient client) {
            System.out.println("Done");
            return null;
        }
    });
    crc.start();
//END SNIPPET: query-list-and-command
}
Also used : HandlerCommand(org.qi4j.library.rest.client.api.HandlerCommand) Response(org.restlet.Response) ResponseHandler(org.qi4j.library.rest.client.spi.ResponseHandler) ContextResource(org.qi4j.library.rest.server.api.ContextResource) Resource(org.qi4j.library.rest.common.Resource) Links(org.qi4j.library.rest.common.link.Links) ResultHandler(org.qi4j.library.rest.client.spi.ResultHandler) ContextResourceClient(org.qi4j.library.rest.client.api.ContextResourceClient) Link(org.qi4j.library.rest.common.link.Link) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Aggregations

ContextResourceClient (org.qi4j.library.rest.client.api.ContextResourceClient)7 HandlerCommand (org.qi4j.library.rest.client.api.HandlerCommand)7 ResponseHandler (org.qi4j.library.rest.client.spi.ResponseHandler)7 Response (org.restlet.Response)7 Test (org.junit.Test)5 AbstractQi4jTest (org.qi4j.test.AbstractQi4jTest)5 ResultHandler (org.qi4j.library.rest.client.spi.ResultHandler)4 Resource (org.qi4j.library.rest.common.Resource)4 Link (org.qi4j.library.rest.common.link.Link)4 Links (org.qi4j.library.rest.common.link.Links)4 ContextResource (org.qi4j.library.rest.server.api.ContextResource)4 ContextResourceClientFactory (org.qi4j.library.rest.client.api.ContextResourceClientFactory)3 ErrorHandler (org.qi4j.library.rest.client.api.ErrorHandler)3 Client (org.restlet.Client)3 Reference (org.restlet.data.Reference)3 ResourceException (org.restlet.resource.ResourceException)3 Before (org.junit.Before)2 ContextRestlet (org.qi4j.library.rest.server.api.ContextRestlet)2 SubResource (org.qi4j.library.rest.server.api.SubResource)2 Server (org.restlet.Server)2