Commit 44d24761 authored by Andy Costanza's avatar Andy Costanza 📸

add UT and upgrade spring boot

parent 1942c5a1
Pipeline #161326064 passed with stage
in 5 minutes and 35 seconds
......@@ -101,7 +101,7 @@
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.10</version>
<version>1.5.2</version>
<executions>
<execution>
<id>mutation</id>
......@@ -115,7 +115,7 @@
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.10</version>
<version>0.12</version>
</dependency>
</dependencies>
<configuration>
......
package com.andycostanza.relveo.chart.service;
import com.andycostanza.relveo.chart.ChartContainer;
import org.junit.jupiter.api.Assertions;
import com.andycostanza.relveo.chart.ChartValue;
import com.andycostanza.relveo.electricity.ElectricityIndexStatement;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
import java.math.BigDecimal;
import java.sql.Date;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@DisplayName("ChartService implementation")
class ChartServiceImplTest {
ChartService service;
......@@ -25,7 +35,63 @@ class ChartServiceImplTest {
//when
List<ChartContainer> result = service.electricityConsumptionCalculator(null);
//then
Assertions.assertEquals(Collections.EMPTY_LIST, result);
assertEquals(Collections.EMPTY_LIST,
result);
}
@Test
void electricityConsumptionCalculatorTest20() {
//given
//when
LocalDate now = LocalDate.now();
java.util.Date today = Date.from(now.atStartOfDay(ZoneId.systemDefault())
.toInstant());
ElectricityIndexStatement statement1 = ElectricityIndexStatement.builder()
.statementDate(today)
.dayIndex(BigDecimal.valueOf(15D))
.nightIndex(BigDecimal.valueOf(5D))
.build();
java.util.Date todayPlus1Day = Date.from(now.plus(1,
ChronoUnit.DAYS)
.atStartOfDay(ZoneId.systemDefault())
.toInstant());
ElectricityIndexStatement statement2 = ElectricityIndexStatement.builder()
.statementDate(todayPlus1Day)
.dayIndex(BigDecimal.valueOf(20D))
.nightIndex(BigDecimal.valueOf(15D))
.build();
List<ChartContainer> result = service.electricityConsumptionCalculator(Arrays.asList(statement1,
statement2));
//then
assertAll("chart container list",
() -> assertNotNull(result),
() -> result.forEach(container -> {
org.assertj.core.api.Assertions.assertThat(container.getSeries())
.containsAnyOf(ChartValue.builder()
.name(todayPlus1Day.toString())
.value(BigDecimal.valueOf(5D))
.build(),
ChartValue.builder()
.name(todayPlus1Day.toString())
.value(BigDecimal.valueOf(10D))
.build(),
ChartValue.builder()
.name(todayPlus1Day.toString())
.value(BigDecimal.valueOf(15D))
.build());
}),
() -> org.assertj.core.api.Assertions.assertThat(result.get(0)
.getSeries())
.contains(ChartValue.builder()
.name(todayPlus1Day.toString())
.value(BigDecimal.valueOf(5D))
.build()),
() -> org.assertj.core.api.Assertions.assertThat(result.get(1)
.getSeries())
.contains(ChartValue.builder()
.name(todayPlus1Day.toString())
.value(BigDecimal.valueOf(10D))
.build()));
}
@Test
......@@ -34,7 +100,8 @@ class ChartServiceImplTest {
//when
List<ChartContainer> result = service.heatingConsumptionCalculator(null);
//then
Assertions.assertEquals(Collections.EMPTY_LIST, result);
assertEquals(Collections.EMPTY_LIST,
result);
}
@Test
......@@ -43,6 +110,7 @@ class ChartServiceImplTest {
//when
List<ChartContainer> result = service.waterConsumptionCalculator(null);
//then
Assertions.assertEquals(Collections.EMPTY_LIST, result);
assertEquals(Collections.EMPTY_LIST,
result);
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<version>2.2.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment