Add test for Gson @SerializedName support

This commit is contained in:
Moandji Ezana 2017-08-05 16:37:18 +02:00
parent 4d206e4af6
commit 8394400b2d
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package com.moandjiezana.toml;
import static org.junit.Assert.assertEquals;
import java.io.File;
import org.junit.Test;
import com.google.gson.annotations.SerializedName;
import com.moandjiezana.toml.testutils.Utils;
public class GsonAnnotationTest {
@Test
public void should_support_SerializedName() throws Exception {
File file = Utils.file(getClass(), "/GsonAnnotationTest/should_support_SerializedName");
GsonAnnotated toml = new Toml().read(file).to(GsonAnnotated.class);
assertEquals("khfdaiq32-fd12-8420-2214-kafdli4328", toml.nodeId);
assertEquals("3", toml.engineVersion);
}
private static class GsonAnnotated {
@SerializedName("node-id")
private String nodeId;
@SerializedName("engine_version")
private String engineVersion;
}
}

View file

@ -0,0 +1,2 @@
node-id = "khfdaiq32-fd12-8420-2214-kafdli4328"
engine_version = "3"