Avoid mocking in tests for EppMetric

Followup to []  Mocking shouldn't be used when you can use the real
implementation just as easily (and more robustly) - in particular, you almost
never want to mock a value type.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132586826
This commit is contained in:
nickfelt 2016-09-08 12:33:00 -07:00 committed by Ben McIlwain
parent e478fd09fb
commit 36c6d59fee
4 changed files with 26 additions and 29 deletions

View file

@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.appengine.api.users.User;
@ -91,7 +90,7 @@ public class FlowRunnerTest extends ShardableTestCase {
flowRunner.isDryRun = false;
flowRunner.isSuperuser = false;
flowRunner.isTransactional = false;
flowRunner.metric = mock(EppMetric.Builder.class);
flowRunner.metric = new EppMetric.Builder();
flowRunner.sessionMetadata =
new StatelessRequestSessionMetadata("TheRegistrar", ImmutableSet.<String>of());
flowRunner.trid = Trid.create("client-123", "server-456");
@ -110,18 +109,16 @@ public class FlowRunnerTest extends ShardableTestCase {
}
@Test
public void testRun_notIsTransactional_callsMetricIncrementAttempts() throws Exception {
public void testRun_notIsTransactional_incrementsMetricAttempts() throws Exception {
flowRunner.run();
verify(flowRunner.metric).incrementAttempts();
assertThat(flowRunner.metric.build().getAttempts()).isEqualTo(1);
}
@Test
public void testRun_isTransactional_callsMetricIncrementAttempts() throws Exception {
public void testRun_isTransactional_incrementsMetricAttempts() throws Exception {
flowRunner.isTransactional = true;
flowRunner.run();
verify(flowRunner.metric).incrementAttempts();
assertThat(flowRunner.metric.build().getAttempts()).isEqualTo(1);
}
@Test