1616public class Expect {
1717 private final SnapshotVerifier snapshotVerifier ;
1818 private final Method testMethod ;
19-
19+ private final Map < String , String > headers = new HashMap <>();
2020 private SnapshotSerializer snapshotSerializer ;
2121 private SnapshotComparator snapshotComparator ;
2222 private List <SnapshotReporter > snapshotReporters ;
2323 private String scenario ;
2424
25- private final Map <String , String > headers = new HashMap <>();
26-
2725 public static Expect of (SnapshotVerifier snapshotVerifier , Method method ) {
2826 return new Expect (snapshotVerifier , method );
2927 }
3028
3129 /**
32- * Make an assertion on the given input parameters against what already exists
30+ * Make an assertion on the given input parameters against what already exists.
3331 *
3432 * <p>If you were previously using varargs and see an error - you can fix the error using
3533 * "toMatchSnapshotLegacy", however, a better approach is to use the ".scenario()" feature as
@@ -51,7 +49,7 @@ public void toMatchSnapshot(Object object) {
5149 if (scenario != null ) {
5250 snapshotContext .setScenario (scenario );
5351 }
54- snapshotContext .header .putAll (headers );
52+ snapshotContext .getHeader () .putAll (headers );
5553
5654 snapshotContext .checkValidContext ();
5755
@@ -73,7 +71,7 @@ public Expect scenario(String scenario) {
7371 }
7472
7573 /**
76- * Apply a custom serializer for this snapshot
74+ * Apply a custom serializer for this snapshot.
7775 *
7876 * @param serializer your custom serializer
7977 * @return Snapshot
@@ -84,7 +82,7 @@ public Expect serializer(SnapshotSerializer serializer) {
8482 }
8583
8684 /**
87- * Apply a custom serializer for this snapshot
85+ * Apply a custom serializer for this snapshot.
8886 *
8987 * @param name - the {name} attribute serializer.{name} from snapshot.properties
9088 * @return Snapshot
@@ -95,7 +93,22 @@ public Expect serializer(String name) {
9593 }
9694
9795 /**
98- * Apply a custom comparator for this snapshot
96+ * Apply a custom serializer for this snapshot.
97+ *
98+ * @param serializer your custom serializer
99+ * @return this
100+ * @see au.com.origin.snapshots.serializers.SnapshotSerializer
101+ * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer
102+ * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer
103+ */
104+ @ SneakyThrows
105+ public Expect serializer (Class <? extends SnapshotSerializer > serializer ) {
106+ this .snapshotSerializer = serializer .getConstructor ().newInstance ();
107+ return this ;
108+ }
109+
110+ /**
111+ * Apply a custom comparator for this snapshot.
99112 *
100113 * @param comparator your custom comparator
101114 * @return Snapshot
@@ -106,7 +119,7 @@ public Expect comparator(SnapshotComparator comparator) {
106119 }
107120
108121 /**
109- * Apply a custom comparator for this snapshot
122+ * Apply a custom comparator for this snapshot.
110123 *
111124 * @param name the {name} attribute comparator.{name} from snapshot.properties
112125 * @return Snapshot
@@ -118,7 +131,7 @@ public Expect comparator(String name) {
118131
119132 /**
120133 * Apply a list of custom reporters for this snapshot This will replace the default reporters
121- * defined in the config
134+ * defined in the config.
122135 *
123136 * @param reporters your custom reporters
124137 * @return Snapshot
@@ -130,7 +143,7 @@ public Expect reporters(SnapshotReporter... reporters) {
130143
131144 /**
132145 * Apply a list of custom reporters for this snapshot This will replace the default reporters
133- * defined in the config
146+ * defined in the config.
134147 *
135148 * @param name the {name} attribute reporters.{name} from snapshot.properties
136149 * @return Snapshot
@@ -140,22 +153,6 @@ public Expect reporters(String name) {
140153 return this ;
141154 }
142155
143- /**
144- * Apply a custom serializer for this snapshot.
145- *
146- * @param serializer your custom serializer
147- * @return this
148- * @see au.com.origin.snapshots.serializers.SnapshotSerializer
149- * <p>Example implementations
150- * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer
151- * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer
152- */
153- @ SneakyThrows
154- public Expect serializer (Class <? extends SnapshotSerializer > serializer ) {
155- this .snapshotSerializer = serializer .getConstructor ().newInstance ();
156- return this ;
157- }
158-
159156 /**
160157 * Add anything you like to the snapshot header.
161158 *
0 commit comments