Package com.avaje.tests.text.json

Source Code of com.avaje.tests.text.json.TestJsonSomeEnumWithToString

package com.avaje.tests.text.json;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;

import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.text.json.JsonContext;
import com.avaje.tests.model.basic.SomeEnum;
import com.avaje.tests.model.basic.SomeEnumBean;

public class TestJsonSomeEnumWithToString extends BaseTestCase {

  @Test
  public void testJsonConversion() throws IOException {

    SomeEnumBean bean = new SomeEnumBean();
    bean.setId(100l);
    bean.setName("Some name");
    bean.setSomeEnum(SomeEnum.ALPHA);

    JsonContext json = Ebean.json();
    String jsonContent = json.toJson(bean);

    SomeEnumBean bean2 = json.toBean(SomeEnumBean.class, jsonContent);

    Assert.assertEquals(bean.getSomeEnum(), bean2.getSomeEnum());
    Assert.assertEquals(bean.getName(), bean2.getName());
    Assert.assertEquals(bean.getId(), bean2.getId());

  }

}
TOP

Related Classes of com.avaje.tests.text.json.TestJsonSomeEnumWithToString

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.