/** * The front has the points [0.1, 0.9], [0.2, 0.8], [0.3, 0.7], [0.4, 0.6]. The inverted front is * [0.9, 0.1], [0.8, 0.2], [0.7, 0.3], [0.6, 0.4] */ @Test public void shouldGetInvertedFrontReturnTheCorrectFrontIfItComposedOfFourPoints() { int numberOfDimensions = 2; int numberOfPoints = 4; Point point1 = new ArrayPoint(numberOfDimensions); point1.setDimensionValue(0, 0.1); point1.setDimensionValue(1, 0.9); Point point2 = new ArrayPoint(numberOfDimensions); point2.setDimensionValue(0, 0.2); point2.setDimensionValue(1, 0.8); Point point3 = new ArrayPoint(numberOfDimensions); point3.setDimensionValue(0, 0.3); point3.setDimensionValue(1, 0.7); Point point4 = new ArrayPoint(numberOfDimensions); point4.setDimensionValue(0, 0.4); point4.setDimensionValue(1, 0.6); Front front = new ArrayFront(numberOfPoints, numberOfDimensions); front.setPoint(0, point1); front.setPoint(1, point2); front.setPoint(2, point3); front.setPoint(3, point4); Front newFront = FrontUtils.getInvertedFront(front); assertEquals(0.9, newFront.getPoint(0).getDimensionValue(0), EPSILON); assertEquals(0.1, newFront.getPoint(0).getDimensionValue(1), EPSILON); assertEquals(0.8, newFront.getPoint(1).getDimensionValue(0), EPSILON); assertEquals(0.2, newFront.getPoint(1).getDimensionValue(1), EPSILON); assertEquals(0.7, newFront.getPoint(2).getDimensionValue(0), EPSILON); assertEquals(0.3, newFront.getPoint(2).getDimensionValue(1), EPSILON); assertEquals(0.6, newFront.getPoint(3).getDimensionValue(0), EPSILON); assertEquals(0.4, newFront.getPoint(3).getDimensionValue(1), EPSILON); }
/** Case C: the front has the point [3.0, -2.0]. The inverted front is [0.0, 1.0] */ @Test public void shouldGetInvertedFrontReturnTheCorrectFrontIfItComposedOfOnePointCaseC() { int numberOfDimensions = 2; int numberOfPoints = 1; Point point1 = new ArrayPoint(numberOfDimensions); point1.setDimensionValue(0, 3.0); point1.setDimensionValue(1, -2.0); Front front = new ArrayFront(numberOfPoints, numberOfDimensions); front.setPoint(0, point1); Front newFront = FrontUtils.getInvertedFront(front); assertEquals(0.0, newFront.getPoint(0).getDimensionValue(0), EPSILON); assertEquals(1.0, newFront.getPoint(0).getDimensionValue(1), EPSILON); }