Search in sources :

Example 1 with SerialConfigBuilder

use of me.retrodaredevil.io.serial.SerialConfigBuilder in project solarthing by wildmountainfarms.

the class DeserializeTest method testAllIO.

@Test
void testAllIO() {
    ObjectMapper mapper = MAPPER.copy();
    InjectableValues.Std iv = new InjectableValues.Std();
    iv.addValue(SerialIOConfig.DEFAULT_SERIAL_CONFIG_KEY, new SerialConfigBuilder(9600));
    mapper.setInjectableValues(iv);
    for (File configFile : getJsonFiles(IO_CONFIG_DIRECTORY)) {
        try {
            mapper.readValue(configFile, IOConfig.class);
        } catch (IOException ex) {
            fail("Failed parsing config: " + configFile, ex);
        }
    }
    {
        // many users of SolarThing have come to rely on config_templates/io/default_linux_serial.json. Let's make sure it's always there for them
        File file = new File(IO_CONFIG_DIRECTORY, "default_linux_serial.json");
        assertTrue(file.exists(), "default_linux_serial.json doesn't exist!");
        try {
            mapper.readValue(file, IOConfig.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : IOException(java.io.IOException) SerialConfigBuilder(me.retrodaredevil.io.serial.SerialConfigBuilder) InjectableValues(com.fasterxml.jackson.databind.InjectableValues) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOConfig(me.retrodaredevil.solarthing.config.io.IOConfig) SerialIOConfig(me.retrodaredevil.solarthing.config.io.SerialIOConfig) Test(org.junit.jupiter.api.Test)

Aggregations

InjectableValues (com.fasterxml.jackson.databind.InjectableValues)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 IOException (java.io.IOException)1 SerialConfigBuilder (me.retrodaredevil.io.serial.SerialConfigBuilder)1 IOConfig (me.retrodaredevil.solarthing.config.io.IOConfig)1 SerialIOConfig (me.retrodaredevil.solarthing.config.io.SerialIOConfig)1 Test (org.junit.jupiter.api.Test)1