File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
approvaltests/src/main/java/org/approvaltests Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 99import org .approvaltests .core .Options ;
1010import org .approvaltests .namer .NamedEnvironment ;
1111import org .approvaltests .namer .NamerFactory ;
12- import org .approvaltests .writers .ApprovalWriterFactory ;
1312import org .approvaltests .writers .ComponentApprovalWriter ;
1413import org .approvaltests .writers .DefaultApprovalWriterFactory ;
1514import org .approvaltests .writers .ImageApprovalWriter ;
15+ import org .approvaltests .writers .PaintableApprovalWriter ;
1616import org .lambda .functions .Function1 ;
1717
1818import com .spun .swing .Paintable ;
@@ -25,6 +25,10 @@ public class AwtApprovals
2525 {
2626 DefaultApprovalWriterFactory .addDefault (c -> c instanceof Component ,
2727 (Object c , Options o ) -> new ComponentApprovalWriter ((Component ) c ));
28+ DefaultApprovalWriterFactory .addDefault (o -> o instanceof Paintable ,
29+ (c , o ) -> new PaintableApprovalWriter ((Paintable ) c ));
30+ DefaultApprovalWriterFactory .addDefault (o -> o instanceof PaintableMultiFrame ,
31+ (c , o ) -> new PaintableMultiframeWriter ((PaintableMultiFrame ) c ));
2832 }
2933 public static void verify (Image image )
3034 {
Original file line number Diff line number Diff line change @@ -17,25 +17,16 @@ public class DefaultApprovalWriterFactory
1717 static
1818 {
1919 addDefault (o -> o instanceof ResultSet , (c , o ) -> new ResultSetApprovalWriter ((ResultSet ) c ));
20+ addDefault (o -> o instanceof File , (c , o ) -> new FileApprovalWriter ((File ) c ));
21+ addDefault (o -> o instanceof ResultSet , (c , o ) -> new ResultSetApprovalWriter ((ResultSet ) c ));
2022 }
2123 public static ApprovalWriterFactory getDefaultFactory ()
2224 {
2325 return (c , o ) -> {
24- Tuple <Function1 <Object , Boolean >, ApprovalWriterFactory > first = factories
25- .first (t -> t .getFirst ().call (c ));
26+ Tuple <Function1 <Object , Boolean >, ApprovalWriterFactory > first = factories .first (t -> t .getFirst ().call (c ));
2627 if (first != null )
27- { return first .getSecond ().create (c , o ); }
28- if (c instanceof File )
29- {
30- return new FileApprovalWriter ((File ) c );
31- }
32- else if (c instanceof Paintable )
33- {
34- return new PaintableApprovalWriter ((Paintable ) c );
35- }
36- else if (c instanceof PaintableMultiFrame )
3728 {
38- return new PaintableMultiframeWriter (( PaintableMultiFrame ) c );
29+ return first . getSecond (). create ( c , o );
3930 }
4031 else
4132 {
You can’t perform that action at this time.
0 commit comments