Эх сурвалжийг харах

Fixes in CensusEntry Validation

Andrew Grant 7 сар өмнө
parent
commit
41113896de

+ 1 - 0
src/main/java/scot/carricksoftware/grants/commands/census/CensusEntryCommandImpl.java

@@ -39,6 +39,7 @@ public class CensusEntryCommandImpl implements CensusEntryCommand {
 
     private String personalOccupation;
 
+
     public Long getId() {
         return id;
     }

+ 4 - 4
src/main/java/scot/carricksoftware/grants/validators/census/CensusEntryCommandValidatorImpl.java

@@ -34,8 +34,8 @@ public class CensusEntryCommandValidatorImpl implements CensusEntryCommandValida
     }
 
     private void validateAgeAndBirthDay(CensusEntryCommand censusEntryCommand, BindingResult bindingResult) {
-        if (censusEntryCommand.getBirthDay() != null) {
-            if (censusEntryCommand.getAge() != null) {
+        if (censusEntryCommand.getBirthDay() != null && !censusEntryCommand.getBirthDay().isEmpty()) {
+            if (censusEntryCommand.getAge() != null && !censusEntryCommand.getAge().isEmpty() ) {
                 bindingResult.rejectValue("birthDay", ApplicationConstants.EMPTY_STRING,
                         null,
                         ValidationConstants.BIRTH_DAY_AND_AGE_CANNOT_COEXIST);
@@ -48,8 +48,8 @@ public class CensusEntryCommandValidatorImpl implements CensusEntryCommandValida
     }
 
     private void validateAgeAndBirthYear(CensusEntryCommand censusEntryCommand, BindingResult bindingResult) {
-        if (censusEntryCommand.getBirthYear() != null) {
-            if (censusEntryCommand.getAge() != null) {
+        if (censusEntryCommand.getBirthYear() != null && !censusEntryCommand.getBirthYear().isEmpty()) {
+            if (censusEntryCommand.getAge() != null && !censusEntryCommand.getAge().isEmpty() ) {
                 bindingResult.rejectValue("birthYear", ApplicationConstants.EMPTY_STRING,
                         null,
                         ValidationConstants.BIRTH_YEAR_AND_AGE_CANNOT_COEXIST);

+ 1 - 1
src/main/resources/application.properties

@@ -2,7 +2,7 @@ spring.application.name=grants
 server.port=8086
 server.servlet.context-path=/grants
 spring.mvc.format.date=dd-MM-yyyy
-spring.profiles.active=uat
+spring.profiles.active=dev
 logging.level.scot.carricksoftware=debug
 
 

+ 1 - 0
src/test/java/scot/carricksoftware/grants/validators/census/CensusEntryCommandValidatorBirthYearAndAgeTest.java

@@ -49,6 +49,7 @@ class CensusEntryCommandValidatorBirthYearAndAgeTest {
         verify(bindingResultMock).rejectValue("age", ApplicationConstants.EMPTY_STRING, null, ValidationConstants.BIRTH_YEAR_AND_AGE_CANNOT_COEXIST);
     }
 
+
     @Test
     public void BirthDayAndAgeMustNotCoexistTest() {
         censusEntryCommand.setBirthDay("25/01");