Search in sources :

Example 16 with ObjectMapper

use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.

the class GeoshapeTest method testGeoJsonCircleMissingRadius.

@Test
public void testGeoJsonCircleMissingRadius() throws IOException {
    assertThrows(IllegalArgumentException.class, () -> {
        GeoshapeSerializer s = new GeoshapeSerializer();
        Map json = new ObjectMapper().readValue("{\n" + "  \"type\": \"Feature\",\n" + "  \"geometry\": {\n" + "    \"type\": \"Circle\",\n" + "    \"coordinates\": [20.5, 10.5]\n" + "  },\n" + "  \"properties\": {\n" + "    \"name\": \"Dinagat Islands\"\n" + "  }\n" + "}", HashMap.class);
        s.convert(json);
    });
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 17 with ObjectMapper

use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.

the class ElasticsearchConfigTest method setup.

@BeforeEach
public void setup() throws Exception {
    httpClient = HttpClients.createDefault();
    host = new HttpHost(InetAddress.getByName(esr.getHostname()), esr.getPort());
    objectMapper = new ObjectMapper();
    IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("_template/template_1")));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpHost(org.apache.http.HttpHost) ObjectMapper(org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 18 with ObjectMapper

use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.

the class ElasticsearchIndexTest method prepareElasticsearch.

@BeforeAll
public static void prepareElasticsearch() throws Exception {
    httpClient = HttpClients.createDefault();
    objectMapper = new ObjectMapper();
    host = new HttpHost(InetAddress.getByName(esr.getHostname()), esr.getPort());
    IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("_ingest/pipeline/pipeline_1")));
    final HttpPut newPipeline = new HttpPut("_ingest/pipeline/pipeline_1");
    newPipeline.setHeader("Content-Type", "application/json");
    newPipeline.setEntity(new StringEntity("{\"description\":\"Test pipeline\",\"processors\":[{\"set\":{\"field\":\"" + STRING + "\",\"value\":\"hello\"}}]}", StandardCharsets.UTF_8));
    IOUtils.closeQuietly(httpClient.execute(host, newPipeline));
}
Also used : StringEntity(org.apache.http.entity.StringEntity) HttpDelete(org.apache.http.client.methods.HttpDelete) HttpHost(org.apache.http.HttpHost) ObjectMapper(org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper) HttpPut(org.apache.http.client.methods.HttpPut) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 19 with ObjectMapper

use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.

the class SerializerTest method jsonSerialization.

private <T extends JsonNode> void jsonSerialization(Class<T> type, String jsonContent) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    T jsonNode = type.cast(objectMapper.readTree(jsonContent));
    DataOutput out = serialize.getDataOutput(128);
    out.writeObjectNotNull(jsonNode);
    ReadBuffer b = out.getStaticBuffer().asReadBuffer();
    assertEquals(jsonNode, serialize.readObjectNotNull(b, type));
}
Also used : DataOutput(org.janusgraph.graphdb.database.serialize.DataOutput) ReadBuffer(org.janusgraph.diskstorage.ReadBuffer) ObjectMapper(org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper)

Example 20 with ObjectMapper

use of org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper in project janusgraph by JanusGraph.

the class ElasticSearchConfigTest method setup.

@Before
public void setup() throws Exception {
    esr = new ElasticsearchRunner();
    esr.start();
    httpClient = HttpClients.createDefault();
    host = new HttpHost(InetAddress.getByName(esr.getHostname()), ElasticsearchRunner.PORT);
    objectMapper = new ObjectMapper();
    IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("_template/template_1")));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpHost(org.apache.http.HttpHost) ObjectMapper(org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

ObjectMapper (org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper)35 HashMap (java.util.HashMap)26 Map (java.util.Map)26 Geoshape (org.janusgraph.core.attribute.Geoshape)14 Test (org.junit.Test)14 Test (org.junit.jupiter.api.Test)14 Coordinate (com.vividsolutions.jts.geom.Coordinate)4 Coordinate (org.locationtech.jts.geom.Coordinate)4 HttpHost (org.apache.http.HttpHost)3 HttpDelete (org.apache.http.client.methods.HttpDelete)3 LinearRing (com.vividsolutions.jts.geom.LinearRing)2 SimpleModule (org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule)2 Before (org.junit.Before)2 LinearRing (org.locationtech.jts.geom.LinearRing)2 JtsSpatialContext (org.locationtech.spatial4j.context.jts.JtsSpatialContext)2 IOException (java.io.IOException)1 List (java.util.List)1 UUID (java.util.UUID)1 Neo4jIndexHandler (nl.knaw.huygens.timbuctoo.database.tinkerpop.Neo4jIndexHandler)1 LogEntryFactory (nl.knaw.huygens.timbuctoo.databaselog.entry.LogEntryFactory)1