@Test public void scalarValueCollection_deserialize() { String jsonString_0 = "{\"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\":2,\"v\":false}]}"; Object deserializedObject_0 = gsonController_.fromJson(jsonString_0); assertEquals(ScalarValueCollection.class, deserializedObject_0.getClass()); ScalarValueCollection scalarValueCollection_0 = (ScalarValueCollection) deserializedObject_0; Vector<ScalarValueReal> realList = scalarValueCollection_0.getRealList(); ScalarValueReal scalarValueReal_0 = realList.get(0); assertEquals(1, scalarValueReal_0.getIdx()); assertEquals(2.0, scalarValueReal_0.getValue(), 0.0); ScalarValueReal scalarValueReal_1 = realList.get(1); assertEquals(2, scalarValueReal_1.getIdx()); assertEquals(3.53, scalarValueReal_1.getValue(), 0.0); // Vector<ScalarValueBoolean> boolList = scalarValueCollection_0.getBooleanList(); // // ScalarValueBoolean scalarValueBoolean_0 = boolList.get(0); // assertEquals(1, scalarValueBoolean_0.getIdx()); // assertEquals(false, scalarValueBoolean_0.getValue()); // // ScalarValueBoolean scalarValueBoolean_1 = boolList.get(1); // assertEquals(2, scalarValueBoolean_1.getIdx()); // assertEquals(false, scalarValueBoolean_1.getValue()); }
@Test public void scalarValueCollection_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); String json_0 = gsonController_.serialize(realList, Vector.class); assertEquals( "[{\"t\":\"ScalarValueReal\",\"i\":1,\"v\":2.0},{\"t\":\"ScalarValueReal\",\"i\":2,\"v\":3.53}]", json_0); // 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(); structBool2.idx = 2; structBool2.value = false; ScalarValueBoolean scalarValueBool2 = new ScalarValueBoolean(structBool2); // make bool list Vector<ScalarValueBoolean> boolList = new Vector<ScalarValueBoolean>(); boolList.add(scalarValueBool1); boolList.add(scalarValueBool2); String json_1 = gsonController_.serialize(boolList, Vector.class); assertEquals( "[{\"t\":\"ScalarValueBoolean\",\"i\":1,\"v\":true},{\"t\":\"ScalarValueBoolean\",\"i\":2,\"v\":false}]", json_1); ScalarValueCollection scalarValueCollection_0 = new ScalarValueCollection(realList); String json_2 = scalarValueCollection_0.serialize(); assertEquals( "{\"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\":2,\"v\":false}]}", json_2); }
@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); }