-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…952) Because setSeries(...series) uses Arrays.asList to convert from array to List, one cannot call addSeries after calling setSeries(...series) since it throws a UnsupportedOperationException. Fix vaadin/vaadin-charts#515 Co-authored-by: Knoobie <[email protected]>
- Loading branch information
1 parent
68841c9
commit 7a7b53e
Showing
2 changed files
with
51 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
50 changes: 50 additions & 0 deletions
50
.../vaadin-charts-flow/src/test/java/com/vaadin/flow/component/charts/ConfigurationTest.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,50 @@ | ||
package com.vaadin.flow.component.charts; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.vaadin.flow.component.charts.model.Configuration; | ||
import com.vaadin.flow.component.charts.model.ListSeries; | ||
import com.vaadin.flow.component.charts.model.Series; | ||
|
||
/** | ||
* Tests for the {@link Configuration} | ||
* | ||
*/ | ||
public class ConfigurationTest { | ||
|
||
@Test(expected = Test.None.class) | ||
public void configurationSetSeriesWithArraysAsListTest() { | ||
Configuration conf = new Configuration(); | ||
|
||
conf.setSeries(Arrays.asList(new ListSeries())); | ||
conf.addSeries(new ListSeries()); | ||
|
||
assertEquals(conf.getSeries().size(), 2); | ||
} | ||
|
||
@Test | ||
public void configurationSetSeriesWithListShouldMakeShallowCopyTest() { | ||
Configuration conf = new Configuration(); | ||
|
||
List<Series> series = new ArrayList<>(); | ||
conf.setSeries(series); | ||
|
||
series.add(new ListSeries()); | ||
|
||
assertEquals(conf.getSeries().size(), 0); | ||
} | ||
|
||
@Test | ||
public void configuration_setSeriesAddSeries_noExceptions() { | ||
Configuration conf = new Configuration(); | ||
conf.setSeries(new ListSeries(), new ListSeries()); | ||
conf.addSeries(new ListSeries()); | ||
assertEquals(3, conf.getSeries().size()); | ||
} | ||
} |