@Test public void scalarValueResults_serialize() { // make real 1 ScalarValueRealStruct struct1 = new ScalarValueRealStruct(); struct1.idx = 1; struct1.value = 2.0; ScalarValueReal scalarValueReal1 = new ScalarValueReal(struct1); // make real 2 ScalarValueRealStruct struct2 = new ScalarValueRealStruct(); struct2.idx = 2; struct2.value = 3.53; ScalarValueReal scalarValueReal2 = new ScalarValueReal(struct2); // make real list SerializableVector<ScalarValueReal> realList = new SerializableVector<ScalarValueReal>("ScalarValueReal"); realList.add(scalarValueReal1); realList.add(scalarValueReal2); // make bool 1 ScalarValueBooleanStruct structBool1 = new ScalarValueBooleanStruct(); structBool1.idx = 1; structBool1.value = true; ScalarValueBoolean scalarValueBool1 = new ScalarValueBoolean(structBool1); // make bool 2 ScalarValueBooleanStruct structBool2 = new ScalarValueBooleanStruct(); structBool1.idx = 2; structBool1.value = true; ScalarValueBoolean scalarValueBool2 = new ScalarValueBoolean(structBool2); // make bool list Vector<ScalarValueBoolean> boolList = new Vector<ScalarValueBoolean>(); boolList.add(scalarValueBool1); boolList.add(scalarValueBool2); // make ScalarValueCollection ScalarValueCollection scalarValueCollection1 = new ScalarValueCollection(); scalarValueCollection1.setRealList(realList); // scalarValueCollection1.setBooleanList(boolList); // make ScalarValueResults ScalarValueResults scalarValueResults = new ScalarValueResults(); scalarValueResults.setInput(scalarValueCollection1); scalarValueResults.setOutput(scalarValueCollection1); scalarValueResults.setTime(2.0); // serialize / deserialize String json_0 = scalarValueResults.serialize(); assertEquals( "{\"t\":\"ScalarValueResults\",\"time_\":2.0,\"input\":{\"t\":\"ScalarValueCollection\",\"realList\":[{\"t\":\"ScalarValueReal\",\"i\":1,\"v\":2.0},{\"t\":\"ScalarValueReal\",\"i\":2,\"v\":3.53}],\"booleanList\":[{\"t\":\"ScalarValueBoolean\",\"i\":1,\"v\":true},{\"t\":\"ScalarValueBoolean\",\"i\":0,\"v\":false}]},\"output\":{\"t\":\"ScalarValueCollection\",\"realList\":[{\"t\":\"ScalarValueReal\",\"i\":1,\"v\":2.0},{\"t\":\"ScalarValueReal\",\"i\":2,\"v\":3.53}],\"booleanList\":[{\"t\":\"ScalarValueBoolean\",\"i\":1,\"v\":true},{\"t\":\"ScalarValueBoolean\",\"i\":0,\"v\":false}]}}", json_0); }
@Test public void scalarValueResults_deserialize() { String jsonString_0 = "{\"t\":\"ScalarValueResults\",\"time_\":2.0,\"input\":{\"t\":\"ScalarValueCollection\",\"realList\":[{\"t\":\"ScalarValueReal\",\"i\":1,\"v\":2.0},{\"t\":\"ScalarValueReal\",\"i\":2,\"v\":3.53}],\"booleanList\":[{\"t\":\"ScalarValueBoolean\",\"i\":1,\"v\":true},{\"t\":\"ScalarValueBoolean\",\"i\":0,\"v\":false}]},\"output\":{\"t\":\"ScalarValueCollection\",\"realList\":[{\"t\":\"ScalarValueReal\",\"i\":1,\"v\":2.0},{\"t\":\"ScalarValueReal\",\"i\":2,\"v\":3.53}],\"booleanList\":[{\"t\":\"ScalarValueBoolean\",\"i\":1,\"v\":true},{\"t\":\"ScalarValueBoolean\",\"i\":0,\"v\":false}]}}"; Object deserializedObject_0 = gsonController_.fromJson(jsonString_0); assertEquals(ScalarValueResults.class, deserializedObject_0.getClass()); ScalarValueResults scalarValueResults_0 = (ScalarValueResults) deserializedObject_0; assertEquals(2.0, scalarValueResults_0.getTime(), 0.0); ScalarValueReal scalarValueReal_0 = scalarValueResults_0.getInput().getRealList().get(0); assertEquals(1, scalarValueReal_0.getIdx()); assertEquals(2.0, scalarValueReal_0.getValue(), 0.0); ScalarValueReal scalarValueReal_1 = scalarValueResults_0.getInput().getRealList().get(1); assertEquals(2, scalarValueReal_1.getIdx()); assertEquals(3.530, scalarValueReal_1.getValue(), 0.0); ScalarValueReal scalarValueReal_2 = scalarValueResults_0.getOutput().getRealList().get(0); assertEquals(1, scalarValueReal_2.getIdx()); assertEquals(2.0, scalarValueReal_2.getValue(), 0.0); ScalarValueReal scalarValueReal_3 = scalarValueResults_0.getOutput().getRealList().get(1); assertEquals(2, scalarValueReal_3.getIdx()); assertEquals(3.530, scalarValueReal_3.getValue(), 0.0); }