@Test
public void testHashornAPIBridge() throws Exception {

    ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
    InputStream is=getClass().getResourceAsStream("JsDeviceDriver0.js");
    engine.eval(new InputStreamReader(is));
    Invocable invocable = (Invocable) engine;
    invocable.invokeFunction("start");
    Object result = invocable.invokeFunction("readObservations");
    invocable.invokeFunction("stop");
    Date asOf = new Date();
    Set<Observation> set = new HashSet<>();
    ScriptObjectMirror som = (ScriptObjectMirror)result;
    if(som.isArray()) {
        Set<String> keys = som.keySet();
        for(String key: keys) {
            ScriptObjectMirror o = (ScriptObjectMirror) som.get(key);
            String code = (String) ((ScriptObjectMirror) o.get("valueQuantity")).get("code");
            Number value = (Number) ((ScriptObjectMirror) o.get("valueQuantity")).get("value");
            set.add(FhirDevice.createObservation(code, value.doubleValue(), asOf));
        }
    }
    Assert.assertTrue("Failed to populate dataset", set.size() != 0);
}