Package javax.json

Examples of javax.json.JsonObject


        final Issue issue = repo.issues().create("testing4", "issue4");
        final RtComment comment = new RtComment(
            new ApacheRequest(container.home()), issue, 10
        );
        try {
            final JsonObject json = comment.json();
            MatcherAssert.assertThat(
                json.getString("body"),
                Matchers.is("test5")
            );
        } finally {
            container.stop();
        }
View Full Code Here


        final Repo repo = repo();
        final Issue issue = repo.issues().create("testing5", "issue5");
        final RtComment comment = new RtComment(
            new ApacheRequest(container.home()), issue, 10
        );
        final JsonObject jsonPatch = Json.createObjectBuilder()
            .add("title", "test comment").build();
        try {
            comment.patch(jsonPatch);
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
View Full Code Here

     * @throws IOException If some problem inside.
     */
    @Test
    public void fetchLabelsRO() throws IOException {
        final String name = "bug";
        final JsonObject json = Json.createObjectBuilder().add(
            "labels",
            Json.createArrayBuilder().add(
                Json.createObjectBuilder()
                    .add("name", name)
                    .add("color", "f29513")
            )
        ).build();
        final Issue issue = new RtIssue(
            new FakeRequest().withBody(json.toString()), this.repo(), 1
        );
        final IssueLabels labels = new Issue.Smart(issue).roLabels();
        this.thrown.expect(UnsupportedOperationException.class);
        labels.add(new ArrayList<String>(0));
        this.thrown.expect(UnsupportedOperationException.class);
View Full Code Here

    @Test
    public void canEditRelease() throws Exception {
        final Release release = repo.releases().create(
            RandomStringUtils.randomAlphanumeric(Tv.TEN)
        );
        final JsonObject patch = Json.createObjectBuilder()
            .add("tag_name", RandomStringUtils.randomAlphanumeric(Tv.TEN))
            .add("name", "jcabi Github test release")
            .add("body", "jcabi Github was here!")
            .build();
        release.patch(patch);
        final JsonObject json = repo.releases()
            .get(release.number()).json();
        for (final String property : patch.keySet()) {
            MatcherAssert.assertThat(
                json.getString(property),
                Matchers.equalTo(patch.getString(property))
            );
        }
    }
View Full Code Here

    public final void editRelease() throws Exception {
        this.container.next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, EMPTY_JSON)
        ).start();
        final RtRelease release = RtReleaseTest.release(this.container.home());
        final JsonObject json = Json.createObjectBuilder()
            .add("tag_name", "v1.0.0")
            .build();
        release.patch(json);
        final MkQuery query = this.container.take();
        MatcherAssert.assertThat(
            query.method(),
            Matchers.equalTo(Request.PATCH)
        );
        MatcherAssert.assertThat(
            query.body(),
            Matchers.equalTo(json.toString())
        );
    }
View Full Code Here

    }

    @Override
    public DataPoint<ConnectionPool> collect() throws Exception {
        Response clientResponse = getResponse(constructResourceString());
        JsonObject response = clientResponse.readEntity(JsonObject.class);
        JsonObject entity = response.getJsonObject("extraProperties").
                getJsonObject("entity");

        int numconnfree = getIntVal(entity, "numconnfree", "current");
        int numconnused = getIntVal(entity, "numconnused", "current");
        int waitqueuelength = getIntVal(entity, "waitqueuelength", "count");
View Full Code Here

    @Test
    public void startStopPollingWithoutLocation() {
        final int INTERVAL_VALUE = 5;
        //activation
        JsonObject interval = Json.createObjectBuilder().add("interval", INTERVAL_VALUE).build();
        Response response = super.mainTarget.request().post(Entity.json(interval));
        Assert.assertThat(response.getStatus(), is(200));
        JsonObject jsonObject = response.readEntity(JsonObject.class);
        String nextTimeout = jsonObject.getString("nextTimeout");
        Assert.assertNotNull(nextTimeout);
        //status
        response = super.mainTarget.request().get();
        Assert.assertThat(response.getStatus(), is(200));
        JsonObject status = response.readEntity(JsonObject.class);
        nextTimeout = status.getString("nextTimeout");
        assertNotNull(nextTimeout);
        String currentInterval = status.getString("interval");
        assertNotNull(currentInterval, is(Integer.parseInt(currentInterval)));
        //stop
        response = super.mainTarget.request().delete();
        Assert.assertThat(response.getStatus(), is(204));
View Full Code Here

    @Asynchronous
    public void distributeMessage() {
        for (Map.Entry<String, CopyOnWriteArraySet<Session>> entry : sessions.entrySet()) {
            String applicationName = entry.getKey();
            JsonObject beanStatistics = applicationMonitoring.getBeanStatistics(applicationName);
            CopyOnWriteArraySet<Session> value = entry.getValue();
            for (Session session : value) {
                if (session != null && session.isOpen()) {
                    session.getAsyncRemote().sendText(beanStatistics.toString());
                }

            }
        }
    }
View Full Code Here

        super.init(URI);
    }

    @Test
    public void fetchVersionAndUptime() {
        JsonObject serverInfo = super.mainTarget.request().get(JsonObject.class);
        Assert.assertNotNull(serverInfo);
        String version = serverInfo.getString("version");
        assertNotNull(version);
        String uptime = serverInfo.getString("uptime");
        assertNotNull(uptime);
    }
View Full Code Here

        assertNotNull(uptime);
    }

    @Test
    public void fetchLightFishInfo() {
        JsonObject lightfishInfo = super.mainTarget.path("lightfish").request().get(JsonObject.class);
        System.out.println("-- " + lightfishInfo);
        assertNotNull(lightfishInfo);
    }
View Full Code Here

TOP

Related Classes of javax.json.JsonObject

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.