CSVDataSetDefValidator extends AbstractDataSetDefValidator<CSVDataSetDef> { @Override public Iterable<ConstraintViolation<?>> validate(CSVDataSetDef dataSetDef, boolean isCacheEnabled, boolean isPushEnabled, boolean isRefreshEnabled, Object... params) { assert params != null && params.length == 1; final Boolean isFilePath = (Boolean) params[0]; Set<ConstraintViolation<CSVDataSetDef>> _violations = validator.validate(dataSetDef, getValidationGroups(isCacheEnabled, isPushEnabled, isRefreshEnabled, CSVDataSetDefValidation.class, isFilePath ? CSVDataSetDefFilePathValidation.class : CSVDataSetDefFileURLValidation.class)); return toIterable(_violations); } @Inject  CSVDataSetDefValidator( Validator validator ); @Override DataSetProviderType getSupportedProvider(); @Override Iterable<ConstraintViolation<?>> validateCustomAttributes( CSVDataSetDef dataSetDef, Object... params); @Override Iterable<ConstraintViolation<?>> validate(CSVDataSetDef dataSetDef, boolean isCacheEnabled, boolean isPushEnabled, boolean isRefreshEnabled, Object... params);  }
@Test public void testValidateUsingFilePath() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingFilePath = true; tested.validate(csvDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingFilePath); verify(validator, times(1)).validate(csvDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, CSVDataSetDefValidation.class, CSVDataSetDefFilePathValidation.class); }
@Test public void testValidateUsingFileUrl() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingFilePath = false; tested.validate(csvDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingFilePath); verify(validator, times(1)).validate(csvDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, CSVDataSetDefValidation.class, CSVDataSetDefFileURLValidation.class); }
@Test public void testValidateNoCache() { final boolean isCacheEnabled = false; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingFilePath = false; tested.validate(csvDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingFilePath); verify(validator, times(1)).validate(csvDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, CSVDataSetDefValidation.class, CSVDataSetDefFileURLValidation.class); }
@Test public void testValidateNoPush() { final boolean isCacheEnabled = true; final boolean isPushEnabled = false; final boolean isRefreshEnabled = true; final boolean isUsingFilePath = false; tested.validate(csvDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingFilePath); verify(validator, times(1)).validate(csvDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefRefreshIntervalValidation.class, CSVDataSetDefValidation.class, CSVDataSetDefFileURLValidation.class); }
@Test public void testValidateNoRefresh() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = false; final boolean isUsingFilePath = false; tested.validate(csvDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingFilePath); verify(validator, times(1)).validate(csvDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, CSVDataSetDefValidation.class, CSVDataSetDefFileURLValidation.class); }