ResourceCalculator { public abstract boolean fitsIn(Resource cluster, Resource smaller, Resource bigger);  abstract int compare(Resource clusterResource, Resource lhs, Resource rhs); static int divideAndCeil(int a, int b); static int roundUp(int a, int b); static int roundDown(int a, int b); abstract int computeAvailableContainers(
      Resource available, Resource required); abstract Resource multiplyAndNormalizeUp(
      Resource r, double by, Resource stepFactor); abstract Resource multiplyAndNormalizeDown(
      Resource r, double by, Resource stepFactor); Resource normalize(Resource r, Resource minimumResource,
      Resource maximumResource); abstract Resource normalize(Resource r, Resource minimumResource,
                                     Resource maximumResource, 
                                     Resource stepFactor); abstract Resource roundUp(Resource r, Resource stepFactor); abstract Resource roundDown(Resource r, Resource stepFactor); abstract float divide(
      Resource clusterResource, Resource numerator, Resource denominator); abstract boolean isInvalidDivisor(Resource r); abstract float ratio(Resource a, Resource b); abstract Resource divideAndCeil(Resource numerator, int denominator); abstract boolean fitsIn(Resource cluster,
      Resource smaller, Resource bigger);  }
@Test(timeout = 10000) public void testFitsIn() { Resource cluster = Resource.newInstance(1024, 1); if (resourceCalculator instanceof DefaultResourceCalculator) { Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(2, 1))); Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(2, 2))); Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(1, 2))); Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(1, 1))); Assert.assertFalse(resourceCalculator.fitsIn(cluster, Resource.newInstance(2, 1), Resource.newInstance(1, 2))); } else if (resourceCalculator instanceof DominantResourceCalculator) { Assert.assertFalse(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(2, 1))); Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(2, 2))); Assert.assertTrue(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(1, 2))); Assert.assertFalse(resourceCalculator.fitsIn(cluster, Resource.newInstance(1, 2), Resource.newInstance(1, 1))); Assert.assertFalse(resourceCalculator.fitsIn(cluster, Resource.newInstance(2, 1), Resource.newInstance(1, 2))); } }