### Question:
CharacterSlot { public JsonObject toJson () { JsonObject json = new JsonObject(); json.put("cid", this.cid); json.put("name", this.name); json.put("gender", this.gender.toString().toLowerCase()); json.put(TEXT_SKINCOLOR, this.skinColor); json.put(TEXT_HAIRCOLOR, this.hairColor); json.put(TEXT_HAIRSTYLE, this.hairStyle); json.put(TEXT_BEART, this.beart); return json; } CharacterSlot(final int cid, final String name, final GENDER gender, String skinColor, String hairColor, String hairStyle, String beart); int getCID(); String getName(); GENDER getGender(); String getSkinColor(); String getHairColor(); String getHairStyle(); String getBeart(); JsonObject toJson(); static CharacterSlot createDummyMaleCharacterSlot(); static CharacterSlot createDummyFemaleCharacterSlot(); static CharacterSlot createFromJson(int cid, String name, JsonObject json); static CharacterSlot create(String name, GENDER gender, String skinColor, String hairColor, String hairStyle, String beart); static final String TEXT_SKINCOLOR; static final String TEXT_HAIRCOLOR; static final String TEXT_HAIRSTYLE; static final String TEXT_BEART; }### Answer:
@Test public void testMaleCharacterToJson () { CharacterSlot slot = new CharacterSlot(10, "name", CharacterSlot.GENDER.MALE, "skinColor", "hairColor", "hairStyle", "beart"); JsonObject json = slot.toJson(); assertEquals(new Integer(10), json.getInteger("cid")); assertEquals("name", json.getString("name")); assertEquals("male", json.getString("gender")); assertEquals("skinColor", json.getString("skinColor")); assertEquals("hairColor", json.getString("hairColor")); assertEquals("hairStyle", json.getString("hairStyle")); assertEquals("beart", json.getString("beart")); }
@Test public void testFemaleCharacterToJson () { CharacterSlot slot = new CharacterSlot(10, "name", CharacterSlot.GENDER.FEMALE, "skinColor", "hairColor", "hairStyle", "beart"); JsonObject json = slot.toJson(); assertEquals(new Integer(10), json.getInteger("cid")); assertEquals("name", json.getString("name")); assertEquals("female", json.getString("gender")); assertEquals("skinColor", json.getString("skinColor")); assertEquals("hairColor", json.getString("hairColor")); assertEquals("hairStyle", json.getString("hairStyle")); assertEquals("beart", json.getString("beart")); }