Remove backported MockitoJUnitRule

Mockito in third_party is updated to 1.10. We do not need to backport this rule anymore.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=237496086
This commit is contained in:
jianglai 2019-03-08 12:15:16 -08:00
parent 5056e48363
commit b573b10ae1
38 changed files with 85 additions and 107 deletions

View file

@ -1,45 +0,0 @@
// Copyright 2018 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.testing;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
/** A rule that initializes Mockito-annotated fields (e.g. mocks and captors). */
// TODO(b/77815684): Replace with native version from Mockito v1.10 once we upgrade to that.
public class MockitoJUnitRule implements MethodRule {
public static MockitoJUnitRule create() {
return new MockitoJUnitRule();
}
@Override
public Statement apply(Statement base, FrameworkMethod method, Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
MockitoAnnotations.initMocks(target);
try {
base.evaluate();
} finally {
Mockito.validateMockitoUsage();
}
}
};
}
}

View file

@ -36,7 +36,6 @@ import com.google.common.flogger.FluentLogger;
import google.registry.mapreduce.MapreduceRunner;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.testing.MockitoJUnitRule;
import google.registry.testing.ShardableTestCase;
import google.registry.util.AppEngineServiceUtils;
import google.registry.util.AppEngineServiceUtilsImpl;
@ -55,6 +54,8 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
/**
* Base test class for mapreduces.
@ -84,7 +85,7 @@ public abstract class MapreduceTestCase<T> extends ShardableTestCase {
.withTaskQueue()
.build();
@Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create();
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
AppEngineServiceUtils appEngineServiceUtils;