Skip to content

Commit

Permalink
bug: Modified tests for bean validation. (WIP) (Close #6)
Browse files Browse the repository at this point in the history
Implemented bean validation for `TimeEntryDTO` & `TimeBillingDTO`.

> Note: The tests are passing because we're providing null values for `TimeEntryDTO#hourlyRate`, whereas we should write tests for both scenarios.
  • Loading branch information
seyedali-dev committed May 17, 2024
1 parent e0cbf02 commit a3d44a1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.seyed.ali.timeentryservice.model.dto;

import com.seyed.ali.timeentryservice.annotation.OptionalField;
import com.seyed.ali.timeentryservice.model.domain.TimeEntry;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMax;
Expand All @@ -15,13 +14,11 @@
@Builder
public record TimeBillingDTO(
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "A flag determining this time entry is billable", example = "true")
@OptionalField
boolean billable,

@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "The hourly rate in BigDecimal format", example = "10.0")
@DecimalMin(value = "0.0", inclusive = false, message = "hourlyRate must be greater than 0")
@DecimalMax(value = "999.99", message = "hourlyRate must be less than 1000")
@OptionalField
BigDecimal hourlyRate
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void getUsersTimeEntryTest() throws Exception {
@Test
public void addTimeEntryManuallyTest() throws Exception {
// given
TimeEntryDTO timeEntryDTO = this.timeEntries.getFirst();
TimeEntryDTO timeEntryDTO = new TimeEntryDTO("1", "2024-05-11 08:00:00", "2024-05-11 10:00:00", false, null, "02:00:00");
String json = this.objectMapper.writeValueAsString(timeEntryDTO);
String responseMessage = "startTime(" + timeEntryDTO.startTime() + ") " +
" | endTime (" + timeEntryDTO.endTime() + ")" +
Expand Down

0 comments on commit a3d44a1

Please sign in to comment.