Skip to content

Commit e12fc68

Browse files
committed
Fixing review comments
1 parent d3a2b86 commit e12fc68

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/main/java/com/capgemini/training/appointmentbooking/dataaccess/entity/AppointmentEntity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.capgemini.training.appointmentbooking.dataaccess.entity;
22

33
import java.time.Instant;
4+
import java.util.Objects;
45

56
import com.capgemini.training.appointmentbooking.common.datatype.AppointmentStatus;
67

@@ -44,4 +45,24 @@ public class AppointmentEntity extends BaseEntity {
4445
@Enumerated(EnumType.STRING)
4546
private AppointmentStatus status;
4647

48+
@Override
49+
public void prePersist() {
50+
super.prePersist();
51+
validateDates();
52+
}
53+
54+
@Override
55+
public void preUpdate() {
56+
super.preUpdate();
57+
validateDates();
58+
}
59+
60+
private void validateDates() {
61+
Objects.requireNonNull(this.dateTime);
62+
Objects.requireNonNull(this.endsAt);
63+
if(!this.endsAt.isAfter(this.dateTime))
64+
{
65+
throw new IllegalStateException(String.format("Starting date: %s must be before end date: %s", this.dateTime, this.endsAt));
66+
}
67+
}
4768
}

src/main/resources/application.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ spring.application.name=appointment-booking-app
22

33
spring.h2.console.enabled=true
44

5-
spring.datasource.url=jdbc:h2:mem:appointmentbooking;
5+
spring.datasource.url=jdbc:h2:mem:appointmentbooking
66
spring.datasource.username=sa
77
spring.datasource.password=password
88

@@ -14,4 +14,6 @@ spring.flyway.locations=classpath:db/migration
1414
spring.flyway.enabled=true
1515
spring.flyway.clean-on-validation-error=true
1616

17-
spring.jpa.hibernate.ddl-auto=none
17+
spring.jpa.hibernate.ddl-auto=none
18+
19+
spring.banner.location=classpath:/banner/jbf_banner.txt
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
,--. ,-----. ,--. ,--. ,------. ,--. ,--. ,--.
2+
| | ,--,--.,--. ,--.,--,--. | |) /_ ,--,--.,---.| |,-. ,---. ,--,--, ,-| | | .---',--.,--.,--,--, ,-| | ,--,--.,-' '-.`--' ,---. ,--,--,
3+
,--. | |' ,-. | \ `' /' ,-. | | .-. \' ,-. | .--'| /| .-. :| \' .-. | | `--, | || || \' .-. |' ,-. |'-. .-',--.| .-. || \
4+
| '-' /\ '-' | \ / \ '-' | | '--' /\ '-' \ `--.| \ \\ --.| || |\ `-' | | |` ' '' '| || |\ `-' |\ '-' | | | | |' '-' '| || |
5+
`-----' `--`--' `--' `--`--' `------' `--`--'`---'`--'`--'`----'`--''--' `---' `--' `----' `--''--' `---' `--`--' `--' `--' `---' `--''--'
6+
7+
${application.title} ${application.version}
8+
Powered by Spring Boot ${spring-boot.version}

0 commit comments

Comments
 (0)