package de.retest.recheck.ui.review;

import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

import de.retest.recheck.report.ActionReplayResult;
import de.retest.recheck.ui.descriptors.IdentifyingAttributes;
import de.retest.recheck.ui.diff.ElementDifference;
import de.retest.recheck.ui.diff.RootElementDifference;
import de.retest.recheck.ui.image.Screenshot;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor( access = AccessLevel.PRIVATE )
public class ScreenshotChanges {

	private static final ScreenshotChanges EMPTY_SCREENSHOTS = new ScreenshotChanges( Collections.emptyMap() );

	private final Map<IdentifyingAttributes, Screenshot> screenshotMap;

	public static ScreenshotChanges empty() {
		return EMPTY_SCREENSHOTS;
	}

	public static ScreenshotChanges actual( final ActionReplayResult result ) {
		return new ScreenshotChanges( result.getStateDifference().getRootElementDifferences().stream() //
				.map( RootElementDifference::getElementDifference ) //
				.collect( Collectors.toMap( ElementDifference::getIdentifyingAttributes,
						ElementDifference::getActualScreenshot ) ) );
	}

	public Screenshot getScreenshot( final IdentifyingAttributes attribute ) {
		return screenshotMap.get( attribute );
	}
}

@@ -83,16 +83,53 @@
 il.Map;%0A
+import java.util.function.Predicate;%0A
 import j
@@ -1012,24 +1012,68 @@
 stream() //%0A
+%09%09%09%09.filter( actualScreenshotNotNull() ) //%0A
 %09%09%09%09.map( Ro
@@ -1248,24 +1248,170 @@
  ) ) );%0A%09%7D%0A%0A
+%09private static Predicate%3CRootElementDifference%3E actualScreenshotNotNull() %7B%0A%09%09return difference -%3E difference.getActualScreenshot() != null;%0A%09%7D%0A%0A
 %09public Scre

Fix null screenshots