MarketDataPointRandomizingManipulator implements StructureManipulator<Double> { @Override public Double execute(Double structure, ValueSpecification valueSpecification, FunctionExecutionContext executionContext) { return structure * randomFactor(); } MarketDataPointRandomizingManipulator(Double lowerBound, Double upperBound); @Override Double execute(Double structure,
                        ValueSpecification valueSpecification,
                        FunctionExecutionContext executionContext); @Override Class<Double> getExpectedType(); MutableFudgeMsg toFudgeMsg(final FudgeSerializer serializer); static MarketDataPointRandomizingManipulator fromFudgeMsg(final FudgeDeserializer deserializer, final FudgeMsg msg);  }
@Test public void testValuesAreDistributed() { StructureManipulator<Double> manipulator = createManipulator(0.9, 1.1); Set<Double> producedValues = new HashSet<>(10000); for (int i = 0; i < 10000; i++) { ValueProperties properties = ValueProperties.with(ValuePropertyNames.FUNCTION, "notUsed").get(); ValueSpecification valueSpec = new ValueSpecification("notUsed", ComputationTargetSpecification.NULL, properties); Double shifted = manipulator.execute(1000d, valueSpec, new FunctionExecutionContext()); assertTrue("Expected shifted to be >= 900 but was " + shifted, shifted >= 900); assertTrue("Expected shifted to be < 1100 but was " + shifted, shifted < 1100); producedValues.add(shifted); } assertTrue("Expected there to be multiple values produced, but there were only " + producedValues.size(), producedValues.size() > 100); }