use of me.retrodaredevil.solarthing.rest.graphql.solcast.SolcastConfig in project solarthing by wildmountainfarms.
the class GraphQLProviderTest method testGeneration.
@Test
void testGeneration() {
CouchDbDatabaseSettings couchDbDatabaseSettings = new CouchDbDatabaseSettings(new CouchPropertiesBuilder("http", "localhost", 5984, null, null).build(), new OkHttpPropertiesBuilder().build());
ObjectMapper mapper = JacksonUtil.defaultMapper();
// Use DefaultInstanceOptions.REQUIRE_NO_DEFAULTS while testing because first, we don't actually query any data,
// and second, we're trying to get rid of usages of DefaultInstanceOptions.DEFAULT_DEFAULT_INSTANCE_OPTIONS
CacheController cacheController = new CacheController(new CacheHandler(mapper, DefaultInstanceOptions.REQUIRE_NO_DEFAULTS, CouchDbUtil.createInstance(couchDbDatabaseSettings.getCouchProperties(), couchDbDatabaseSettings.getOkHttpProperties())));
GraphQLSchema schema = GraphQLProvider.createGraphQLSchemaGenerator(JacksonUtil.defaultMapper(), couchDbDatabaseSettings, DefaultInstanceOptions.REQUIRE_NO_DEFAULTS, new SolcastConfig(Collections.emptyMap()), cacheController).generate();
GraphQL.newGraphQL(schema).build();
}
use of me.retrodaredevil.solarthing.rest.graphql.solcast.SolcastConfig in project solarthing by wildmountainfarms.
the class GraphQLProvider method init.
@PostConstruct
public void init() {
try {
updateNonNull();
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
ObjectMapper objectMapper = JacksonUtil.defaultMapper();
SolcastConfig solcastConfig = null;
try {
solcastConfig = objectMapper.readValue(solcastFile, SolcastConfig.class);
} catch (JsonParseException | JsonMappingException e) {
throw new RuntimeException("Bad solcast JSON!", e);
} catch (IOException e) {
LOGGER.debug("No solcast config! Not using solcast!");
}
if (solcastConfig == null) {
solcastConfig = new SolcastConfig(Collections.emptyMap());
}
GraphQLSchema schema = createGraphQLSchemaGenerator(objectMapper, couchDbDatabaseSettings, defaultInstanceOptions, solcastConfig, cacheController).generate();
this.graphQL = GraphQL.newGraphQL(schema).defaultDataFetcherExceptionHandler(new SolarThingExceptionHandler()).build();
}
Aggregations