### Question:
RelativeScaleFactor extends ScaleFactor { @Override public int apply(int currentSize, Action action) { int newSize = Math.round(currentSize * new Double(getFactor()).floatValue()); if(action instanceof ScaleInAction) { newSize = Math.round(currentSize * new Double(Math.pow(getFactor(), -1)).floatValue()); if(newSize < 1) { newSize = 1; } } return newSize; } RelativeScaleFactor(double factor); @Override int apply(int currentSize,  Action action);  }### Answer:
@Test public void testRelativeFactorApplyWithScaleIn() { System.out.println("testRelativeFactorApply"); RelativeScaleFactor factor; factor = new RelativeScaleFactor(2); assertEquals("New scaling size is incorrect", 5, factor.apply(10, new ScaleInAction())); assertEquals("New scaling size is incorrect", 2, factor.apply(4, new ScaleInAction())); assertEquals("New scaling size is incorrect", 1, factor.apply(2, new ScaleInAction())); assertEquals("New size is less than 1 after scaling in", 1, factor.apply(1, new ScaleInAction())); }
@Test public void testRelativeFactorApplyWithScaleOut() { System.out.println("testRelativeFactorApply"); RelativeScaleFactor factor; factor = new RelativeScaleFactor(2); assertEquals("New scaling size is incorrect", 2, factor.apply(1, new ScaleOutAction())); assertEquals("New scaling size is incorrect", 4, factor.apply(2, new ScaleOutAction())); assertEquals("New scaling size is incorrect", 10, factor.apply(5, new ScaleOutAction())); }