| | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayInputStream; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| | | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | | |
| | |
| | | assertNoLargeLightGrayBackground(stacked); |
| | | } |
| | | |
| | | @Test |
| | | void rendersHigherPrecisionLineLabelsWhenRequested() { |
| | | HolidayTrendChartService service = new HolidayTrendChartService(); |
| | | HolidayTrendChartService.ChartSeries congestion = new HolidayTrendChartService.ChartSeries(); |
| | | congestion.setName("平均拥挤度"); |
| | | congestion.setValues(java.util.Arrays.asList( |
| | | new java.math.BigDecimal("0.467029"), |
| | | new java.math.BigDecimal("0.490890"), |
| | | new java.math.BigDecimal("0.492414"))); |
| | | |
| | | byte[] twoDecimals = service.lineChart("拥挤度", |
| | | java.util.Collections.singletonList(congestion), false, 2, 1100, 590); |
| | | byte[] threeDecimals = service.lineChart("拥挤度", |
| | | java.util.Collections.singletonList(congestion), false, 3, 1100, 590); |
| | | |
| | | assertPng(twoDecimals); |
| | | assertPng(threeDecimals); |
| | | assertFalse(java.util.Arrays.equals(twoDecimals, threeDecimals)); |
| | | } |
| | | |
| | | private void assertNoLargeLightGrayBackground(byte[] data) throws Exception { |
| | | BufferedImage image = ImageIO.read(new ByteArrayInputStream(data)); |
| | | int matches = 0; |