RowCountVerificationStrategy extends AbstractMinMaxVerificationStrategy implements VerificationStrategy<RowCountVerification> { @Override public <T extends ExecutableRule> Result.Status verify(T executable, RowCountVerification verification, List<String> columnNames, List<Map<String, Object>> rows) { return getStatus(executable, rows.size(), verification.getMin(), verification.getMax()); }  @Override Class<RowCountVerification> getVerificationType(); @Override Result.Status verify(T executable, RowCountVerification verification, List<String> columnNames,
            List<Map<String, Object>> rows);  }
@Test public void defaultConfiguration() throws RuleException { RowCountVerification rowCountVerification = RowCountVerification.builder().build(); when(result.size()).thenReturn(0); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); when(result.size()).thenReturn(1); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); }
@Test public void min() throws RuleException { RowCountVerification rowCountVerification = RowCountVerification.builder().min(1).build(); when(result.size()).thenReturn(0); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); when(result.size()).thenReturn(1); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); }
@Test public void max() throws RuleException { RowCountVerification rowCountVerification = RowCountVerification.builder().max(0).build(); when(result.size()).thenReturn(0); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); when(result.size()).thenReturn(1); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); }
@Test public void minMax() throws RuleException { RowCountVerification rowCountVerification = RowCountVerification.builder().min(1).max(1).build(); when(result.size()).thenReturn(0); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); when(result.size()).thenReturn(1); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(SUCCESS)); when(result.size()).thenReturn(2); assertThat(strategy.verify(concept, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); assertThat(strategy.verify(constraint, rowCountVerification, COLUMN_NAMES, result), equalTo(FAILURE)); }