test: ValidExchangeRequestValidatorTest more test cases & validator implementation
TODO: move disabled tests to future service / endpoint suite
This commit is contained in:
parent
8d722e3ce4
commit
b5237c49bc
2 changed files with 46 additions and 12 deletions
|
@ -4,12 +4,21 @@ import eu.ztsh.wymiana.web.model.CurrencyExchangeRequest;
|
|||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
public class ValidExchangeRequestValidator implements ConstraintValidator<ValidExchangeRequest, CurrencyExchangeRequest> {
|
||||
public class ValidExchangeRequestValidator implements
|
||||
ConstraintValidator<ValidExchangeRequest, CurrencyExchangeRequest> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(CurrencyExchangeRequest currencyExchangeRequest,
|
||||
public boolean isValid(CurrencyExchangeRequest request,
|
||||
ConstraintValidatorContext constraintValidatorContext) {
|
||||
return false;
|
||||
if (request == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !request.from().equals(request.to())
|
||||
&& !((request.toBuy() == null && request.toSell() == null)
|
||||
|| (request.toBuy() != null && request.toSell() != null))
|
||||
&& ((request.toBuy() != null && request.toBuy() >= 0)
|
||||
|| (request.toSell() != null && request.toSell() >= 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue