BAEL-5545: fixed timezone issue

This commit is contained in:
Elmar Mammadov 2022-07-08 16:17:37 +02:00
parent 0b5ffa01a7
commit e934c96f6d
1 changed files with 10 additions and 9 deletions

View File

@ -7,9 +7,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -55,15 +52,19 @@ class ProductServiceUnitTest {
.thenReturn(1, 3, 2, 0); .thenReturn(1, 3, 2, 0);
when(clock.instant()) when(clock.instant())
.thenReturn(Instant.parse("2022-04-09T10:15:30.00Z")); .thenReturn(Instant.parse("2022-04-09T10:15:30.00Z"));
when(clock.getZone())
.thenReturn(ZoneId.of("UTC"));
when(clock.millis()) when(clock.millis())
.thenReturn(100L,500L); .thenReturn(100L,500L);
when(clock.getZone())
.thenReturn(ZoneId.systemDefault());
long actualElapsedTime = productService.createProducts(2);
final long actualElapsedTime = productService.createProducts(2);
assertThat(actualElapsedTime) assertThat(actualElapsedTime)
.isEqualTo(400L); .isEqualTo(400L);
verify(productRepository,times(1)) verify(productRepository,times(1))
.saveAll(proArgumentCaptor.capture()); .saveAll(proArgumentCaptor.capture());
@ -71,8 +72,8 @@ class ProductServiceUnitTest {
.hasSize(2) .hasSize(2)
.extracting("title", "createdTs", "price") .extracting("title", "createdTs", "price")
.containsExactly( .containsExactly(
tuple("yacht", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("8539.99")), tuple("yacht", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("8539.99")),
tuple("car", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("88894")) tuple("car", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("88894"))
); );
} }
} }