Skip to content

Commit

Permalink
revert lombok usage and remove dependencies of micrometer and springdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
c5ms authored and orende committed Dec 13, 2024
1 parent 378886a commit ab90ed0
Show file tree
Hide file tree
Showing 20 changed files with 145 additions and 152 deletions.
73 changes: 6 additions & 67 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<version>3.3.6</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -119,6 +119,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand All @@ -140,70 +144,10 @@
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>

<!-- dev -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<!-- log monitor trace -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
<groupId>net.ttddyy.observation</groupId>
<artifactId>datasource-micrometer-spring-boot</artifactId>
<version>1.0.5</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency> <!-- Overridden version required for Java 11 -->
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
Expand All @@ -213,12 +157,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
</dependency>
<!-- doc -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import se.citerus.dddsample.domain.model.handling.HandlingHistory;

import java.lang.invoke.MethodHandles;
import java.util.Objects;

public class CargoInspectionServiceImpl implements CargoInspectionService {

Expand All @@ -32,7 +33,7 @@ public CargoInspectionServiceImpl(final ApplicationEvents applicationEvents,
@Override
@Transactional
public void inspectCargo(final TrackingId trackingId) {
Validate.notNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");

final Cargo cargo = cargoRepository.find(trackingId);
if (cargo == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package se.citerus.dddsample.config;

import com.pathfinder.api.GraphTraversalService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/se/citerus/dddsample/domain/model/cargo/Cargo.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package se.citerus.dddsample.domain.model.cargo;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang3.Validate;
import se.citerus.dddsample.domain.model.handling.HandlingHistory;
import se.citerus.dddsample.domain.model.location.Location;
import se.citerus.dddsample.domain.shared.DomainEntity;

import java.util.List;
import java.util.Objects;

/**
* A Cargo. This is the central class in the domain model,
Expand Down Expand Up @@ -49,8 +47,6 @@
*/
@Entity(name = "Cargo")
@Table(name = "Cargo")
@Setter(AccessLevel.PROTECTED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Cargo implements DomainEntity<Cargo> {

@Id
Expand All @@ -75,8 +71,8 @@ public class Cargo implements DomainEntity<Cargo> {
private Delivery delivery;

public Cargo(final TrackingId trackingId, final RouteSpecification routeSpecification) {
Validate.notNull(trackingId, "Tracking ID is required");
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");

this.trackingId = trackingId.idString();
// Cargo origin never changes, even if the route specification changes.
Expand All @@ -90,8 +86,8 @@ public Cargo(final TrackingId trackingId, final RouteSpecification routeSpecific
}

public Cargo(TrackingId trackingId, RouteSpecification routeSpecification, Itinerary itinerary) {
Validate.notNull(trackingId, "Tracking ID is required");
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");
this.trackingId = trackingId.idString();
this.origin = routeSpecification.origin();
this.routeSpecification = routeSpecification;
Expand Down Expand Up @@ -156,7 +152,7 @@ public RouteSpecification routeSpecification() {
* @param routeSpecification route specification.
*/
public void specifyNewRoute(final RouteSpecification routeSpecification) {
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");

this.routeSpecification = routeSpecification;
Itinerary itineraryForRouting = this.itinerary != null && !this.itinerary.isEmpty() ? new Itinerary(this.itinerary) : null;
Expand All @@ -170,7 +166,7 @@ public void specifyNewRoute(final RouteSpecification routeSpecification) {
* @param itinerary an itinerary. May not be null.
*/
public void assignToRoute(final Itinerary itinerary) {
Validate.notNull(itinerary, "Itinerary is required for assignment");
Objects.requireNonNull(itinerary, "Itinerary is required for assignment");

this.itinerary = itinerary.legs();
// Handling consistency within the Cargo aggregate synchronously
Expand Down Expand Up @@ -230,6 +226,8 @@ public String toString() {
return trackingId;
}


protected Cargo() {
// Needed by Hibernate
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package se.citerus.dddsample.domain.model.cargo;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
Expand All @@ -25,7 +23,6 @@
*
*/
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Delivery implements ValueObject<Delivery> {

@Column
Expand Down Expand Up @@ -76,7 +73,7 @@ public class Delivery implements ValueObject<Delivery> {
* @return An up to date delivery
*/
Delivery updateOnRouting(RouteSpecification routeSpecification, Itinerary itinerary) {
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");

return new Delivery(this.lastEvent, itinerary, routeSpecification);
}
Expand All @@ -91,8 +88,8 @@ Delivery updateOnRouting(RouteSpecification routeSpecification, Itinerary itiner
* @return An up to date delivery.
*/
static Delivery derivedFrom(RouteSpecification routeSpecification, Itinerary itinerary, HandlingHistory handlingHistory) {
Validate.notNull(routeSpecification, "Route specification is required");
Validate.notNull(handlingHistory, "Delivery history is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(handlingHistory, "Delivery history is required");

final HandlingEvent lastEvent = handlingHistory.mostRecentlyCompletedEvent();

Expand Down Expand Up @@ -357,4 +354,7 @@ public int hashCode() {
toHashCode();
}

protected Delivery() {
// Needed by Hibernate
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package se.citerus.dddsample.domain.model.cargo;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
Expand All @@ -11,14 +9,15 @@
import se.citerus.dddsample.domain.model.voyage.Voyage;
import se.citerus.dddsample.domain.shared.ValueObject;

import java.util.Objects;

/**
* A handling activity represents how and where a cargo can be handled,
* and can be used to express predictions about what is expected to
* happen to a cargo in the future.
*
*/
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class HandlingActivity implements ValueObject<HandlingActivity> {

// TODO make HandlingActivity a part of HandlingEvent too? There is some overlap.
Expand All @@ -36,17 +35,17 @@ public class HandlingActivity implements ValueObject<HandlingActivity> {
public Voyage voyage;

public HandlingActivity(final HandlingEvent.Type type, final Location location) {
Validate.notNull(type, "Handling event type is required");
Validate.notNull(location, "Location is required");
Objects.requireNonNull(type, "Handling event type is required");
Objects.requireNonNull(location, "Location is required");

this.type = type;
this.location = location;
}

public HandlingActivity(final HandlingEvent.Type type, final Location location, final Voyage voyage) {
Validate.notNull(type, "Handling event type is required");
Validate.notNull(location, "Location is required");
Validate.notNull(location, "Voyage is required");
Objects.requireNonNull(type, "Handling event type is required");
Objects.requireNonNull(location, "Location is required");
Objects.requireNonNull(location, "Voyage is required");

this.type = type;
this.location = location;
Expand Down Expand Up @@ -94,4 +93,8 @@ public boolean equals(final Object obj) {
return sameValueAs(other);
}

protected HandlingActivity() {
// Needed by Hibernate
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package se.citerus.dddsample.domain.model.cargo;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
Expand All @@ -17,7 +15,6 @@
*/
@Entity(name = "Leg")
@Table(name = "Leg")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Leg implements ValueObject<Leg> {

@Id
Expand Down Expand Up @@ -104,4 +101,7 @@ public int hashCode() {
toHashCode();
}

protected Leg() {
// Needed by Hibernate
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import jakarta.persistence.Embeddable;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
Expand All @@ -14,14 +12,14 @@
import se.citerus.dddsample.domain.shared.ValueObject;

import java.time.Instant;
import java.util.Objects;

/**
* Route specification. Describes where a cargo origin and destination is,
* and the arrival deadline.
*
*/
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class RouteSpecification extends AbstractSpecification<Itinerary> implements ValueObject<RouteSpecification> {

@ManyToOne()
Expand All @@ -41,9 +39,9 @@ public class RouteSpecification extends AbstractSpecification<Itinerary> impleme
* @param arrivalDeadline arrival deadline
*/
public RouteSpecification(final Location origin, final Location destination, final Instant arrivalDeadline) {
Validate.notNull(origin, "Origin is required");
Validate.notNull(destination, "Destination is required");
Validate.notNull(arrivalDeadline, "Arrival deadline is required");
Objects.requireNonNull(origin, "Origin is required");
Objects.requireNonNull(destination, "Destination is required");
Objects.requireNonNull(arrivalDeadline, "Arrival deadline is required");
Validate.isTrue(!origin.sameIdentityAs(destination), "Origin and destination can't be the same: " + origin);

this.origin = origin;
Expand Down Expand Up @@ -108,4 +106,8 @@ public int hashCode() {
toHashCode();
}

protected RouteSpecification() {
// Needed by Hibernate
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.apache.commons.lang3.Validate;
import se.citerus.dddsample.domain.shared.ValueObject;

import java.util.Objects;

/**
* Uniquely identifies a particular cargo. Automatically generated by the application.
*
Expand All @@ -17,7 +19,7 @@ public final class TrackingId implements ValueObject<TrackingId> {
* @param id Id string.
*/
public TrackingId(final String id) {
Validate.notNull(id);
Objects.requireNonNull(id);
Validate.notEmpty(id);
this.id = id;
}
Expand Down
Loading

0 comments on commit ab90ed0

Please sign in to comment.