@@ -123,6 +123,15 @@ public WireMockContainer withCliArg(String arg) {
123123 return this ;
124124 }
125125
126+ /**
127+ * Add mapping JSON file from its value
128+ * @param json JSON sting
129+ * @return This instance
130+ */
131+ public WireMockContainer withMappingFromJSON (String json ) {
132+ return withMapping (Integer .toString (json .hashCode ()), json );
133+ }
134+
126135 /**
127136 * Adds a JSON mapping stub to WireMock configuration
128137 * @param name Name of the mapping stub
@@ -146,6 +155,17 @@ public WireMockContainer withMappingFromResource(String name, Class<?> resource,
146155 return withMapping (name , resource .getSimpleName () + "/" + resourceJson );
147156 }
148157
158+ /**
159+ * Loads mapping stub from the class resource
160+ * @param resource Resource class. Name of the class will be appended to the resource path
161+ * @param resourceJson Mapping definition file
162+ * @return this instance
163+ */
164+ public WireMockContainer withMappingFromResource (Class <?> resource , String resourceJson ) {
165+ final String id = resource .getName () + "_" + resourceJson ;
166+ return withMapping (id , resource .getSimpleName () + "/" + resourceJson );
167+ }
168+
149169 /**
150170 * @deprecated use {@link #withMappingFromResource(String, Class, String)}
151171 */
@@ -170,6 +190,16 @@ public WireMockContainer withMappingFromResource(String name, String resourceNam
170190 }
171191 }
172192
193+ /**
194+ * Loads mapping stub from the resource file
195+ * @param resourceName Resource name and path
196+ * @return this instance
197+ */
198+ public WireMockContainer withMappingFromResource (String resourceName ) {
199+ String id = resourceName .replace ('/' , '_' );
200+ return withMappingFromResource (id , resourceName );
201+ }
202+
173203 /**
174204 * Loads mapping stub from the resource file
175205 * @param name Name of the mapping stub
@@ -185,22 +215,50 @@ public WireMockContainer withMappingFromResource(String name, URL url) {
185215 }
186216 }
187217
218+ /**
219+ * Adds file
220+ * @param name ID to be used
221+ * @param file File to add
222+ * @return This instance
223+ */
188224 public WireMockContainer withFile (String name , File file ) {
189225 mappingFiles .put (name , MountableFile .forHostPath (file .getPath ()));
190226 // TODO: Prevent duplication
191227 return this ;
192228 }
193229
230+ /**
231+ * Adds file
232+ * @param file File to add
233+ * @return This instance
234+ */
235+ public WireMockContainer withFile (File file ) {
236+ mappingFiles .put (file .getName (), MountableFile .forHostPath (file .getPath ()));
237+ // TODO: Prevent duplication
238+ return this ;
239+ }
240+
194241 public WireMockContainer withFileFromResource (String name , String classpathResource ) {
195242 mappingFiles .put (name , MountableFile .forClasspathResource (classpathResource ));
196243 // TODO: Prevent duplication
197244 return this ;
198245 }
199246
247+ public WireMockContainer withFileFromResource (String classpathResource ) {
248+ String id = classpathResource .replace ('/' , '_' );
249+ // TODO: Prevent duplication
250+ return withFileFromResource (id , classpathResource );
251+ }
252+
200253 public WireMockContainer withFileFromResource (String name , Class <?> resource , String filename ) {
201254 return withFileFromResource (name , resource .getName ().replace ('.' , '/' ) + "/" + filename );
202255 }
203256
257+ public WireMockContainer withFileFromResource (Class <?> resource , String filename ) {
258+ String id = resource .getSimpleName () + "_" + filename ;
259+ return withFileFromResource (id , resource , filename );
260+ }
261+
204262 /**
205263 * Add extension that will be loaded from the specified JAR file.
206264 * @param id Unique ID of the extension, for logging purposes
0 commit comments