@Test public void testSerialize() throws Exception { GameObjectInstanceAddedToSceneCondition theCondition = new GameObjectInstanceAddedToSceneCondition(); GameObject theObject = mock(GameObject.class); Property theUUIDProperty = mock(Property.class); when(theUUIDProperty.get()).thenReturn("UUID"); when(theObject.uuidProperty()).thenReturn(theUUIDProperty); GameObjectInstance theInstance = mock(GameObjectInstance.class); when(theInstance.getOwnerGameObject()).thenReturn(theObject); Map<String, Object> theData = theCondition.serialize(); assertEquals(1, theData.size()); assertEquals(GameObjectInstanceAddedToSceneCondition.TYPE_VALUE, theData.get(GameObjectInstanceAddedToSceneCondition.TYPE_ATTRIBUTE)); theCondition.gameObjectProperty().set(theObject); theData = theCondition.serialize(); assertEquals(2, theData.size()); assertEquals(GameObjectInstanceAddedToSceneCondition.TYPE_VALUE, theData.get(GameObjectInstanceAddedToSceneCondition.TYPE_ATTRIBUTE)); assertEquals("UUID", theData.get("objectUUID")); }
@Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put(TYPE_ATTRIBUTE, TYPE_VALUE); GameObject theObject = gameObject.get(); if (theObject != null) { theResult.put("objectUUID", theObject.uuidProperty().get()); } return theResult; }
GameObjectInstanceAddedToSceneCondition implements Condition { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put(TYPE_ATTRIBUTE, TYPE_VALUE); GameObject theObject = gameObject.get(); if (theObject != null) { theResult.put("objectUUID", theObject.uuidProperty().get()); } return theResult; } }
GameObjectInstanceAddedToSceneCondition implements Condition { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put(TYPE_ATTRIBUTE, TYPE_VALUE); GameObject theObject = gameObject.get(); if (theObject != null) { theResult.put("objectUUID", theObject.uuidProperty().get()); } return theResult; } @UsedByReflection  GameObjectInstanceAddedToSceneCondition(); }
GameObjectInstanceAddedToSceneCondition implements Condition { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put(TYPE_ATTRIBUTE, TYPE_VALUE); GameObject theObject = gameObject.get(); if (theObject != null) { theResult.put("objectUUID", theObject.uuidProperty().get()); } return theResult; } @UsedByReflection  GameObjectInstanceAddedToSceneCondition(); Property<GameObject> gameObjectProperty(); @Override ConditionResult appliesTo(GameScene aScene, GameEvent aEvent); @Override Map<String, Object> serialize(); static GameObjectInstanceAddedToSceneCondition unmarshall(GameScene aGameScene, Map<String, Object> aSerializedData); }
GameObjectInstanceAddedToSceneCondition implements Condition { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put(TYPE_ATTRIBUTE, TYPE_VALUE); GameObject theObject = gameObject.get(); if (theObject != null) { theResult.put("objectUUID", theObject.uuidProperty().get()); } return theResult; } @UsedByReflection  GameObjectInstanceAddedToSceneCondition(); Property<GameObject> gameObjectProperty(); @Override ConditionResult appliesTo(GameScene aScene, GameEvent aEvent); @Override Map<String, Object> serialize(); static GameObjectInstanceAddedToSceneCondition unmarshall(GameScene aGameScene, Map<String, Object> aSerializedData); static final String GAME_OBJECT_PROPERTY; }