@Test public void test_isValid_withId_happyPath() throws Exception { _validator = new RangerServiceValidator(_store); RangerService service = mock(RangerService.class); when(_store.getService(1L)).thenReturn(service); Assert.assertTrue(_validator.isValid(1L, Action.DELETE, _failures)); }
boolean isValid(Long id, Action action, List<ValidationFailureDetails> failures) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceValidator.isValid(" + id + ")"); } boolean valid = true; if (action != Action.DELETE) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; failures.add(new ValidationFailureDetailsBuilder() .isAnInternalError() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(action)) .build()); valid = false; } else if (id == null) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_MISSING_FIELD; failures.add(new ValidationFailureDetailsBuilder() .field("id") .isMissing() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(id)) .build()); valid = false; } else if (getService(id) == null) { if (LOG.isDebugEnabled()) { LOG.debug("No service found for id[" + id + "]! ok!"); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceValidator.isValid(" + id + "): " + valid); } return valid; }
RangerServiceValidator extends RangerValidator { boolean isValid(Long id, Action action, List<ValidationFailureDetails> failures) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceValidator.isValid(" + id + ")"); } boolean valid = true; if (action != Action.DELETE) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; failures.add(new ValidationFailureDetailsBuilder() .isAnInternalError() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(action)) .build()); valid = false; } else if (id == null) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_MISSING_FIELD; failures.add(new ValidationFailureDetailsBuilder() .field("id") .isMissing() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(id)) .build()); valid = false; } else if (getService(id) == null) { if (LOG.isDebugEnabled()) { LOG.debug("No service found for id[" + id + "]! ok!"); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceValidator.isValid(" + id + "): " + valid); } return valid; } }
RangerServiceValidator extends RangerValidator { boolean isValid(Long id, Action action, List<ValidationFailureDetails> failures) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceValidator.isValid(" + id + ")"); } boolean valid = true; if (action != Action.DELETE) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; failures.add(new ValidationFailureDetailsBuilder() .isAnInternalError() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(action)) .build()); valid = false; } else if (id == null) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_MISSING_FIELD; failures.add(new ValidationFailureDetailsBuilder() .field("id") .isMissing() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(id)) .build()); valid = false; } else if (getService(id) == null) { if (LOG.isDebugEnabled()) { LOG.debug("No service found for id[" + id + "]! ok!"); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceValidator.isValid(" + id + "): " + valid); } return valid; } RangerServiceValidator(ServiceStore store); }
RangerServiceValidator extends RangerValidator { boolean isValid(Long id, Action action, List<ValidationFailureDetails> failures) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceValidator.isValid(" + id + ")"); } boolean valid = true; if (action != Action.DELETE) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; failures.add(new ValidationFailureDetailsBuilder() .isAnInternalError() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(action)) .build()); valid = false; } else if (id == null) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_MISSING_FIELD; failures.add(new ValidationFailureDetailsBuilder() .field("id") .isMissing() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(id)) .build()); valid = false; } else if (getService(id) == null) { if (LOG.isDebugEnabled()) { LOG.debug("No service found for id[" + id + "]! ok!"); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceValidator.isValid(" + id + "): " + valid); } return valid; } RangerServiceValidator(ServiceStore store); void validate(RangerService service, Action action); boolean isValidString(final Pattern pattern, final String name); }
RangerServiceValidator extends RangerValidator { boolean isValid(Long id, Action action, List<ValidationFailureDetails> failures) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerServiceValidator.isValid(" + id + ")"); } boolean valid = true; if (action != Action.DELETE) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_UNSUPPORTED_ACTION; failures.add(new ValidationFailureDetailsBuilder() .isAnInternalError() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(action)) .build()); valid = false; } else if (id == null) { ValidationErrorCode error = ValidationErrorCode.SERVICE_VALIDATION_ERR_MISSING_FIELD; failures.add(new ValidationFailureDetailsBuilder() .field("id") .isMissing() .errorCode(error.getErrorCode()) .becauseOf(error.getMessage(id)) .build()); valid = false; } else if (getService(id) == null) { if (LOG.isDebugEnabled()) { LOG.debug("No service found for id[" + id + "]! ok!"); } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerServiceValidator.isValid(" + id + "): " + valid); } return valid; } RangerServiceValidator(ServiceStore store); void validate(RangerService service, Action action); boolean isValidString(final Pattern pattern, final String name);  }