-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests. Create request validator. Controller return 400 code if…
… validation request is failed.
- Loading branch information
1 parent
401cfb4
commit b734632
Showing
5 changed files
with
170 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
@Data | ||
@Builder | ||
public class VacationResponse { | ||
private double totalPay; | ||
private Double totalPay; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.kepler.service; | ||
|
||
import com.kepler.model.VacationRequest; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ValidatorService { | ||
public boolean isRequestCorrect(VacationRequest request) { | ||
if (request.getAverageSalary() < 0) { | ||
return false; | ||
} | ||
|
||
if (request.getAverageSalary() == 0) { | ||
return false; | ||
} | ||
|
||
if (request.getVacationDays() < 0) { | ||
return false; | ||
} | ||
|
||
if (request.getVacationDays() == 0) { | ||
return false; | ||
} | ||
|
||
if (request.getStartDate() != null | ||
&& request.getEndDate() != null | ||
&& request.getStartDate().isAfter(request.getEndDate())) { | ||
return false; | ||
} | ||
|
||
if(request.getStartDate() != null && request.getEndDate() == null) { | ||
return false; | ||
} | ||
|
||
if(request.getEndDate() != null && request.getStartDate() == null) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters