From c0e981ed66f1c0bff38710d71f9d9cd38af08b47 Mon Sep 17 00:00:00 2001 From: Karim Elmosalamy Date: Wed, 8 May 2024 22:26:46 +0300 Subject: [PATCH] working on added basic boilerplate --- services/contracts/pom.xml | 34 +++++++++++++++++-- .../commands/EvaluateMilestoneCommand.java | 18 ++++++++++ .../commands/GetContractCommand.java | 20 +++++++++++ .../commands/GetMilestoneCommand.java | 22 ++++++++++++ .../GetPendingTerminationsCommand.java | 24 +++++++++++++ .../commands/ProgressMilestoneCommand.java | 20 +++++++++++ .../shared/commands/contracts/Milestone.java | 2 +- .../requests/GetContractRequest.java | 15 ++++++++ .../requests/GetMilestoneRequest.java | 16 +++++++++ .../GetPendingTerminationsRequest.java | 15 ++++++++ ...se.java => EvaluateMilestoneResponse.java} | 2 +- .../responses/GetContractResponse.java | 26 ++++++++++++++ .../responses/GetMilestoneResponse.java | 14 ++++++++ .../GetPendingTerminationsResponse.java | 24 +++++++++++++ 14 files changed, 247 insertions(+), 5 deletions(-) create mode 100644 services/contracts/src/main/java/com/workup/contracts/commands/EvaluateMilestoneCommand.java create mode 100644 services/contracts/src/main/java/com/workup/contracts/commands/GetContractCommand.java create mode 100644 services/contracts/src/main/java/com/workup/contracts/commands/GetMilestoneCommand.java create mode 100644 services/contracts/src/main/java/com/workup/contracts/commands/GetPendingTerminationsCommand.java create mode 100644 services/contracts/src/main/java/com/workup/contracts/commands/ProgressMilestoneCommand.java create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/requests/GetContractRequest.java create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/requests/GetMilestoneRequest.java create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/requests/GetPendingTerminationsRequest.java rename shared/src/main/java/com/workup/shared/commands/contracts/responses/{EvaluatedMilestoneResponse.java => EvaluateMilestoneResponse.java} (80%) create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/responses/GetContractResponse.java create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/responses/GetMilestoneResponse.java create mode 100644 shared/src/main/java/com/workup/shared/commands/contracts/responses/GetPendingTerminationsResponse.java diff --git a/services/contracts/pom.xml b/services/contracts/pom.xml index a377bb9a..0ca96710 100644 --- a/services/contracts/pom.xml +++ b/services/contracts/pom.xml @@ -20,6 +20,10 @@ 21 + + org.springframework.boot + spring-boot-starter-amqp + org.springframework.boot spring-boot-starter-web @@ -36,17 +40,41 @@ org.springframework.boot - spring-boot-starter-data-cassandra + spring-boot-testcontainers + test - org.springframework.boot - spring-boot-starter-amqp + org.testcontainers + junit-jupiter + 1.19.7 + test + + + org.testcontainers + cassandra + 1.19.7 + test + + + org.testcontainers + rabbitmq + 1.19.7 + test + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.16.0 org.springframework.amqp spring-rabbit-test test + + org.springframework.boot + spring-boot-starter-data-cassandra + org.projectlombok lombok diff --git a/services/contracts/src/main/java/com/workup/contracts/commands/EvaluateMilestoneCommand.java b/services/contracts/src/main/java/com/workup/contracts/commands/EvaluateMilestoneCommand.java new file mode 100644 index 00000000..92959fa5 --- /dev/null +++ b/services/contracts/src/main/java/com/workup/contracts/commands/EvaluateMilestoneCommand.java @@ -0,0 +1,18 @@ +package com.workup.contracts.commands; + +import com.workup.shared.commands.contracts.requests.EvaluateMilestoneRequest; + +import com.workup.shared.commands.contracts.responses.EvaluateMilestoneResponse; + +public class EvaluateMilestoneCommand + extends ContractCommand { + + @Override + public EvaluateMilestoneResponse Run(EvaluateMilestoneRequest request) { + // First we will get the milestones and add them to the database first, + // This will allow us to have their IDs for when we insert the contract. + + return null; + + } +} diff --git a/services/contracts/src/main/java/com/workup/contracts/commands/GetContractCommand.java b/services/contracts/src/main/java/com/workup/contracts/commands/GetContractCommand.java new file mode 100644 index 00000000..50198656 --- /dev/null +++ b/services/contracts/src/main/java/com/workup/contracts/commands/GetContractCommand.java @@ -0,0 +1,20 @@ +package com.workup.contracts.commands; + +import com.workup.shared.commands.contracts.requests.EvaluateMilestoneRequest; + +import com.workup.shared.commands.contracts.requests.GetContractRequest; +import com.workup.shared.commands.contracts.responses.EvaluateMilestoneResponse; +import com.workup.shared.commands.contracts.responses.GetContractResponse; + +public class GetContractCommand + extends ContractCommand { + + @Override + public GetContractResponse Run(GetContractRequest request) { + // First we will get the milestones and add them to the database first, + // This will allow us to have their IDs for when we insert the contract. + + return null; + + } +} diff --git a/services/contracts/src/main/java/com/workup/contracts/commands/GetMilestoneCommand.java b/services/contracts/src/main/java/com/workup/contracts/commands/GetMilestoneCommand.java new file mode 100644 index 00000000..3308c0ce --- /dev/null +++ b/services/contracts/src/main/java/com/workup/contracts/commands/GetMilestoneCommand.java @@ -0,0 +1,22 @@ +package com.workup.contracts.commands; + +import com.workup.shared.commands.contracts.requests.EvaluateMilestoneRequest; + +import com.workup.shared.commands.contracts.requests.GetContractRequest; +import com.workup.shared.commands.contracts.requests.GetMilestoneRequest; +import com.workup.shared.commands.contracts.responses.EvaluateMilestoneResponse; +import com.workup.shared.commands.contracts.responses.GetContractResponse; +import com.workup.shared.commands.contracts.responses.GetMilestoneResponse; + +public class GetMilestoneCommand + extends ContractCommand { + + @Override + public GetMilestoneResponse Run(GetMilestoneRequest request) { + // First we will get the milestones and add them to the database first, + // This will allow us to have their IDs for when we insert the contract. + + return null; + + } +} diff --git a/services/contracts/src/main/java/com/workup/contracts/commands/GetPendingTerminationsCommand.java b/services/contracts/src/main/java/com/workup/contracts/commands/GetPendingTerminationsCommand.java new file mode 100644 index 00000000..2988202e --- /dev/null +++ b/services/contracts/src/main/java/com/workup/contracts/commands/GetPendingTerminationsCommand.java @@ -0,0 +1,24 @@ +package com.workup.contracts.commands; + +import com.workup.shared.commands.contracts.requests.EvaluateMilestoneRequest; + +import com.workup.shared.commands.contracts.requests.GetContractRequest; +import com.workup.shared.commands.contracts.requests.GetMilestoneRequest; +import com.workup.shared.commands.contracts.requests.GetPendingTerminationsRequest; +import com.workup.shared.commands.contracts.responses.EvaluateMilestoneResponse; +import com.workup.shared.commands.contracts.responses.GetContractResponse; +import com.workup.shared.commands.contracts.responses.GetMilestoneResponse; +import com.workup.shared.commands.contracts.responses.GetPendingTerminationsResponse; + +public class GetPendingTerminationsCommand + extends ContractCommand { + + @Override + public GetPendingTerminationsResponse Run(GetPendingTerminationsRequest request) { + // First we will get the milestones and add them to the database first, + // This will allow us to have their IDs for when we insert the contract. + + return null; + + } +} diff --git a/services/contracts/src/main/java/com/workup/contracts/commands/ProgressMilestoneCommand.java b/services/contracts/src/main/java/com/workup/contracts/commands/ProgressMilestoneCommand.java new file mode 100644 index 00000000..ab886943 --- /dev/null +++ b/services/contracts/src/main/java/com/workup/contracts/commands/ProgressMilestoneCommand.java @@ -0,0 +1,20 @@ +package com.workup.contracts.commands; + +import com.workup.shared.commands.contracts.requests.EvaluateMilestoneRequest; + +import com.workup.shared.commands.contracts.requests.ProgressMilestoneRequest; +import com.workup.shared.commands.contracts.responses.EvaluateMilestoneResponse; +import com.workup.shared.commands.contracts.responses.ProgressMilestoneResponse; + +public class ProgressMilestoneCommand + extends ContractCommand { + + @Override + public ProgressMilestoneResponse Run(ProgressMilestoneRequest request) { + // First we will get the milestones and add them to the database first, + // This will allow us to have their IDs for when we insert the contract. + + return null; + + } +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/Milestone.java b/shared/src/main/java/com/workup/shared/commands/contracts/Milestone.java index 308163c5..159dac47 100644 --- a/shared/src/main/java/com/workup/shared/commands/contracts/Milestone.java +++ b/shared/src/main/java/com/workup/shared/commands/contracts/Milestone.java @@ -11,7 +11,7 @@ @Jacksonized public class Milestone { - private final String milestoneId; // Not Needed when initiating contract, make it null + private final String milestoneId; // Not needed when initiating contract, make it null private final String contractId; // Not needed when initiating contract, make it null private final String description; diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetContractRequest.java b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetContractRequest.java new file mode 100644 index 00000000..5fbb7726 --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetContractRequest.java @@ -0,0 +1,15 @@ +package com.workup.shared.commands.contracts.requests; + +import com.workup.shared.commands.CommandRequest; +import com.workup.shared.enums.contracts.TerminationRequestStatus; +import lombok.Getter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +// PURPOSE : To fulfill the need for the read of CRUD for our contract repository +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetContractRequest extends CommandRequest { + private final String contractId; +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetMilestoneRequest.java b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetMilestoneRequest.java new file mode 100644 index 00000000..b9dc48b6 --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetMilestoneRequest.java @@ -0,0 +1,16 @@ +package com.workup.shared.commands.contracts.requests; + +import com.workup.shared.commands.CommandRequest; +import com.workup.shared.enums.contracts.TerminationRequestStatus; +import lombok.Getter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +// PURPOSE : To fulfill the need for the read of CRUD for our milestone repository +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetMilestoneRequest extends CommandRequest { + + private final String milestoneId; +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetPendingTerminationsRequest.java b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetPendingTerminationsRequest.java new file mode 100644 index 00000000..e5ee968a --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/requests/GetPendingTerminationsRequest.java @@ -0,0 +1,15 @@ +package com.workup.shared.commands.contracts.requests; + +import com.workup.shared.commands.CommandRequest; +import com.workup.shared.enums.contracts.TerminationRequestStatus; +import lombok.Getter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +// PURPOSE : To fulfill the need for the read of CRUD for our terminations repository +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetPendingTerminationsRequest extends CommandRequest { + private final String contractId; +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluatedMilestoneResponse.java b/shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluateMilestoneResponse.java similarity index 80% rename from shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluatedMilestoneResponse.java rename to shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluateMilestoneResponse.java index c119e14f..c1319d9d 100644 --- a/shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluatedMilestoneResponse.java +++ b/shared/src/main/java/com/workup/shared/commands/contracts/responses/EvaluateMilestoneResponse.java @@ -8,4 +8,4 @@ @Getter @SuperBuilder(setterPrefix = "with") @Jacksonized -public class EvaluatedMilestoneResponse extends CommandResponse {} +public class EvaluateMilestoneResponse extends CommandResponse {} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetContractResponse.java b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetContractResponse.java new file mode 100644 index 00000000..3165d795 --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetContractResponse.java @@ -0,0 +1,26 @@ +package com.workup.shared.commands.contracts.responses; + +import com.workup.shared.commands.CommandResponse; +import com.workup.shared.enums.contracts.ContractState; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; +import java.util.UUID; + +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetContractResponse extends CommandResponse { + private final String contractId; + private String jobTitle; + private String jobId; + private String proposalId; + private String freelancerId; + private String clientId; + private List milestonesIds; + private ContractState status; + +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetMilestoneResponse.java b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetMilestoneResponse.java new file mode 100644 index 00000000..241c9cbb --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetMilestoneResponse.java @@ -0,0 +1,14 @@ +package com.workup.shared.commands.contracts.responses; + +import com.workup.shared.commands.CommandResponse; +import com.workup.shared.commands.contracts.Milestone; +import lombok.Getter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetMilestoneResponse extends CommandResponse { + private final Milestone milestone; +} diff --git a/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetPendingTerminationsResponse.java b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetPendingTerminationsResponse.java new file mode 100644 index 00000000..f22819d3 --- /dev/null +++ b/shared/src/main/java/com/workup/shared/commands/contracts/responses/GetPendingTerminationsResponse.java @@ -0,0 +1,24 @@ +package com.workup.shared.commands.contracts.responses; + +import com.workup.shared.commands.CommandResponse; +import com.workup.shared.commands.contracts.Milestone; +import com.workup.shared.enums.contracts.TerminationRequestStatus; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +import java.util.UUID; + +@Getter +@SuperBuilder(setterPrefix = "with") +@Jacksonized +public class GetPendingTerminationsResponse extends CommandResponse { + private String requestId; + + private String contractId; + private String requesterId; + private String reason; + + private TerminationRequestStatus status; +}