use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.
the class ProtobufResourceTest method checkListProtobufEndpointUrl.
private void checkListProtobufEndpointUrl(String fileName, String errorMessage) {
RestSchemaClient schemaClient = client.schemas();
RestResponse response = join(schemaClient.names());
Json jsonNode = Json.read(response.getBody());
assertEquals(1, jsonNode.asList().size());
assertEquals(fileName, jsonNode.at(0).at("name").asString());
assertEquals("Schema error.proto has errors", jsonNode.at(0).at("error").at("message").asString());
assertEquals(errorMessage, jsonNode.at(0).at("error").at("cause").asString());
}
use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.
the class ProtobufResourceTest method addAndGetListOrderedByName.
@Test
public void addAndGetListOrderedByName() throws Exception {
RestSchemaClient schemaClient = client.schemas();
String personProto = getResourceAsString("person.proto", getClass().getClassLoader());
join(schemaClient.post("users", personProto));
join(schemaClient.post("people", personProto));
join(schemaClient.post("dancers", personProto));
RestResponse response = join(schemaClient.names());
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(response.getBody());
assertEquals(3, jsonNode.asList().size());
assertEquals("dancers.proto", jsonNode.at(0).at("name").asString());
assertEquals("people.proto", jsonNode.at(1).at("name").asString());
assertEquals("users.proto", jsonNode.at(2).at("name").asString());
}
use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.
the class MultiResourceTest method getProtobuf.
private String getProtobuf(String name) {
RestSchemaClient schemas = client.schemas();
RestResponse response = join(schemas.get(name));
ResponseAssertion.assertThat(response).isOk();
return response.getBody();
}
use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.
the class MultiResourceTest method createSchema.
private void createSchema(String name, String value) throws Exception {
RestSchemaClient schemas = client.schemas();
RestResponse response = join(schemas.put(name, value));
ResponseAssertion.assertThat(response).isOk();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(response.getBody());
assertEquals("null", jsonNode.get("error").asText());
}
use of org.infinispan.client.rest.RestSchemaClient in project infinispan by infinispan.
the class ProtobufResourceTest method crudSchema.
@Test
public void crudSchema() throws Exception {
RestSchemaClient schemaClient = client.schemas();
String personProto = getResourceAsString("person.proto", getClass().getClassLoader());
// Create
RestResponse response = join(schemaClient.post("person", personProto));
ResponseAssertion.assertThat(response).isOk();
Json jsonNode = Json.read(response.getBody());
assertTrue(jsonNode.at("error").isNull());
// Read
response = join(schemaClient.get("person"));
ResponseAssertion.assertThat(response).isOk();
ResponseAssertion.assertThat(response).hasContentEqualToFile("person.proto");
// Read adding .proto should also work
response = join(schemaClient.get("person.proto"));
ResponseAssertion.assertThat(response).isOk();
ResponseAssertion.assertThat(response).hasContentEqualToFile("person.proto");
// Update
response = join(schemaClient.put("person", personProto));
ResponseAssertion.assertThat(response).isOk();
// Delete
response = join(schemaClient.delete("person"));
ResponseAssertion.assertThat(response).isOk();
response = join(schemaClient.get("person"));
ResponseAssertion.assertThat(response).isNotFound();
}
Aggregations