mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 16:32:11 +02:00
Move thrown.expect() right before the throwing statement
aka regexing for fun and profit. This also makes sure that there are no statements after the throwing statement, since these would be dead code. There were a surprising number of places with assertions after the throw, and none of these are actually triggered in tests ever. When I found these, I replaced them with try/catch/rethrow which makes the assertions actually happen: before: // This is the ExceptionRule that checks EppException marshaling thrown.expect(FooException.class); doThrowingThing(); assertSomething(); // Dead code! after: try { doThrowingThing(); assertWithMessage("...").fail(); } catch (FooException e) { assertSomething(); // For EppExceptions: assertAboutEppExceptins().that(e).marshalsToXml(); } To make this work, I added EppExceptionSubject. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135793407
This commit is contained in:
parent
cb8320ff40
commit
f3a0b78145
62 changed files with 519 additions and 450 deletions
|
@ -1145,12 +1145,12 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
|||
|
||||
@Test
|
||||
public void testFailure_alreadyExists() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "Registrar existing already exists");
|
||||
persistResource(new Registrar.Builder()
|
||||
.setClientId("existing")
|
||||
.setIanaIdentifier(1L)
|
||||
.setType(Registrar.Type.REAL)
|
||||
.build());
|
||||
thrown.expect(IllegalStateException.class, "Registrar existing already exists");
|
||||
runCommand(
|
||||
"--name=blobio",
|
||||
"--password=some_password",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
|
@ -86,9 +87,9 @@ public class CreateReservedListCommandTest extends
|
|||
|
||||
@Test
|
||||
public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "A reserved list already exists by this name");
|
||||
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
|
||||
thrown.expect(IllegalArgumentException.class, "A reserved list already exists by this name");
|
||||
runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath);
|
||||
}
|
||||
|
||||
|
@ -169,9 +170,13 @@ public class CreateReservedListCommandTest extends
|
|||
}
|
||||
|
||||
private void runNameTestExpectedFailure(String name, String expectedErrorMsg) throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, expectedErrorMsg);
|
||||
runCommandForced("--name=" + name, "--input=" + reservedTermsPath);
|
||||
assertThat(ReservedList.get(name)).isAbsent();
|
||||
try {
|
||||
runCommandForced("--name=" + name, "--input=" + reservedTermsPath);
|
||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(ReservedList.get(name)).isAbsent();
|
||||
assertThat(e).hasMessage(expectedErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private void runNameTestWithOverride(String name) throws Exception {
|
||||
|
|
|
@ -267,8 +267,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_bothTldStateFlags() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
DateTime now = DateTime.now(UTC);
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.plus(1)),
|
||||
"--initial_tld_state=GENERAL_AVAILABILITY",
|
||||
|
@ -306,8 +306,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_alreadyExists() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
createTld("xn--q9jyb4c");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
runCommandForced("--roid_suffix=NOTDUPE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
|
@ -55,9 +56,13 @@ public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumL
|
|||
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
|
||||
createTld("xn--q9jyb4c");
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setPremiumList(premiumList).build());
|
||||
thrown.expect(IllegalArgumentException.class,
|
||||
"Cannot delete premium list because it is used on these tld(s): xn--q9jyb4c");
|
||||
runCommandForced("--name=" + premiumList.getName());
|
||||
assertThat(PremiumList.get(premiumList.getName())).isPresent();
|
||||
try {
|
||||
runCommandForced("--name=" + premiumList.getName());
|
||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(PremiumList.get(premiumList.getName())).isPresent();
|
||||
assertThat(e)
|
||||
.hasMessage("Cannot delete premium list because it is used on these tld(s): xn--q9jyb4c");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -53,9 +54,13 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
|
|||
public void testFailure_whenReservedListIsInUse() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(reservedList).build());
|
||||
thrown.expect(IllegalArgumentException.class,
|
||||
"Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
||||
runCommandForced("--name=" + reservedList.getName());
|
||||
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
||||
try {
|
||||
runCommandForced("--name=" + reservedList.getName());
|
||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
||||
assertThat(e).hasMessage(
|
||||
"Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,10 +113,10 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
|
||||
@Test
|
||||
public void testFailure_contact_oneDoesNotExist() throws Exception {
|
||||
persistActiveContact("sh8013");
|
||||
thrown.expect(
|
||||
NullPointerException.class,
|
||||
"Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
|
||||
persistActiveContact("sh8013");
|
||||
runCommand(
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
|
@ -159,10 +159,10 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
|
||||
@Test
|
||||
public void testFailure_host_oneDoesNotExist() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
thrown.expect(
|
||||
NullPointerException.class,
|
||||
"Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
runCommand(
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
|
|
|
@ -50,8 +50,8 @@ public class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_oneTldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
createTld("xn--q9jyb4c");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("xn--q9jyb4c", "example");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
|
@ -285,7 +285,7 @@ public class MutatingCommandTest {
|
|||
+ "blockPremiumNames -> [false, true]\n");
|
||||
try {
|
||||
command.execute();
|
||||
fail("Expected transaction to fail with IllegalStateException.");
|
||||
assertWithMessage("Expected transaction to fail with IllegalStateException").fail();
|
||||
} catch (IllegalStateException e) {
|
||||
assertThat(e.getMessage()).contains("Entity changed since init() was called.");
|
||||
assertThat(ofy().load().entity(host1).now()).isNull();
|
||||
|
|
|
@ -257,6 +257,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
@Test
|
||||
public void testFailure_invalidPremiumList() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
|
@ -266,8 +267,8 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_tldExists() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
createTld("blobio-sunrise");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
|
@ -277,13 +278,12 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_registrarExists() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
|
||||
Registrar registrar = Registrar.loadByClientId("TheRegistrar").asBuilder()
|
||||
.setClientId("blobio-1")
|
||||
.setRegistrarName("blobio-1")
|
||||
.build();
|
||||
persistResource(registrar);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
|
|
|
@ -139,8 +139,8 @@ public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsN
|
|||
|
||||
@Test
|
||||
public void testFailure_claimsNoticeForWrongLabel() throws Exception {
|
||||
thrown.expectRootCause(InvalidChecksumException.class);
|
||||
domainApplication = persistResource(newDomainApplication("bad-label.xn--q9jyb4c"));
|
||||
thrown.expectRootCause(InvalidChecksumException.class);
|
||||
runCommand(
|
||||
"--id=4-Q9JYB4C",
|
||||
"--tcn_id=370d0b7c9223372036854775807",
|
||||
|
@ -150,12 +150,11 @@ public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsN
|
|||
|
||||
@Test
|
||||
public void testFailure_sunriseApplication() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
||||
// Add an encoded signed mark to the application to make it a sunrise application.
|
||||
domainApplication = persistResource(domainApplication.asBuilder()
|
||||
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "AAAAA")))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
||||
runCommand(
|
||||
"--id=1-Q9JYB4C",
|
||||
|
|
|
@ -62,7 +62,6 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
|
||||
@Test
|
||||
public void testFailure_noPasscodeOnChangeToReal() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "--passcode is required for REAL registrars.");
|
||||
persistResource(
|
||||
loadByClientId("NewRegistrar")
|
||||
.asBuilder()
|
||||
|
@ -70,6 +69,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
.setIanaIdentifier(null)
|
||||
.setPhonePasscode(null)
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "--passcode is required for REAL registrars.");
|
||||
runCommand("--registrar_type=REAL", "--iana_id=1000", "--force", "NewRegistrar");
|
||||
}
|
||||
|
||||
|
|
|
@ -91,60 +91,60 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidSmd() throws Exception {
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
String smdFile = writeToTmpFile(INVALID_SMD);
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_revokedSmd() throws Exception {
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
DateTime now = new DateTime(UTC);
|
||||
SignedMarkRevocationList.create(now, ImmutableMap.of(ACTIVE_SMD_ID, now)).save();
|
||||
String smdFile = writeToTmpFile(ACTIVE_SMD);
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_revokedTmv() throws Exception {
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
String smdFile = writeToTmpFile(REVOKED_TMV_SMD);
|
||||
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unparseableXml() throws Exception {
|
||||
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
|
||||
String smdFile = writeToTmpFile(base64().encode("This is not XML!".getBytes(UTF_8)));
|
||||
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badlyEncodedData() throws Exception {
|
||||
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
|
||||
String smdFile = writeToTmpFile("Bad base64 data ~!@#$#@%%$#^$%^&^**&^)(*)(_".getBytes(UTF_8));
|
||||
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_wrongLabel() throws Exception {
|
||||
thrown.expectRootCause(RequiredParameterMissingException.class);
|
||||
String smdFile = writeToTmpFile(DIFFERENT_LABEL_SMD);
|
||||
thrown.expectRootCause(RequiredParameterMissingException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonExistentApplication() throws Exception {
|
||||
thrown.expectRootCause(IllegalArgumentException.class);
|
||||
String smdFile = writeToTmpFile(ACTIVE_SMD);
|
||||
thrown.expectRootCause(IllegalArgumentException.class);
|
||||
runCommand("--id=3-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_deletedApplication() throws Exception {
|
||||
thrown.expectRootCause(IllegalArgumentException.class);
|
||||
persistResource(domainApplication.asBuilder().setDeletionTime(new DateTime(UTC)).build());
|
||||
String smdFile = writeToTmpFile(ACTIVE_SMD);
|
||||
thrown.expectRootCause(IllegalArgumentException.class);
|
||||
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,8 +481,6 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_outOfOrder() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "The TLD states are chronologically out of order");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -490,14 +488,13 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "The TLD states are chronologically out of order");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_laterTransitionScheduled() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
" when there is a later transition already scheduled");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -505,14 +502,14 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.plusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
" when there is a later transition already scheduled");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_inProduction() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"--set_current_tld_state is not safe to use in production.");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -520,6 +517,9 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"--set_current_tld_state is not safe to use in production.");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--set_current_tld_state=SUNRISE",
|
||||
|
|
|
@ -45,101 +45,101 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
}
|
||||
|
||||
public void testFailure_wrongNumberOfFieldsOnFirstLine() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,2012-08-16T00:00:00.0Z,random-extra-field",
|
||||
"DNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_wrongVersion() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"2,2012-08-16T00:00:00.0Z",
|
||||
"DNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_badCreationTime() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_badFirstHeader() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"SNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_badSecondHeader() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-keys,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_badThirdHeader() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-key,insertion-datetimes",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_wrongNumberOfHeaders() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-key,insertion-datetime,extra-field",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_wrongNumberOfFields() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z,extra",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
public void testFailure_badInsertionTime() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
String filename = writeToTmpFile(
|
||||
"1,foo",
|
||||
"DNL,lookup-key,insertion-datetime",
|
||||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,foo",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue