File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,20 @@ public class DownloaderFactory {
1111 private final static DownloaderType DEFAULT_DOWNLOADER = DownloaderType .REAL ;
1212
1313 /**
14+ * <p>
15+ * Returns a implementation of a downloader.
16+ * </p>
17+ * <p>
18+ * If the system property "downloader" is set and is one of {@link DownloaderType},
19+ * then a downloader of that type is returned.
20+ * It can be passed in with gradle by adding the argument -Ddownloader=abcd,
21+ * where abcd is one of {@link DownloaderType}
22+ * </p>
23+ * <p>
24+ * Otherwise it falls back to {@link DownloaderFactory#DEFAULT_DOWNLOADER}.
25+ * Change this during development on the local machine to use a different downloader.
26+ * </p>
27+ *
1428 * @param path The path to the folder where mocks are saved/retrieved.
1529 * Preferably starting with {@link DownloaderFactory#RESOURCE_PATH}
1630 */
Original file line number Diff line number Diff line change 1414
1515import javax .annotation .Nonnull ;
1616
17+ /**
18+ * <p>
19+ * Mocks requests by using json files created by {@link RecordingDownloader}
20+ * </p>
21+ */
1722class MockDownloader extends Downloader {
1823
1924 private final String path ;
Original file line number Diff line number Diff line change 1616
1717import javax .annotation .Nonnull ;
1818
19+ /**
20+ * <p>
21+ * Relays requests to {@link DownloaderTestImpl} and saves the request/response pair into a json file.
22+ * </p>
23+ * <p>
24+ * Those files are used by {@link MockDownloader}.
25+ * </p>
26+ * <p>
27+ * The files <b>must</b> be created on the local dev environment
28+ * and recreated when the requests made by a test class change.
29+ * </p>
30+ */
1931class RecordingDownloader extends Downloader {
2032
2133 public final static String FILE_NAME_PREFIX = "generated_mock_" ;
2234
2335 private int index = 0 ;
2436 private final String path ;
2537
38+ /**
39+ * Creates the folder described by {@code stringPath} if it does not exists.
40+ * Deletes existing files starting with {@link RecordingDownloader#FILE_NAME_PREFIX}.
41+ * @param stringPath Path to the folder where the json files will be saved to.
42+ */
2643 public RecordingDownloader (String stringPath ) throws IOException {
2744 this .path = stringPath ;
2845 Path path = Paths .get (stringPath );
You can’t perform that action at this time.
0 commit comments