#502 - jsonContext.toJson(o, generator, path) can not apply path on @Transient field that is an entity bean

This commit is contained in:
Robin Bygrave committed 2016-01-13 13:29:06 +13:00
1 parent e2666f0c4c
commit 9665de2dbe
7 files changed
+188 -3

No files matched your search

@@ -2,12 +2,15 @@ package com.avaje.tests.json.include;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.config.JsonConfig;
import com.avaje.ebean.text.PathProperties;
import com.avaje.ebean.text.json.JsonWriteOptions;
import com.avaje.tests.json.transientproperties.EJsonTransientEntityList;
import com.avaje.tests.json.transientproperties.EJsonTransientList;
import org.junit.Test;
import java.util.ArrayList;
import static org.assertj.core.api.StrictAssertions.assertThat;
import static org.junit.Assert.assertEquals;
public class TestJsonExcludeTransientEmptyList {
@@ -45,4 +48,18 @@ public class TestJsonExcludeTransientEmptyList {
assertEquals(expectedJson, asJson);
}
@Test
public void testToJson_with_transientExcludeFromPathProperties() throws Exception {
EJsonTransientEntityList bean = new EJsonTransientEntityList();
bean.setId(99L);
bean.setName("John");
PathProperties pathProps = PathProperties.parse("id,name");
String asJson = Ebean.json().toJson(bean, pathProps);
assertThat(asJson).isEqualTo("{\"id\":99,\"name\":\"John\"}");
}
}