Legofy { public Bitmap convert(Bitmap bitmap) { int brickSize = getActualBrickSize(bitmap); int bricksInWidth = getBricksInWidth(bitmap, brickSize); int bricksInHeight = getBricksInHeight(bitmap, brickSize); return createLegofiedBitmap(bitmap, brickSize, bricksInWidth, bricksInHeight); } protected  Legofy(Context context, BitmapWrapper bitmapWrapper, BrickDrawer brickDrawer); private  Legofy(Context context); static Legofy with(Context context); Legofy amountOfBricks(int minimumBricks); Bitmap convert(Bitmap bitmap); int getBricksInWidth(); static final int MINIMUM_BRICKSIZE; static final int DEFAULT_AMOUNTOFBRICKS; static final int DEFAULT_MAXOUTPUTSIZE; static final int DEFAULT_SCALE; }
@Test public void setBrickSizeBrickDrawer() throws Exception { Bitmap mockBitmap = createMockBitmap(234, 257); legofy.convert(mockBitmap); verify(mockDrawer).setBitmap(any(Resources.class), any(Bitmap.class), eq(23)); }
@Test public void convertBitmap() throws Exception { Bitmap mockBitmap = createMockBitmap(234, 257); Bitmap convertedBitmap = legofy.convert(mockBitmap); assertThat(convertedBitmap).isNotNull(); }
@Test public void widthMultipleOfBricks() throws Exception { Bitmap mockBitmap = createMockBitmap(234, 257); Bitmap convertedBitmap = legofy.convert(mockBitmap); assertThat(convertedBitmap.getWidth()).isEqualTo(230); }
@Test public void heightMultipleOfBricks() throws Exception { Bitmap mockBitmap = createMockBitmap(234, 257); Bitmap convertedBitmap = legofy.convert(mockBitmap); assertThat(convertedBitmap.getHeight()).isEqualTo(253); }
@Test public void useResourcesFromContext() throws Exception { Resources mockResources = mock(Resources.class); doReturn(mockResources).when(mockContext).getResources(); Bitmap mockBitmap = createMockBitmap(BRICK_SIZE, BRICK_SIZE); legofy.convert(mockBitmap); verify(mockDrawer).setBitmap(eq(mockResources), any(Bitmap.class), anyInt()); }
@Test public void setconvertedBitmapToBrickDrawer() throws Exception { Bitmap mockBitmap = createMockBitmap(BRICK_SIZE, BRICK_SIZE); Bitmap convertedBitmap = legofy.convert(mockBitmap); verify(mockDrawer).setBitmap(any(Resources.class), eq(convertedBitmap), anyInt()); }