Search in sources :

Example 1 with ChartOptions

use of com.vaadin.addon.charts.ChartOptions in project charts by vaadin.

the class ChartOptionsJSONSerializationTest method toJSON_LangWithFinnishLocale_LocaleSerialized_Months.

@Test
public void toJSON_LangWithFinnishLocale_LocaleSerialized_Months() throws IOException {
    final String[] fiMonths = new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" };
    final Lang fi = new Lang();
    fi.setMonths(fiMonths);
    options.setLang(fi);
    String json = toJSON(options);
    ObjectMapper om = ChartSerialization.createObjectMapper();
    ChartOptions chartOptions = om.readValue(json, ChartOptions.class);
    Assert.assertArrayEquals(fiMonths, chartOptions.getLang().getMonths());
}
Also used : Lang(com.vaadin.addon.charts.model.Lang) ChartOptions(com.vaadin.addon.charts.ChartOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with ChartOptions

use of com.vaadin.addon.charts.ChartOptions in project charts by vaadin.

the class ChartOptionsJSONSerializationTest method toJSON_LangWithFinnishLocale_LocaleSerialized_ShortMonths.

@Test
public void toJSON_LangWithFinnishLocale_LocaleSerialized_ShortMonths() throws IOException {
    final String[] fiShortMonths = new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" };
    final Lang fi = new Lang();
    fi.setShortMonths(fiShortMonths);
    options.setLang(fi);
    String json = toJSON(options);
    ObjectMapper om = ChartSerialization.createObjectMapper();
    ChartOptions fromJson = om.readValue(json, ChartOptions.class);
    Assert.assertArrayEquals(fiShortMonths, fromJson.getLang().getShortMonths());
}
Also used : Lang(com.vaadin.addon.charts.model.Lang) ChartOptions(com.vaadin.addon.charts.ChartOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with ChartOptions

use of com.vaadin.addon.charts.ChartOptions in project charts by vaadin.

the class ChartOptionsJSONSerializationTest method toJSON_LangWithFinnishLocale_LocaleSerialized_Days.

@Test
public void toJSON_LangWithFinnishLocale_LocaleSerialized_Days() throws IOException {
    final String[] fiDays = new String[] { "Ma", "Ti", "Ke", "To", "Pe", "La", "Su" };
    final Lang fi = new Lang();
    fi.setWeekdays(fiDays);
    options.setLang(fi);
    String json = toJSON(options);
    ObjectMapper om = ChartSerialization.createObjectMapper();
    ChartOptions chartOptions = om.readValue(json, ChartOptions.class);
    Assert.assertArrayEquals(fiDays, chartOptions.getLang().getWeekdays());
}
Also used : Lang(com.vaadin.addon.charts.model.Lang) ChartOptions(com.vaadin.addon.charts.ChartOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ChartOptions (com.vaadin.addon.charts.ChartOptions)3 Lang (com.vaadin.addon.charts.model.Lang)3 Test (org.junit.Test)3