/** * Adjusts the base value based on the criteria of this adjustment. * <p> * For example, if this adjustment represents a 10% decrease, then the * result will be the base value minus 10%. * * @param baseValue the base, or previous, value to be adjusted * @return the calculated result */ public double adjust(double baseValue) { return type.adjust(baseValue, modifyingValue); }
@Test(dataProvider = "name") public void test_of_lookup(ValueAdjustmentType convention, String name) { assertEquals(ValueAdjustmentType.of(name), convention); }
@Test(dataProvider = "name") public void test_toString(ValueAdjustmentType convention, String name) { assertEquals(convention.toString(), name); }
@Test(dataProvider = "name") public void test_of_lookupLowerCase(ValueAdjustmentType convention, String name) { assertEquals(ValueAdjustmentType.of(name.toLowerCase(Locale.ENGLISH)), convention); }
public void test_adjust() { assertEquals(ValueAdjustmentType.DELTA_AMOUNT.adjust(2d, 3d), 5d, 1e-12); assertEquals(ValueAdjustmentType.DELTA_MULTIPLIER.adjust(2d, 1.5d), 5d, 1e-12); assertEquals(ValueAdjustmentType.MULTIPLIER.adjust(2d, 1.5d), 3d, 1e-12); assertEquals(ValueAdjustmentType.REPLACE.adjust(2d, 1.5d), 1.5d, 1e-12); }
@Test(dataProvider = "name") public void test_of_lookupUpperCase(ValueAdjustmentType convention, String name) { assertEquals(ValueAdjustmentType.of(name.toUpperCase(Locale.ENGLISH)), convention); }
public void test_of_lookup_null() { assertThrowsIllegalArg(() -> ValueAdjustmentType.of(null)); }
public void test_of_lookup_notFound() { assertThrowsIllegalArg(() -> ValueAdjustmentType.of("Rubbish")); }