### Question:
ValueValidatorService { public void validate(Object obj, Class<?>... groups) { final List<String> violations = validator.validate(obj, groups).stream() .map(vl -> vl.getPropertyPath().toString() + " : " + vl.getMessage()) .collect(Collectors.toList()); if (!violations.isEmpty()) { log.debug("Value validation failed: {}", violations.toString()); throw new ValidationException(FORMAT_ERROR.name() + ": " + violations); } } @Autowired  ValueValidatorService(Validator validator); void validateAccountIdTransactionId(String accountId, String transactionId); void validate(Object obj, Class<?>... groups);  }### Answer:
@Test void validate_AccountAndTransaction() { ValidationGroup fields = new ValidationGroup(); fields.setAccountId(ACCOUNT_ID); fields.setTransactionId(TRANSACTION_ID); valueValidatorService.validate(fields, ValidationGroup.AccountIdGroup.class, ValidationGroup.TransactionIdGroup.class); }
@Test void shouldFail_validate_AccountAndEmptyTransaction() { ValidationGroup fields = new ValidationGroup(); fields.setAccountId(ACCOUNT_ID); assertThatThrownBy(() -> valueValidatorService.validate(fields, ValidationGroup.AccountIdGroup.class, ValidationGroup.TransactionIdGroup.class)) .isInstanceOf(ValidationException.class); }
@Test void shouldFail_validate_EmptyAccountAndTransaction() { ValidationGroup fields = new ValidationGroup(); fields.setTransactionId(TRANSACTION_ID); assertThatThrownBy(() -> valueValidatorService.validate(fields, ValidationGroup.AccountIdGroup.class, ValidationGroup.TransactionIdGroup.class)) .isInstanceOf(ValidationException.class); }