Search in sources :

Example 1 with GsonPersistedDataArray

use of org.terasology.persistence.typeHandling.gson.GsonPersistedDataArray in project Terasology by MovingBlocks.

the class ColorTypeHandlerTest method testDeserializeArray.

@Test
public void testDeserializeArray() {
    JsonArray array = new Gson().fromJson("[12, 34, 56, 78]", JsonArray.class);
    PersistedData data = new GsonPersistedDataArray(array);
    Color color = handler.deserialize(data, deserializationContext);
    Assert.assertEquals(12, color.r());
    Assert.assertEquals(34, color.g());
    Assert.assertEquals(56, color.b());
    Assert.assertEquals(78, color.a());
}
Also used : JsonArray(com.google.gson.JsonArray) Color(org.terasology.rendering.nui.Color) Gson(com.google.gson.Gson) PersistedData(org.terasology.persistence.typeHandling.PersistedData) GsonPersistedDataArray(org.terasology.persistence.typeHandling.gson.GsonPersistedDataArray) Test(org.junit.Test)

Aggregations

Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 Test (org.junit.Test)1 PersistedData (org.terasology.persistence.typeHandling.PersistedData)1 GsonPersistedDataArray (org.terasology.persistence.typeHandling.gson.GsonPersistedDataArray)1 Color (org.terasology.rendering.nui.Color)1