mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 08:22:13 +02:00
Remove the use of InjectRule in UrlFetchUtilsTest
Random used to be a static variable which requires InjectRule to mock it in unit tests. It is now a singleton, which ensures that the same instance is called every time and Random.nextBytes() generates results that distribute uniformly between each call. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217592767
This commit is contained in:
parent
84c3544097
commit
4140ef6315
5 changed files with 35 additions and 12 deletions
|
@ -80,6 +80,7 @@ public final class NordnUploadAction implements Runnable {
|
|||
private final String actionLogId = String.valueOf(1000000000 + new Random().nextInt(1000000000));
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject Random random;
|
||||
@Inject LordnRequestInitializer lordnRequestInitializer;
|
||||
@Inject URLFetchService fetchService;
|
||||
@Inject @Config("tmchMarksdbUrl") String tmchMarksdbUrl;
|
||||
|
@ -138,7 +139,7 @@ public final class NordnUploadAction implements Runnable {
|
|||
"LORDN upload task %s: Sending to URL: %s ; data: %s", actionLogId, url, csvData);
|
||||
HTTPRequest req = new HTTPRequest(new URL(url), POST, validateCertificate().setDeadline(60d));
|
||||
lordnRequestInitializer.initialize(req, tld);
|
||||
setPayloadMultipart(req, "file", "claims.csv", CSV_UTF_8, csvData);
|
||||
setPayloadMultipart(req, "file", "claims.csv", CSV_UTF_8, csvData, random);
|
||||
HTTPResponse rsp = fetchService.fetch(req);
|
||||
logger.atInfo().log(
|
||||
"LORDN upload task %s response: HTTP response code %d, response data: %s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue