Search in sources :

Example 1 with InfluxDbDatabaseSettings

use of me.retrodaredevil.solarthing.config.databases.implementations.InfluxDbDatabaseSettings in project solarthing by wildmountainfarms.

the class DeserializeTest method testInfluxDb1.

@Test
void testInfluxDb1() throws JsonProcessingException {
    ObjectMapper mapper = JacksonUtil.defaultMapper();
    String json = "{\n" + "  \"type\": \"influxdb\",\n" + "  \"config\": {\n" + "    \"url\": \"http://localhost:8086\",\n" + "    \"username\": \"root\",\n" + "    \"password\": \"root\",\n" + "    \"database\": \"default_database\",\n" + "    \"measurement\": null,\n" + "\n" + "    \"status_retention_policies\": [\n" + "      {\n" + "        \"frequency\": 120,\n" + "        \"name\": \"autogen\"\n" + "      }\n" + "    ],\n" + "\n" + "    \"event_retention_policy\": {\n" + "      \"name\": \"autogen\"\n" + "    }\n" + "  }\n" + "}";
    mapper.registerSubtypes(DatabaseSettings.class, InfluxDbDatabaseSettings.class);
    DatabaseConfig config = mapper.readValue(json, DatabaseConfig.class);
    assertTrue(config.getSettings() instanceof InfluxDbDatabaseSettings);
}
Also used : InfluxDbDatabaseSettings(me.retrodaredevil.solarthing.config.databases.implementations.InfluxDbDatabaseSettings) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DatabaseConfig(me.retrodaredevil.solarthing.program.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InfluxDbDatabaseSettings (me.retrodaredevil.solarthing.config.databases.implementations.InfluxDbDatabaseSettings)1 DatabaseConfig (me.retrodaredevil.solarthing.program.DatabaseConfig)1 Test (org.junit.jupiter.api.Test)1