Skip to content

Commit

Permalink
feat: Implemented billable in TimeEntryTrackingService (Close #20)
Browse files Browse the repository at this point in the history
Key changes:
- Created `TimeBillingDTO` class.
- Modified `TimeEntry` domain.
- Modified unit tests.
  • Loading branch information
seyedali-dev committed May 14, 2024
1 parent f20d68c commit 6111d8e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
@RequiredArgsConstructor
public class AuthenticationServiceClient {

private @Value("${authentication.service.user-persistence-controller.base-url}") String authenticationServiceClient_BaseUrl;
private @Value("${authentication.service.user-persistence-controller.handle-user-url}") String authenticationServiceClient_HandleUserUrl;

private final WebClient.Builder webClientBuilder;
private final KeycloakSecurityUtil keycloakSecurityUtil;
private final ObjectMapper objectMapper;
private @Value("${authentication.service.user-persistence-controller.base-url}") String authenticationServiceClient_BaseUrl;
private @Value("${authentication.service.user-persistence-controller.handle-user-url}") String authenticationServiceClient_HandleUserUrl;
private WebClient webClient;

@PostConstruct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -58,13 +59,13 @@ class TimeEntryControllerTest {

@BeforeEach
void setUp() {
TimeEntryDTO timeEntryDTO = new TimeEntryDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", "02:00:00");
TimeEntryDTO timeEntryDTO = new TimeEntryDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", false, BigDecimal.ZERO.toString(), "02:00:00");
this.timeEntries.add(timeEntryDTO);

TimeSegmentDTO timeSegmentDTO = new TimeSegmentDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", "02:00:00", "01");
this.timeSegmentDTOList.add(timeSegmentDTO);

this.timeEntryResponse = new TimeEntryResponse("1", this.timeSegmentDTOList, "02:00:00");
this.timeEntryResponse = new TimeEntryResponse("1", this.timeSegmentDTOList, false, BigDecimal.ZERO.toString(), "02:00:00");
this.timeEntriesResponse.add(timeEntryResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TimeEntryTrackingControllerTest {

@BeforeEach
void setUp() {
TimeEntryDTO timeEntryDTO = new TimeEntryDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", "02:00:00");
TimeEntryDTO timeEntryDTO = new TimeEntryDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", false, BigDecimal.ZERO.toString(), "02:00:00");

this.timeEntries.add(timeEntryDTO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -114,7 +115,7 @@ void getUsersTimeEntry() {

@Test
public void addTimeEntryManuallyTest_WithDuration() {
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, this.durationStr);
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, false, BigDecimal.ZERO.toString(), this.durationStr);

when(this.timeParser.parseStringToLocalDateTime(this.startTimeStr))
.thenReturn(this.startTime);
Expand Down Expand Up @@ -147,7 +148,7 @@ public void addTimeEntryManuallyTest_WithDuration() {
@Test
public void addTimeEntryManuallyTest_WithoutDuration() {
// Given
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, null);
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, false, BigDecimal.ZERO.toString(), null);

when(this.timeParser.parseStringToLocalDateTime(this.startTimeStr))
.thenReturn(this.startTime);
Expand Down Expand Up @@ -177,7 +178,7 @@ public void addTimeEntryManuallyTest_WithoutDuration() {
public void updateTimeEntryTest() {
// Given
String id = "Some_timeEntry_id";
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, this.durationStr);
TimeEntryDTO timeEntryDTO = new TimeEntryDTO(null, this.startTimeStr, this.endTimeStr, false, BigDecimal.ZERO.toString(), this.durationStr);

when(this.timeEntryRepository.findById(id))
.thenReturn(Optional.of(this.timeEntry));
Expand Down

0 comments on commit 6111d8e

Please sign in to comment.