SQLDataSetDefValidator extends AbstractDataSetDefValidator<SQLDataSetDef> { @Override public Iterable<ConstraintViolation<?>> validate( SQLDataSetDef dataSetDef, boolean isCacheEnabled, boolean isPushEnabled, boolean isRefreshEnabled, Object... params ) { assert params != null && params.length == 1; final Boolean isQuery = (Boolean) params[0]; Set<ConstraintViolation<SQLDataSetDef>> _violations = validator.validate( dataSetDef, getValidationGroups( isCacheEnabled, isPushEnabled, isRefreshEnabled, SQLDataSetDefValidation.class, isQuery ? SQLDataSetDefDbSQLValidation.class : SQLDataSetDefDbTableValidation.class ) ); return toIterable( _violations ); } @Inject  SQLDataSetDefValidator( Validator validator ); @Override DataSetProviderType getSupportedProvider(); @Override Iterable<ConstraintViolation<?>> validateCustomAttributes( SQLDataSetDef dataSetDef, Object... params ); @Override Iterable<ConstraintViolation<?>> validate( SQLDataSetDef dataSetDef,
                                                      boolean isCacheEnabled,
                                                      boolean isPushEnabled,
                                                      boolean isRefreshEnabled,
                                                      Object... params );  }
@Test public void testValidateUsingQuery() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingQuery = true; tested.validate(sqlDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingQuery); verify(validator, times(1)).validate(sqlDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, SQLDataSetDefValidation.class, SQLDataSetDefDbSQLValidation.class); }
@Test public void testValidateUsingTable() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingQuery = false; tested.validate(sqlDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingQuery); verify(validator, times(1)).validate(sqlDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, SQLDataSetDefValidation.class, SQLDataSetDefDbTableValidation.class); }
@Test public void testValidateNoCache() { final boolean isCacheEnabled = false; final boolean isPushEnabled = true; final boolean isRefreshEnabled = true; final boolean isUsingQuery = false; tested.validate(sqlDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingQuery); verify(validator, times(1)).validate(sqlDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefPushSizeValidation.class, DataSetDefRefreshIntervalValidation.class, SQLDataSetDefValidation.class, SQLDataSetDefDbTableValidation.class); }
@Test public void testValidateNoPush() { final boolean isCacheEnabled = true; final boolean isPushEnabled = false; final boolean isRefreshEnabled = true; final boolean isUsingQuery = false; tested.validate(sqlDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingQuery); verify(validator, times(1)).validate(sqlDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefRefreshIntervalValidation.class, SQLDataSetDefValidation.class, SQLDataSetDefDbTableValidation.class); }
@Test public void testValidateNoRefresh() { final boolean isCacheEnabled = true; final boolean isPushEnabled = true; final boolean isRefreshEnabled = false; final boolean isUsingQuery = false; tested.validate(sqlDataSetDef, isCacheEnabled, isPushEnabled, isRefreshEnabled, isUsingQuery); verify(validator, times(1)).validate(sqlDataSetDef, DataSetDefBasicAttributesGroup.class, DataSetDefProviderTypeGroup.class, DataSetDefCacheRowsValidation.class, DataSetDefPushSizeValidation.class, SQLDataSetDefValidation.class, SQLDataSetDefDbTableValidation.class); }