Replace deprecated Truth hasMessage() method with hasMessageThat()

hasMessageThat() was added in Truth 0.32 and we are already on that
version in the Nomulus release.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=153095111
This commit is contained in:
mcilwain 2017-04-13 13:00:08 -07:00 committed by Ben McIlwain
parent 5047d568de
commit 1751ea0b98
7 changed files with 18 additions and 16 deletions

View file

@ -14,7 +14,6 @@
package google.registry.export;
import static com.google.common.base.Throwables.getRootCause;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE;
@ -130,7 +129,7 @@ public class ExportReservedTermsActionTest {
assertWithMessage("Expected RuntimeException to be thrown").fail();
} catch (RuntimeException e) {
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
assertThat(getRootCause(e)).hasMessage("errorMessage");
assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("errorMessage");
}
}
@ -141,7 +140,10 @@ public class ExportReservedTermsActionTest {
assertWithMessage("Expected RuntimeException to be thrown").fail();
} catch (RuntimeException e) {
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
assertThat(getRootCause(e)).hasMessage("No registry object found for fakeTld");
assertThat(e)
.hasCauseThat()
.hasMessageThat()
.isEqualTo("No registry object found for fakeTld");
}
}
}

View file

@ -81,7 +81,9 @@ public class OfyFilterTest {
Key.create(entity);
fail("Should not be able to create key for unregistered entity");
} catch (IllegalStateException e) {
assertThat(e).hasMessage(
assertThat(e)
.hasMessageThat()
.isEqualTo(
"class google.registry.model.ofy.OfyFilterTest$UnregisteredEntity "
+ "has not been registered");
}

View file

@ -38,7 +38,7 @@ public class EppExceptionSubject extends Subject<EppExceptionSubject, EppExcepti
}
public And<EppExceptionSubject> hasMessage(String expected) {
assertThat(actual()).hasMessage(expected);
assertThat(actual()).hasMessageThat().isEqualTo(expected);
return new And<>(this);
}

View file

@ -175,7 +175,7 @@ public class CreateReservedListCommandTest extends
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
} catch (IllegalArgumentException e) {
assertThat(ReservedList.get(name)).isAbsent();
assertThat(e).hasMessage(expectedErrorMsg);
assertThat(e).hasMessageThat().isEqualTo(expectedErrorMsg);
}
}

View file

@ -59,8 +59,9 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
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");
assertThat(e)
.hasMessageThat()
.isEqualTo("Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
}
}
}

View file

@ -20,12 +20,11 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import google.registry.testing.ExceptionRule;
import google.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -34,8 +33,6 @@ import org.junit.runners.JUnit4;
public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
Connection connection = mock(Connection.class);
@Rule public final ExceptionRule thrown = new ExceptionRule();
@Before
public void setUp() throws Exception {
command.setConnection(connection);

View file

@ -62,8 +62,8 @@ public class ConcurrentTest {
fail("Didn't throw!");
} catch (UncheckedExecutionException e) {
// We can't use ExpectedException because root cause must be one level of indirection away.
assertThat(e.getCause()).isInstanceOf(RuntimeException.class);
assertThat(e.getCause()).hasMessage("hello");
assertThat(e).hasCauseThat().isInstanceOf(RuntimeException.class);
assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("hello");
}
}