mirror of
https://github.com/google/nomulus
synced 2025-12-23 14:25:44 +00:00
Add TLD identifier to premium terms filename and header (#2644)
https://b.corp.google.com/issues/390053672 This makes it easier to identify what file you're looking at, at a glance
This commit is contained in:
@@ -54,7 +54,8 @@ public class ExportPremiumTermsAction implements Runnable {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
static final MediaType EXPORT_MIME_TYPE = MediaType.PLAIN_TEXT_UTF_8;
|
||||
static final String PREMIUM_TERMS_FILENAME = "CONFIDENTIAL_premium_terms.txt";
|
||||
static final String TLD_IDENTIFIER_FORMAT = "# TLD: %s";
|
||||
static final String PREMIUM_TERMS_FILENAME_FORMAT = "CONFIDENTIAL_premium_terms_%s.txt";
|
||||
|
||||
@Inject DriveConnection driveConnection;
|
||||
|
||||
@@ -127,7 +128,7 @@ public class ExportPremiumTermsAction implements Runnable {
|
||||
try {
|
||||
String fileId =
|
||||
driveConnection.createOrUpdateFile(
|
||||
PREMIUM_TERMS_FILENAME,
|
||||
String.format(PREMIUM_TERMS_FILENAME_FORMAT, tldStr),
|
||||
EXPORT_MIME_TYPE,
|
||||
tld.getDriveFolderId(),
|
||||
getFormattedPremiumTerms(tld).getBytes(UTF_8));
|
||||
@@ -150,11 +151,9 @@ public class ExportPremiumTermsAction implements Runnable {
|
||||
.map(PremiumEntry::toString)
|
||||
.collect(ImmutableSortedSet.toImmutableSortedSet(String::compareTo));
|
||||
|
||||
return Joiner.on("\n")
|
||||
.appendTo(
|
||||
new StringBuilder(),
|
||||
Iterables.concat(ImmutableList.of(exportDisclaimer.trim()), premiumTerms))
|
||||
.append("\n")
|
||||
.toString();
|
||||
String tldIdentifier = String.format(TLD_IDENTIFIER_FORMAT, tldStr);
|
||||
Iterable<String> commentsAndTerms =
|
||||
Iterables.concat(ImmutableList.of(exportDisclaimer.trim(), tldIdentifier), premiumTerms);
|
||||
return Joiner.on("\n").join(commentsAndTerms) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.export;
|
||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.export.ExportPremiumTermsAction.EXPORT_MIME_TYPE;
|
||||
import static google.registry.export.ExportPremiumTermsAction.PREMIUM_TERMS_FILENAME;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.deleteTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
@@ -52,11 +51,10 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link ExportPremiumTermsAction}. */
|
||||
public class ExportPremiumTermsActionTest {
|
||||
|
||||
private static final String DISCLAIMER_WITH_NEWLINE = "# Premium Terms Export Disclaimer\n";
|
||||
private static final ImmutableList<String> PREMIUM_NAMES =
|
||||
ImmutableList.of("2048,USD 549", "0,USD 549");
|
||||
private static final String EXPECTED_FILE_CONTENT =
|
||||
DISCLAIMER_WITH_NEWLINE + "0, 549.00\n" + "2048, 549.00\n";
|
||||
"# Premium Terms Export Disclaimer\n# TLD: tld\n0, 549.00\n" + "2048, 549.00\n";
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationTestExtension jpa =
|
||||
@@ -69,7 +67,7 @@ public class ExportPremiumTermsActionTest {
|
||||
ExportPremiumTermsAction action = new ExportPremiumTermsAction();
|
||||
action.response = response;
|
||||
action.driveConnection = driveConnection;
|
||||
action.exportDisclaimer = DISCLAIMER_WITH_NEWLINE;
|
||||
action.exportDisclaimer = "# Premium Terms Export Disclaimer\n";
|
||||
action.tldStr = tld;
|
||||
action.run();
|
||||
}
|
||||
@@ -94,7 +92,7 @@ public class ExportPremiumTermsActionTest {
|
||||
|
||||
verify(driveConnection)
|
||||
.createOrUpdateFile(
|
||||
PREMIUM_TERMS_FILENAME,
|
||||
"CONFIDENTIAL_premium_terms_tld.txt",
|
||||
EXPORT_MIME_TYPE,
|
||||
"folder_id",
|
||||
EXPECTED_FILE_CONTENT.getBytes(UTF_8));
|
||||
@@ -157,7 +155,7 @@ public class ExportPremiumTermsActionTest {
|
||||
|
||||
verify(driveConnection)
|
||||
.createOrUpdateFile(
|
||||
PREMIUM_TERMS_FILENAME,
|
||||
"CONFIDENTIAL_premium_terms_tld.txt",
|
||||
EXPORT_MIME_TYPE,
|
||||
"bad_folder_id",
|
||||
EXPECTED_FILE_CONTENT.getBytes(UTF_8));
|
||||
|
||||
Reference in New Issue
Block a user