Source:
public void testRecomputePictureViews() throws Exception { DocumentModel doc = session.createDocumentModel("/", "pictureDoc", "Picture"); Blob blob = Blobs.createBlob(FileUtils.getResourceFileFromContext("images/test.jpg"), "image/jpeg", StandardCharsets.UTF_8.name(), "test.jpg"); doc.setPropertyValue("file:content", (Serializable) blob); doc = session.createDocument(doc); txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); List<Serializable> pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertFalse(pictureViews.isEmpty()); MultiviewPicture multiviewPicture = doc.getAdapter(MultiviewPicture.class); PictureView picView = multiviewPicture.getView("Medium"); ImageInfo imageBlobInfo = imagingService.getImageInfo(picView.getBlob()); ImageInfo resizedImageInfo = picView.getImageInfo(); assertEquals(imageBlobInfo.getHeight(), resizedImageInfo.getHeight()); assertEquals(imageBlobInfo.getWidth(), resizedImageInfo.getWidth()); assertEquals(imageBlobInfo.getWidth(), picView.getWidth()); assertEquals(imageBlobInfo.getHeight(), resizedImageInfo.getHeight()); doc.setPropertyValue("picture:views", new ArrayList<>()); session.saveDocument(doc); txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertTrue(pictureViews.isEmpty()); Map<String, String> parameters = Collections.singletonMap("query", "SELECT * FROM Document WHERE ecm:mixinType = 'Picture'"); try (OperationContext ctx = new OperationContext(session)) { automationService.run(ctx, RecomputePictureViews.ID, parameters); } txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertFalse(pictureViews.isEmpty()); }

Target:
public void testRecomputePictureViews() throws Exception { DocumentModel doc = session.createDocumentModel("/", "pictureDoc", "Picture"); Blob blob = Blobs.createBlob(FileUtils.getResourceFileFromContext("images/test.jpg"), "image/jpeg", StandardCharsets.UTF_8.name(), "test.jpg"); doc.setPropertyValue("file:content", (Serializable) blob); doc = session.createDocument(doc); txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); List<Serializable> pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertFalse(pictureViews.isEmpty()); doc.setPropertyValue("picture:views", new ArrayList<>()); session.saveDocument(doc); txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertTrue(pictureViews.isEmpty()); Map<String, String> parameters = Collections.singletonMap("query", "SELECT * FROM Document WHERE ecm:mixinType = 'Picture'"); try (OperationContext ctx = new OperationContext(session)) { automationService.run(ctx, RecomputePictureViews.ID, parameters); } txFeature.nextTransaction(); doc = session.getDocument(doc.getRef()); pictureViews = (List<Serializable>) doc.getPropertyValue("picture:views"); assertNotNull(pictureViews); assertFalse(pictureViews.isEmpty()); }