mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
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:
parent
5047d568de
commit
1751ea0b98
7 changed files with 18 additions and 16 deletions
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package google.registry.export;
|
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.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static google.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE;
|
import static google.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE;
|
||||||
|
@ -130,7 +129,7 @@ public class ExportReservedTermsActionTest {
|
||||||
assertWithMessage("Expected RuntimeException to be thrown").fail();
|
assertWithMessage("Expected RuntimeException to be thrown").fail();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
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();
|
assertWithMessage("Expected RuntimeException to be thrown").fail();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,9 @@ public class OfyFilterTest {
|
||||||
Key.create(entity);
|
Key.create(entity);
|
||||||
fail("Should not be able to create key for unregistered entity");
|
fail("Should not be able to create key for unregistered entity");
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
assertThat(e).hasMessage(
|
assertThat(e)
|
||||||
|
.hasMessageThat()
|
||||||
|
.isEqualTo(
|
||||||
"class google.registry.model.ofy.OfyFilterTest$UnregisteredEntity "
|
"class google.registry.model.ofy.OfyFilterTest$UnregisteredEntity "
|
||||||
+ "has not been registered");
|
+ "has not been registered");
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class EppExceptionSubject extends Subject<EppExceptionSubject, EppExcepti
|
||||||
}
|
}
|
||||||
|
|
||||||
public And<EppExceptionSubject> hasMessage(String expected) {
|
public And<EppExceptionSubject> hasMessage(String expected) {
|
||||||
assertThat(actual()).hasMessage(expected);
|
assertThat(actual()).hasMessageThat().isEqualTo(expected);
|
||||||
return new And<>(this);
|
return new And<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class CreateReservedListCommandTest extends
|
||||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(ReservedList.get(name)).isAbsent();
|
assertThat(ReservedList.get(name)).isAbsent();
|
||||||
assertThat(e).hasMessage(expectedErrorMsg);
|
assertThat(e).hasMessageThat().isEqualTo(expectedErrorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,9 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
|
||||||
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
assertThat(ReservedList.get(reservedList.getName())).isPresent();
|
||||||
assertThat(e).hasMessage(
|
assertThat(e)
|
||||||
"Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
.hasMessageThat()
|
||||||
|
.isEqualTo("Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,11 @@ import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.testing.ExceptionRule;
|
|
||||||
import google.registry.tools.ServerSideCommand.Connection;
|
import google.registry.tools.ServerSideCommand.Connection;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
@ -34,8 +33,6 @@ import org.junit.runners.JUnit4;
|
||||||
public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||||
Connection connection = mock(Connection.class);
|
Connection connection = mock(Connection.class);
|
||||||
|
|
||||||
@Rule public final ExceptionRule thrown = new ExceptionRule();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class ConcurrentTest {
|
||||||
fail("Didn't throw!");
|
fail("Didn't throw!");
|
||||||
} catch (UncheckedExecutionException e) {
|
} catch (UncheckedExecutionException e) {
|
||||||
// We can't use ExpectedException because root cause must be one level of indirection away.
|
// We can't use ExpectedException because root cause must be one level of indirection away.
|
||||||
assertThat(e.getCause()).isInstanceOf(RuntimeException.class);
|
assertThat(e).hasCauseThat().isInstanceOf(RuntimeException.class);
|
||||||
assertThat(e.getCause()).hasMessage("hello");
|
assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("hello");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue