public void insertImage(TemporaryImage temporaryImage, Image image) {
checkNotNull(temporaryImage, "temporaryImage must not be null");
checkNotNull(image, "image must not be null");
- checkArgument(image.getId().equals(temporaryImage.getId()), "image IDs must match");
+ checkArgument(image.getInternalId().equals(temporaryImage.getId()), "image IDs must match");
try {
InsertToken insertToken = insertTokenSupplier.apply(image);
insertTokens.put(image.getId(), insertToken);
linkTemplateContext.set("src", "/" + image.getKey());
linkTemplateContext.set("forceDownload", true);
} else {
- linkTemplateContext.set("src", "getImage.html?image=" + image.getId());
+ linkTemplateContext.set("src", "getImage.html?image=" + image.getInternalId());
}
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
public class ImageInserterTest {
private final TemporaryImage temporaryImage = when(mock(TemporaryImage.class).getId()).thenReturn("image-id").getMock();
- private final Image image = when(mock(Image.class).getId()).thenReturn("image-id").getMock();
+ private final Image image = when(mock(Image.class).getInternalId()).thenReturn("image-id").getMock();
private final FreenetInterface freenetInterface = mock(FreenetInterface.class);
private final InsertToken insertToken = mock(InsertToken.class);
private final Function<Image, InsertToken> insertTokenSupplier = when(mock(Function.class).apply(any(Image.class))).thenReturn(insertToken).getMock();
@Before
public void setupImage() {
when(image.getId()).thenReturn("image-id");
+ when(image.getInternalId()).thenReturn("internal-image-id");
when(image.getKey()).thenReturn("image-key");
when(image.isInserted()).thenReturn(true);
when(image.getWidth()).thenReturn(640);
String result = String.valueOf(imageLinkFilter.format(templateContext, image, ImmutableMap.<String, Object>of()));
Element imageElement = getSingleElement(result);
assertThat(imageElement.attr("class"), is(""));
- assertThat(imageElement.attr("src"), is("getImage.html?image=image-id"));
+ assertThat(imageElement.attr("src"), is("getImage.html?image=internal-image-id"));
assertThat(imageElement.attr("title"), is("image title"));
assertThat(imageElement.attr("alt"), is("image description"));
assertThat(imageElement.attr("width"), is("640"));