use of jakarta.json.JsonObject in project resteasy by resteasy.
the class JsonpResource method object.
@Path("structure")
@POST
@Produces("application/json")
@Consumes("application/json")
public JsonStructure object(JsonStructure struct) {
JsonObject obj = (JsonObject) struct;
Assert.assertTrue("The field 'name' didn't propagated correctly from the request", obj.containsKey("name"));
Assert.assertEquals("The value of field 'name' didn't propagated correctly from the request", obj.getJsonString("name").getString(), "Bill");
return obj;
}
use of jakarta.json.JsonObject in project resteasy by resteasy.
the class JsonpResource method array.
@Path("array")
@POST
@Produces("application/json")
@Consumes("application/json")
public JsonArray array(JsonArray array) {
Assert.assertEquals("The request didn't contain 2 json elements", 2, array.size());
JsonObject obj = array.getJsonObject(0);
Assert.assertTrue("The field 'name' didn't propagated correctly from the request for object[0]", obj.containsKey("name"));
Assert.assertEquals("The value of field 'name' didn't propagated correctly from the request for object[0]", obj.getJsonString("name").getString(), "Bill");
obj = array.getJsonObject(1);
Assert.assertTrue("The field 'name' didn't propagated correctly from the request for object[1]", obj.containsKey("name"));
Assert.assertEquals("The value of field 'name' didn't propagated correctly from the request for object[1]", obj.getJsonString("name").getString(), "Monica");
return array;
}
use of jakarta.json.JsonObject in project resteasy by resteasy.
the class AbstractDigestAuthenticationTest method digestAuthMultipleRequestsNoCache.
@Test
public void digestAuthMultipleRequestsNoCache() throws Exception {
try (Client client = ClientBuilder.newBuilder().register(HttpAuthenticators.digest(-1, CREDENTIALS_USER_1)).build()) {
Response response = client.target(TestUtil.generateUri(url, "user")).request(MediaType.APPLICATION_JSON_TYPE).get();
Assert.assertEquals(Response.Status.OK, response.getStatusInfo());
JsonObject json = response.readEntity(JsonObject.class);
validate(json, 1);
response = client.target(TestUtil.generateUri(url, "user")).request(MediaType.APPLICATION_JSON_TYPE).get();
Assert.assertEquals(Response.Status.OK, response.getStatusInfo());
json = response.readEntity(JsonObject.class);
validate(json, 1);
}
}
use of jakarta.json.JsonObject in project resteasy by resteasy.
the class AbstractDigestAuthenticationTest method digestAuth.
@Test
public void digestAuth() throws Exception {
try (Client client = ClientBuilder.newBuilder().register(HttpAuthenticators.digest(CREDENTIALS_USER_1)).build()) {
final Response response = client.target(TestUtil.generateUri(url, "user")).request(MediaType.APPLICATION_JSON_TYPE).get();
Assert.assertEquals(Response.Status.OK, response.getStatusInfo());
final JsonObject json = response.readEntity(JsonObject.class);
validate(json);
}
}
use of jakarta.json.JsonObject in project resteasy by resteasy.
the class AbstractDigestAuthenticationTest method digestAuthUser2.
@Test
public void digestAuthUser2() throws Exception {
try (Client client = ClientBuilder.newBuilder().register(HttpAuthenticators.digest(CREDENTIALS_USER_2)).build()) {
final Response response = client.target(TestUtil.generateUri(url, "user")).request(MediaType.APPLICATION_JSON_TYPE).get();
Assert.assertEquals(Response.Status.OK, response.getStatusInfo());
final JsonObject json = response.readEntity(JsonObject.class);
validate(USER_2, json, 1);
}
}
Aggregations