Skip to content

Commit af83cf5

Browse files
author
Piotr Kubicki
committed
feat: add spotless, change name from EntitySmokeTest to EntitySmokeIT, cleanup
1 parent 919eea7 commit af83cf5

File tree

11 files changed

+94
-83
lines changed

11 files changed

+94
-83
lines changed

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@
124124
<aggregate>true</aggregate>
125125
</configuration>
126126
</plugin>
127+
<plugin>
128+
<groupId>com.diffplug.spotless</groupId>
129+
<artifactId>spotless-maven-plugin</artifactId>
130+
<version>2.43.0</version>
131+
<configuration>
132+
<java>
133+
<removeUnusedImports/>
134+
<eclipse/>
135+
</java>
136+
</configuration>
137+
<executions>
138+
<execution>
139+
<goals>
140+
<goal>check</goal>
141+
</goals>
142+
</execution>
143+
</executions>
144+
</plugin>
127145
</plugins>
128146
</build>
129147

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.capgemini.training.appointmentbooking.common.datatype;
22

33
public enum AppointmentStatus {
4-
SCHEDULED, CANCELLED, COMPLETED;
4+
SCHEDULED, CANCELLED, COMPLETED
55
}
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
package com.capgemini.training.appointmentbooking.common.datatype;
22

3+
import lombok.Getter;
4+
5+
@Getter
36
public enum Specialization {
4-
5-
DENTIST("Dentist"),
6-
CARDIOLOGIST("Cardiologist"),
7-
PEDIATRICIAN("Pediatrician"),
8-
UROLOGIST("Urologist"),
9-
NEUROLOGIST("Neurologist"),
10-
ORTHOPAEDIST("Orthopaedist");
11-
12-
private String name;
13-
14-
private Specialization(String name) {
7+
8+
DENTIST("Dentist"), CARDIOLOGIST("Cardiologist"), PEDIATRICIAN("Pediatrician"), UROLOGIST("Urologist"), NEUROLOGIST(
9+
"Neurologist"), ORTHOPAEDIST("Orthopaedist");
10+
11+
private final String name;
12+
13+
Specialization(String name) {
1514
this.name = name;
1615
}
1716

18-
public String getName() {
19-
return this.name;
20-
}
21-
22-
public static Specialization getByName(String name) {
17+
public static Specialization getByName(String name) {
2318

2419
for (Specialization s : Specialization.values()) {
2520
if (s.getName().equals(name)) {
@@ -28,5 +23,5 @@ public static Specialization getByName(String name) {
2823
}
2924
return null;
3025
}
31-
26+
3227
}

src/main/java/com/capgemini/training/appointmentbooking/dataaccess/converter/SpecializationConverter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ public class SpecializationConverter implements AttributeConverter<Specializatio
99

1010
@Override
1111
public String convertToDatabaseColumn(Specialization specialization) {
12-
12+
1313
return specialization != null ? specialization.getName() : null;
14-
14+
1515
}
1616

1717
@Override
18-
public Specialization convertToEntityAttribute(String dbData) {
19-
if (dbData == null) {
20-
return null;
21-
}
22-
return Specialization.getByName(dbData);
23-
}
18+
public Specialization convertToEntityAttribute(String dbData) {
19+
if (dbData == null) {
20+
return null;
21+
}
22+
return Specialization.getByName(dbData);
23+
}
2424

2525
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
import lombok.Setter;
2020

2121
@Entity
22-
@Table(name="APPOINTMENT")
22+
@Table(name = "APPOINTMENT")
2323
@Getter
2424
@Setter
2525
public class AppointmentEntity extends BaseEntity {
26-
26+
2727
@Id
2828
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "APPOINTMENT_SEQ_GEN")
29-
@SequenceGenerator(sequenceName = "APPOINTMENT_SEQ", name = "APPOINTMENT_SEQ_GEN", allocationSize = 100, initialValue = 1)
29+
@SequenceGenerator(sequenceName = "APPOINTMENT_SEQ", name = "APPOINTMENT_SEQ_GEN", allocationSize = 100)
3030
private Long id;
31-
31+
3232
@ManyToOne(fetch = FetchType.LAZY)
3333
private ClientEntity client;
34-
34+
3535
@ManyToOne(fetch = FetchType.LAZY)
3636
private TreatmentEntity treatment;
37-
38-
@Column(name="DATE_TIME")
37+
38+
@Column(name = "DATE_TIME")
3939
private Instant dateTime;
40-
40+
4141
@Enumerated(EnumType.STRING)
4242
private AppointmentStatus status;
43-
43+
4444
}

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

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

33
import java.time.Instant;
4-
import java.util.Date;
54

65
import jakarta.persistence.Column;
76
import jakarta.persistence.MappedSuperclass;
@@ -14,24 +13,24 @@
1413
@MappedSuperclass
1514
@Getter
1615
public class BaseEntity {
17-
16+
1817
@Version
1918
@Setter
2019
private int version;
2120

22-
@Column(insertable = true, updatable = false)
21+
@Column(updatable = false)
2322
private Instant created;
24-
25-
@Column(name="LAST_UPDATED")
23+
24+
@Column(name = "LAST_UPDATED")
2625
private Instant lastUpdated;
27-
26+
2827
@PrePersist
2928
public void prePersist() {
3029
Instant now = Instant.now();
3130
this.created = now;
3231
this.lastUpdated = now;
3332
}
34-
33+
3534
@PreUpdate
3635
public void preUpdate() {
3736
this.lastUpdated = Instant.now();

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@
1616
import lombok.Setter;
1717

1818
@Entity
19-
@Table(name="CLIENT")
19+
@Table(name = "CLIENT")
2020
@Getter
2121
@Setter
22-
public class ClientEntity extends BaseEntity {
23-
22+
public class ClientEntity extends BaseEntity {
23+
2424
@Id
2525
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CLIENT_SEQ_GEN")
26-
@SequenceGenerator(sequenceName = "CLIENT_SEQ", name = "CLIENT_SEQ_GEN", allocationSize = 100, initialValue = 1)
26+
@SequenceGenerator(sequenceName = "CLIENT_SEQ", name = "CLIENT_SEQ_GEN", allocationSize = 100)
2727
private Long id;
28-
29-
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
28+
29+
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
3030
private UserEntity user;
31-
32-
@OneToMany(mappedBy = "client", fetch = FetchType.LAZY, orphanRemoval=true, cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
31+
32+
@OneToMany(mappedBy = "client", fetch = FetchType.LAZY, orphanRemoval = true, cascade = {CascadeType.PERSIST,
33+
CascadeType.REMOVE})
3334
private List<AppointmentEntity> appointments;
34-
35+
3536
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@
2020
import lombok.Setter;
2121

2222
@Entity
23-
@Table(name="SPECIALIST")
23+
@Table(name = "SPECIALIST")
2424
@Getter
2525
@Setter
2626
public class SpecialistEntity extends BaseEntity {
2727

2828
@Id
2929
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SPECIALIST_SEQ_GEN")
30-
@SequenceGenerator(sequenceName = "SPECIALIST_SEQ", name = "SPECIALIST_SEQ_GEN", allocationSize = 100, initialValue = 1)
30+
@SequenceGenerator(sequenceName = "SPECIALIST_SEQ", name = "SPECIALIST_SEQ_GEN", allocationSize = 100)
3131
private Long id;
32-
33-
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
32+
33+
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
3434
private UserEntity user;
35-
35+
3636
@Convert(converter = SpecializationConverter.class)
3737
private Specialization specialization;
3838

39-
@OneToMany(mappedBy = "specialist", fetch = FetchType.LAZY, orphanRemoval = true, cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
39+
@OneToMany(mappedBy = "specialist", fetch = FetchType.LAZY, orphanRemoval = true, cascade = {CascadeType.PERSIST,
40+
CascadeType.REMOVE})
4041
private List<TreatmentEntity> treatments;
4142
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,25 @@
99
import jakarta.persistence.ManyToOne;
1010
import jakarta.persistence.SequenceGenerator;
1111
import jakarta.persistence.Table;
12-
import jakarta.persistence.Version;
1312
import lombok.Getter;
1413
import lombok.Setter;
1514

1615
@Entity
17-
@Table(name="TREATMENT")
16+
@Table(name = "TREATMENT")
1817
@Getter
1918
@Setter
2019
public class TreatmentEntity extends BaseEntity {
21-
20+
2221
@Id
2322
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TREATMENT_SEQ_GEN")
24-
@SequenceGenerator(sequenceName = "TREATMENT_SEQ", name = "TREATMENT_SEQ_GEN", allocationSize = 100, initialValue = 1)
23+
@SequenceGenerator(sequenceName = "TREATMENT_SEQ", name = "TREATMENT_SEQ_GEN", allocationSize = 100)
2524
private Long id;
26-
25+
2726
private String name;
28-
27+
2928
private String description;
30-
31-
@Column(name="DURATION_MINUTES")
29+
30+
@Column(name = "DURATION_MINUTES")
3231
private int durationMinutes;
3332

3433
@ManyToOne(fetch = FetchType.LAZY)

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@
77
import jakarta.persistence.Id;
88
import jakarta.persistence.SequenceGenerator;
99
import jakarta.persistence.Table;
10-
import jakarta.persistence.Version;
1110
import lombok.Getter;
1211
import lombok.Setter;
1312

1413
@Entity
15-
@Table(name="USER_TABLE")
14+
@Table(name = "USER_TABLE")
1615
@Getter
1716
@Setter
1817
public class UserEntity extends BaseEntity {
19-
18+
2019
@Id
2120
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_SEQ_GEN")
22-
@SequenceGenerator(sequenceName = "USER_SEQ", name = "USER_SEQ_GEN", allocationSize = 100, initialValue = 1)
21+
@SequenceGenerator(sequenceName = "USER_SEQ", name = "USER_SEQ_GEN", allocationSize = 100)
2322
private Long id;
24-
23+
2524
private String email;
26-
27-
@Column(name="PASSWORD_HASH")
25+
26+
@Column(name = "PASSWORD_HASH")
2827
private String passwordHash;
29-
30-
@Column(name="FIRST_NAME")
28+
29+
@Column(name = "FIRST_NAME")
3130
private String firstname;
32-
33-
@Column(name="LAST_NAME")
31+
32+
@Column(name = "LAST_NAME")
3433
private String lastname;
3534

3635
}

0 commit comments

Comments
 (0)