Package com.rallydev.rest.response

Examples of com.rallydev.rest.response.QueryResponse


    public void shouldQueryOnePage() throws Exception {
        JsonObject response = buildQueryResponse(5);
        QueryRequest request = new QueryRequest("Defect");
        request.setPageSize(1);
        doReturn(new Gson().toJson(response)).when(api.client).doGet(request.toUrl());
        QueryResponse queryResponse = api.query(request);

        verify(api.client, times(1)).doGet(anyString());
        verify(api.client).doGet(request.toUrl());
        Assert.assertTrue(queryResponse.wasSuccessful());
        assertEquals(queryResponse.getTotalResultCount(), 5);
    }
View Full Code Here


     * @param request the {@link QueryRequest} specifying the object to be created.
     * @return the resulting {@link QueryResponse}
     * @throws IOException if an error occurs during the query.
     */
    public QueryResponse query(QueryRequest request) throws IOException {
        QueryResponse queryResponse = new QueryResponse(client.doGet(request.toUrl()));
        if (queryResponse.wasSuccessful()) {
            int receivedRecords = request.getPageSize();
            while (receivedRecords < request.getLimit() &&
                    (receivedRecords + request.getStart() - 1) < queryResponse.getTotalResultCount()) {
                QueryRequest pageRequest = request.clone();
                pageRequest.setStart(receivedRecords + request.getStart());
                QueryResponse pageResponse = new QueryResponse(client.doGet(pageRequest.toUrl()));
                if (pageResponse.wasSuccessful()) {
                    JsonArray results = queryResponse.getResults();
                    results.addAll(pageResponse.getResults());
                    receivedRecords += pageRequest.getPageSize();
                }
            }
        }

View Full Code Here

            //Return up to 5, 1 per page
            defects.setPageSize(1);
            defects.setLimit(5);

            QueryResponse queryResponse = restApi.query(defects);
            if (queryResponse.wasSuccessful()) {
                System.out.println(String.format("\nTotal results: %d", queryResponse.getTotalResultCount()));
                System.out.println("Top 5:");
                for (JsonElement result : queryResponse.getResults()) {
                    JsonObject defect = result.getAsJsonObject();
                    System.out.println(String.format("\t%s - %s: Priority=%s, State=%s",
                            defect.get("FormattedID").getAsString(),
                            defect.get("Name").getAsString(),
                            defect.get("Priority").getAsString(),
                            defect.get("State").getAsString()));
                }
            } else {
                System.err.println("The following errors occurred: ");
                for (String err : queryResponse.getErrors()) {
                    System.err.println("\t" + err);
                }
            }

        } finally {
View Full Code Here

            //Get a story with defects
            System.out.println("\nQuerying for stories with defects...");
            QueryRequest storiesWithDefects = new QueryRequest("hierarchicalrequirement");
            storiesWithDefects.setQueryFilter(new QueryFilter("Defects.ObjectID", "!=", null));
            storiesWithDefects.setFetch(new Fetch("FormattedID", "Name", "Defects:summary[Priority;State]"));
            QueryResponse storiesWithDefectsResponse = restApi.query(storiesWithDefects);
            JsonObject story = storiesWithDefectsResponse.getResults().get(0).getAsJsonObject();
            System.out.println(String.format("Found: %s - %s", story.get("FormattedID").getAsString(), story.get("Name").getAsString()));

            System.out.println(String.format("\nSummarizing defects..."));
            JsonObject defectSummary = story.getAsJsonObject("Summary").getAsJsonObject("Defects");
View Full Code Here

            //Get a story with defects
            System.out.println("\nQuerying for stories with defects...");
            QueryRequest storiesWithDefects = new QueryRequest("hierarchicalrequirement");
            storiesWithDefects.setQueryFilter(new QueryFilter("Defects.ObjectID", "!=", null));
            storiesWithDefects.setFetch(new Fetch("FormattedID", "Name", "Defects"));
            QueryResponse storiesWithDefectsResponse = restApi.query(storiesWithDefects);
            JsonObject story = storiesWithDefectsResponse.getResults().get(0).getAsJsonObject();
            System.out.println(String.format("Found: %s - %s", story.get("FormattedID").getAsString(), story.get("Name").getAsString()));

            //Inspect the defects collection
            JsonObject defectInfo = story.getAsJsonObject("Defects");
            int defectCount = defectInfo.get("Count").getAsInt();
            System.out.println(String.format("\nTotal defects: %d", defectCount));

            //Query the defects collection
            QueryRequest defectRequest = new QueryRequest(defectInfo);
            defectRequest.setFetch(new Fetch("FormattedID", "Name", "State", "Priority"));

            QueryResponse queryResponse = restApi.query(defectRequest);
            if (queryResponse.wasSuccessful()) {
                for (JsonElement result : queryResponse.getResults()) {
                    JsonObject defect = result.getAsJsonObject();
                    System.out.println(String.format("\t%s - %s: Priority=%s, State=%s",
                            defect.get("FormattedID").getAsString(),
                            defect.get("Name").getAsString(),
                            defect.get("Priority").getAsString(),
View Full Code Here

TOP

Related Classes of com.rallydev.rest.response.QueryResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.