Commit 4ff2989d authored by mey's avatar mey
Browse files

AbstractLimitedStoragePipeline.java: fixed draining wrong amount from element

    when sum storage puts a penalty on subtracted amount
        e.g. if sum is ConfigurableStorage and factorOut != 1
    updated test
parent 9d264783
......@@ -93,7 +93,7 @@ public abstract class AbstractLimitedStoragePipeline<Q extends Quantity>
ChangeResult<Q> changeResult = sum.add(amount.opposite());
// sum the amount received from storage
returnAmount = returnAmount.plus(amount.plus(changeResult.getRejected()));
returnAmount = returnAmount.minus(changeResult.getStored());
} else {
// no expired elements
break;
......
......@@ -29,8 +29,9 @@ public class AbstractLimitedStoragePipelineTest implements Serializable {
// TEST STORE AMOUNT
private static final Amount<Dimensionless> CHANGE = Amount.valueOf(15.4, Unit.ONE);
private static final Amount<Dimensionless> STORED_IN = CHANGE.times(LimitedTestStorage.FACTOR_IN);
private static final Amount<Dimensionless> DRAINED = STORED_IN.minus(LimitedTestStorage.LOWER_LIMIT)
.divide(LimitedTestStorage.FACTOR_OUT);
// amount will exceed lower limit, so the maximum will be drained
private static final Amount<Dimensionless> DRAINED = STORED_IN.minus(LimitedTestStorage.LOWER_LIMIT);
private long timePassed;
......@@ -144,7 +145,8 @@ public class AbstractLimitedStoragePipelineTest implements Serializable {
}
@Override
protected AbstractLimitedStoragePipeline.DelayedStorage<Dimensionless> createDelayedStorage(Amount<Dimensionless> storedAmount) {
protected AbstractLimitedStoragePipeline.DelayedStorage<Dimensionless> createDelayedStorage(
Amount<Dimensionless> storedAmount) {
return new FixedDelayStorage(storedAmount);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment