LinearCenteredShape extends LinearShape { @Override protected float getFirstItemLeftPosition() { float itemSize = getShapeConfig().getItemSize(); float itemMargin = getShapeConfig().getItemMargin(); float center = getCenter(); int numberOfElements = getShapeConfig().getNumberOfElements(); return center - numberOfElements * (itemSize / 2 + itemMargin / 2); } LinearCenteredShape(ShapeConfig shapeConfig);   }
@Test public void shouldCalculateLeftPositionsUsingOneCenteredLinearDistributionUsingItemSizeAndMargin() { int numberOfElements = 10; ShapeConfig shapeConfig = givenAShapeConfig(numberOfElements, ANY_VIEW_WIDTH, ANY_VIEW_HEIGHT, ANY_ITEM_SIZE, ANY_ITEM_MARGIN); shape = getShape(shapeConfig); shape.calculate(); float expectedLeft = getFirstItemLeftPosition(shapeConfig); for (int i = 0; i < numberOfElements; i++) { assertEquals(expectedLeft, shape.getXForItemAtPosition(i), DELTA); expectedLeft += ANY_ITEM_SIZE + ANY_ITEM_MARGIN; } }