forked from vaadin/flow-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mark
DataSeriesItemSankey
as customized to ensure its proper s…
…erialization (vaadin#6216) Without this call, the object would be serialized as an array containing two value from `bean.getLow()` and `bean.getHigh()`, which are not usually set on the Sankey type, so the result would be `[null, null]`, instead of the actual JSON string expected (containing the `from`, `to`, and `weight` keys). The Sankey example in the IT works because it uses `setDataLabels`, which in turn calls `makeCustomized` and then makes the instance to be proper serialized.
- Loading branch information
1 parent
505255e
commit c67cb2c
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...-flow/src/test/java/com/vaadin/flow/component/charts/DataSeriesItemSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.vaadin.flow.component.charts; | ||
|
||
import com.vaadin.flow.component.charts.model.DataSeriesItem; | ||
import com.vaadin.flow.component.charts.model.DataSeriesItemSankey; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static com.vaadin.flow.component.charts.util.ChartSerialization.toJSON; | ||
|
||
/** | ||
* Tests for the serialization of custom data series items extending | ||
* {@link DataSeriesItem} | ||
*/ | ||
public class DataSeriesItemSerializationTest { | ||
@Test | ||
public void dataSeriesItemSankey_empty_toJSON() { | ||
var json = toJSON(new DataSeriesItemSankey()); | ||
Assert.assertEquals("{}", json); | ||
} | ||
|
||
@Test | ||
public void dataSeriesItemSankey_withValues_toJSON() { | ||
var item = new DataSeriesItemSankey("A", "B", 1); | ||
var json = toJSON(item); | ||
Assert.assertEquals("{\"from\":\"A\",\"to\":\"B\",\"weight\":1}", json); | ||
} | ||
} |