improving branch coverage for AssetValidator+ShareValidator
This commit is contained in:
parent
7ba20b3687
commit
1ac8df5ed9
@ -1,5 +1,7 @@
|
|||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import org.assertj.core.api.AbstractThrowableAssert;
|
import org.assertj.core.api.AbstractThrowableAssert;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
@ -18,12 +20,25 @@ public class AssetValidatorUnitTest {
|
|||||||
private AssetValidator assetValidator = new AssetValidator();
|
private AssetValidator assetValidator = new AssetValidator();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAcceptValidAssetDTO() {
|
public void shouldAcceptValidIncreasingTransaction() {
|
||||||
new GivenAssetValidationTestCase()
|
for (AssetAction action : ImmutableList.of(AssetAction.PAYMENT, AssetAction.ADOPTION)) {
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
new GivenAssetValidationTestCase()
|
||||||
.withAction(AssetAction.PAYMENT).withAmount("64.00")
|
.withAnyValidDateValues()
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.withAction(action).withAmount("64.00")
|
||||||
.thenActualException().isNull();
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
|
.thenActualException().isNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldAcceptValidDecreasingTransaction() {
|
||||||
|
for (AssetAction action : ImmutableList.of(AssetAction.PAYBACK, AssetAction.HANDOVER, AssetAction.CLEARING, AssetAction.LOSS)) {
|
||||||
|
new GivenAssetValidationTestCase()
|
||||||
|
.withAnyValidDateValues()
|
||||||
|
.withAction(action).withAmount("-64.00")
|
||||||
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
|
.thenActualException().isNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -35,6 +50,15 @@ public class AssetValidatorUnitTest {
|
|||||||
.thenActualException().isNull();
|
.thenActualException().isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldRejectUpdates() {
|
||||||
|
new GivenAssetValidationTestCase()
|
||||||
|
.withId(RandomUtils.nextLong())
|
||||||
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
|
"Asset transactions are immutable", "asset", "assetTransactionImmutable"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfDocumentDateAfterValueDate() {
|
public void shouldRejectIfDocumentDateAfterValueDate() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
@ -48,7 +72,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfPaymentWithNegativeAmount() {
|
public void shouldRejectIfPaymentWithNegativeAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.PAYMENT).withAmount("-64.00")
|
.withAction(AssetAction.PAYMENT).withAmount("-64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -58,7 +82,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfPaymentWithZeroAmount() {
|
public void shouldRejectIfPaymentWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.PAYMENT).withAmount("0.00")
|
.withAction(AssetAction.PAYMENT).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -68,7 +92,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfAdoptionWithNegativeAmount() {
|
public void shouldRejectIfAdoptionWithNegativeAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.ADOPTION).withAmount("-64.00")
|
.withAction(AssetAction.ADOPTION).withAmount("-64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -78,7 +102,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfAdoptionWithZeroAmount() {
|
public void shouldRejectIfAdoptionWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.ADOPTION).withAmount("0.00")
|
.withAction(AssetAction.ADOPTION).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -88,7 +112,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfPaybackWithPositiveAmount() {
|
public void shouldRejectIfPaybackWithPositiveAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.PAYBACK).withAmount("64.00")
|
.withAction(AssetAction.PAYBACK).withAmount("64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -98,7 +122,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfPaybackWithZeroAmount() {
|
public void shouldRejectIfPaybackWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.PAYBACK).withAmount("0.00")
|
.withAction(AssetAction.PAYBACK).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -108,7 +132,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfHandoverWithPositiveAmount() {
|
public void shouldRejectIfHandoverWithPositiveAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.HANDOVER).withAmount("64.00")
|
.withAction(AssetAction.HANDOVER).withAmount("64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -118,7 +142,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfHandoverWithZeroAmount() {
|
public void shouldRejectIfHandoverWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.HANDOVER).withAmount("0.00")
|
.withAction(AssetAction.HANDOVER).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -128,7 +152,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfLossWithPositiveAmount() {
|
public void shouldRejectIfLossWithPositiveAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.LOSS).withAmount("64.00")
|
.withAction(AssetAction.LOSS).withAmount("64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -138,7 +162,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfLossWithZeroAmount() {
|
public void shouldRejectIfLossWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.LOSS).withAmount("0.00")
|
.withAction(AssetAction.LOSS).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -148,7 +172,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfClearingWithPositiveAmount() {
|
public void shouldRejectIfClearingWithPositiveAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.CLEARING).withAmount("64.00")
|
.withAction(AssetAction.CLEARING).withAmount("64.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -158,7 +182,7 @@ public class AssetValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfClearingWithZeroAmount() {
|
public void shouldRejectIfClearingWithZeroAmount() {
|
||||||
new GivenAssetValidationTestCase()
|
new GivenAssetValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(AssetAction.CLEARING).withAmount("0.00")
|
.withAction(AssetAction.CLEARING).withAmount("0.00")
|
||||||
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
.when((AssetDTO assetDto) -> assetValidator.validate(assetDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -173,6 +197,11 @@ public class AssetValidatorUnitTest {
|
|||||||
private final AssetDTO assetDto = new AssetDTO();
|
private final AssetDTO assetDto = new AssetDTO();
|
||||||
private BadRequestAlertException actualException;
|
private BadRequestAlertException actualException;
|
||||||
|
|
||||||
|
public GivenAssetValidationTestCase withId(long id) {
|
||||||
|
assetDto.setId(id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
GivenAssetValidationTestCase withDocumentDate(String documentDate) {
|
GivenAssetValidationTestCase withDocumentDate(String documentDate) {
|
||||||
assetDto.setDocumentDate(LocalDate.parse(documentDate));
|
assetDto.setDocumentDate(LocalDate.parse(documentDate));
|
||||||
return this;
|
return this;
|
||||||
@ -183,6 +212,10 @@ public class AssetValidatorUnitTest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GivenAssetValidationTestCase withAnyValidDateValues() {
|
||||||
|
return withDocumentDate("2019-04-11").withValueDate("2019-04-12");
|
||||||
|
}
|
||||||
|
|
||||||
GivenAssetValidationTestCase withAction(AssetAction assetAction) {
|
GivenAssetValidationTestCase withAction(AssetAction assetAction) {
|
||||||
assetDto.setAction(assetAction);
|
assetDto.setAction(assetAction);
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
import org.assertj.core.api.AbstractThrowableAssert;
|
import org.assertj.core.api.AbstractThrowableAssert;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -17,14 +19,23 @@ public class ShareValidatorUnitTest {
|
|||||||
private ShareValidator shareValidator = new ShareValidator();
|
private ShareValidator shareValidator = new ShareValidator();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAcceptValidShareDTO() {
|
public void shouldAcceptValidSubscription() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(ShareAction.SUBSCRIPTION).withQuantity(1)
|
.withAction(ShareAction.SUBSCRIPTION).withQuantity(1)
|
||||||
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
.thenActualException().isNull();
|
.thenActualException().isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldAcceptValidCancellation() {
|
||||||
|
new GivenShareValidationTestCase()
|
||||||
|
.withAnyValidDateValues()
|
||||||
|
.withAction(ShareAction.CANCELLATION).withQuantity(-1)
|
||||||
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
|
.thenActualException().isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAcceptIfDocumentDateEqualsValueDate() {
|
public void shouldAcceptIfDocumentDateEqualsValueDate() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
@ -34,6 +45,15 @@ public class ShareValidatorUnitTest {
|
|||||||
.thenActualException().isNull();
|
.thenActualException().isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldRejectUpdates() {
|
||||||
|
new GivenShareValidationTestCase()
|
||||||
|
.withId(RandomUtils.nextLong())
|
||||||
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
|
"Share transactions are immutable", "share", "shareTransactionImmutable"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfDocumentDateAfterValueDate() {
|
public void shouldRejectIfDocumentDateAfterValueDate() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
@ -47,7 +67,7 @@ public class ShareValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfSubscriptionWithNegativeQuantity() {
|
public void shouldRejectIfSubscriptionWithNegativeQuantity() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(ShareAction.SUBSCRIPTION).withQuantity(-1)
|
.withAction(ShareAction.SUBSCRIPTION).withQuantity(-1)
|
||||||
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -57,7 +77,7 @@ public class ShareValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfSubscriptionWithZeroQuantity() {
|
public void shouldRejectIfSubscriptionWithZeroQuantity() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(ShareAction.SUBSCRIPTION).withQuantity(0)
|
.withAction(ShareAction.SUBSCRIPTION).withQuantity(0)
|
||||||
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -67,7 +87,7 @@ public class ShareValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfCancellationWithPositiveQuantity() {
|
public void shouldRejectIfCancellationWithPositiveQuantity() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(ShareAction.CANCELLATION).withQuantity(1)
|
.withAction(ShareAction.CANCELLATION).withQuantity(1)
|
||||||
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -77,7 +97,7 @@ public class ShareValidatorUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRejectIfCancellationWithZeroQuantity() {
|
public void shouldRejectIfCancellationWithZeroQuantity() {
|
||||||
new GivenShareValidationTestCase()
|
new GivenShareValidationTestCase()
|
||||||
.withDocumentDate("2019-04-11").withValueDate("2019-04-12")
|
.withAnyValidDateValues()
|
||||||
.withAction(ShareAction.CANCELLATION).withQuantity(0)
|
.withAction(ShareAction.CANCELLATION).withQuantity(0)
|
||||||
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
.when((ShareDTO shareDto) -> shareValidator.validate(shareDto))
|
||||||
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
.thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException(
|
||||||
@ -92,6 +112,11 @@ public class ShareValidatorUnitTest {
|
|||||||
private final ShareDTO shareDto = new ShareDTO();
|
private final ShareDTO shareDto = new ShareDTO();
|
||||||
private BadRequestAlertException actualException;
|
private BadRequestAlertException actualException;
|
||||||
|
|
||||||
|
public GivenShareValidationTestCase withId(long id) {
|
||||||
|
shareDto.setId(id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
GivenShareValidationTestCase withDocumentDate(String documentDate) {
|
GivenShareValidationTestCase withDocumentDate(String documentDate) {
|
||||||
shareDto.setDocumentDate(LocalDate.parse(documentDate));
|
shareDto.setDocumentDate(LocalDate.parse(documentDate));
|
||||||
return this;
|
return this;
|
||||||
@ -102,6 +127,10 @@ public class ShareValidatorUnitTest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GivenShareValidationTestCase withAnyValidDateValues() {
|
||||||
|
return withDocumentDate("2019-04-11").withValueDate("2019-04-12");
|
||||||
|
}
|
||||||
|
|
||||||
GivenShareValidationTestCase withAction(ShareAction shareAction) {
|
GivenShareValidationTestCase withAction(ShareAction shareAction) {
|
||||||
shareDto.setAction(shareAction);
|
shareDto.setAction(shareAction);
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user