Skip to content

Commit

Permalink
refactor(ContractOffer): deprecate contractStart and contractEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
juliapampus committed Apr 19, 2023
1 parent 3c3e29e commit 2e8192d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ public class ContractOffer {
private ZonedDateTime offerEnd;
/**
* Timestamp defining the start date when the contract becomes effective
*
* @deprecated replaced with policy implementation
*/
@Deprecated(forRemoval = true)
private ZonedDateTime contractStart;
/**
* Timestamp defining the end date when the contract becomes terminated
*
* @deprecated replaced with policy implementation
*/
@Deprecated(forRemoval = true)
private ZonedDateTime contractEnd;


Expand Down Expand Up @@ -94,11 +100,13 @@ public ZonedDateTime getOfferEnd() {
return offerEnd;
}

@Deprecated
@NotNull
public ZonedDateTime getContractStart() {
return contractStart;
}

@Deprecated
@NotNull
public ZonedDateTime getContractEnd() {
return contractEnd;
Expand Down Expand Up @@ -177,11 +185,13 @@ public Builder offerEnd(ZonedDateTime date) {
return this;
}

@Deprecated
public Builder contractStart(ZonedDateTime date) {
contractOffer.contractStart = date;
return this;
}

@Deprecated
public Builder contractEnd(ZonedDateTime date) {
contractOffer.contractEnd = date;
return this;
Expand All @@ -196,8 +206,6 @@ public ContractOffer build() {
Objects.requireNonNull(contractOffer.id);
Objects.requireNonNull(contractOffer.asset, "Asset must not be null");
Objects.requireNonNull(contractOffer.policy, "Policy must not be null");
Objects.requireNonNull(contractOffer.contractStart, "Contract start must not be null");
Objects.requireNonNull(contractOffer.contractEnd, "Contract end must not be null");
return contractOffer;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,4 @@ void verifyAssetNotNull() {
.isInstanceOf(NullPointerException.class)
.hasMessage("Asset must not be null");
}

@Test
void verifyContractStartNotNull() {
assertThatThrownBy(() -> ContractOffer.Builder.newInstance().id("some-id")
.asset(Asset.Builder.newInstance().id("test-assetId").build())
.policy(Policy.Builder.newInstance().build())
.contractEnd(ZonedDateTime.now().plusMonths(1))
.build())
.isInstanceOf(NullPointerException.class)
.hasMessage("Contract start must not be null");
}

@Test
void verifyContractEndNotNull() {
assertThatThrownBy(() -> ContractOffer.Builder.newInstance().id("some-id")
.asset(Asset.Builder.newInstance().id("test-assetId").build())
.policy(Policy.Builder.newInstance().build())
.contractStart(ZonedDateTime.now())
.build())
.isInstanceOf(NullPointerException.class)
.hasMessage("Contract end must not be null");
}
}

0 comments on commit 2e8192d

Please sign in to comment.