final byte[] bytes = {01};
final BufferedInputStream bufferedInputStream = mock(BufferedInputStream.class);
final Pair<Integer, Integer> dimension = mock(Pair.class);
final Pair<String, String> filenameAndExtension = mock(Pair.class);
final CssClass cssClass = mock(CssClass.class);
doNothing()
.when(defaultImageConversionService)
.validateUrl(url);
doReturn(filenameAndExtension)
.when(defaultImageConversionService)
.validateFilenameAndExtension(url);
when(filenameAndExtension.getLeft())
.thenReturn(filename);
when(filenameAndExtension.getRight())
.thenReturn(fileExtension);
doReturn(cssClassName)
.when(defaultImageConversionService)
.determineCssClassName(filename);
when(commonObjectFactory.newBufferedInputStream(any(URL.class)))
.thenReturn(bufferedInputStream);
doReturn(bytes)
.when(defaultImageConversionService)
.readInputStreamToBytes(bufferedInputStream);
when(base64Encoder.base64EncodeBytes(bytes))
.thenReturn(base64EncodedBytes);
doReturn(dimension)
.when(defaultImageConversionService)
.getImageDimension(bytes);
doReturn(cssEntry)
.when(defaultImageConversionService)
.determineCssEntry(cssClassName, fileExtension, base64EncodedBytes, dimension);
when(commonObjectFactory.newCssClass(cssClassName, cssEntry))
.thenReturn(cssClass);
final CssClass result = defaultImageConversionService.convert(url);
assertThat(result, is(cssClass));
final InOrder inOrder = inOrder(defaultImageConversionService, fileUtils, base64Encoder, commonObjectFactory);