SampleElementsForSplitPoints implements
        Operation,
        InputOutput<Iterable<? extends Element>, List<T>>,
        MultiInput<Element> { @Override public ValidationResult validate() { final ValidationResult result = InputOutput.super.validate(); if (null != numSplits && numSplits < 1) { result.addError("numSplits must be null or greater than 0"); } if (proportionToSample > 1 || proportionToSample < 0) { result.addError("proportionToSample must within range: [0, 1]"); } return result; }  @Override ValidationResult validate(); @Override SampleElementsForSplitPoints<T> shallowClone(); @Override Iterable<? extends Element> getInput(); @Override void setInput(final Iterable<? extends Element> input); @Override Map<String, String> getOptions(); @Override void setOptions(final Map<String, String> options); Integer getNumSplits(); void setNumSplits(final Integer numSplits); float getProportionToSample(); void setProportionToSample(final float proportionToSample); @Override TypeReference<List<T>> getOutputTypeReference();  }
@Test public void shouldFailValidationIfNumSplitsIsLessThan1() { final SampleElementsForSplitPoints op = new SampleElementsForSplitPoints.Builder<>().numSplits(0).build(); final ValidationResult result = op.validate(); assertFalse(result.isValid()); assertTrue(result.getErrorString().contains("numSplits must be null or greater than 0"), result.getErrorString()); }
@Test public void shouldFailValidationIfProportionToSampleIsNotIn0_1Range() { final SampleElementsForSplitPoints op = new SampleElementsForSplitPoints.Builder<>().proportionToSample(1.1f) .build(); final ValidationResult result = op.validate(); assertFalse(result.isValid()); assertTrue(result.getErrorString().contains("proportionToSample must within range: [0, 1]"), result.getErrorString()); }