Upgrade to Mockito 2
Closes gh-7770
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
@@ -143,14 +142,14 @@ public abstract class AbstractHttpClientMockTests {
|
||||
given(response.getFirstHeader(headerName)).willReturn(header);
|
||||
}
|
||||
|
||||
private Matcher<HttpGet> getForMetadata(boolean serviceCapabilities) {
|
||||
private ArgumentMatcher<HttpGet> getForMetadata(boolean serviceCapabilities) {
|
||||
if (!serviceCapabilities) {
|
||||
return new HasAcceptHeader(InitializrService.ACCEPT_META_DATA, true);
|
||||
}
|
||||
return new HasAcceptHeader(InitializrService.ACCEPT_SERVICE_CAPABILITIES, true);
|
||||
}
|
||||
|
||||
private Matcher<HttpGet> getForNonMetadata() {
|
||||
private ArgumentMatcher<HttpGet> getForNonMetadata() {
|
||||
return new HasAcceptHeader(InitializrService.ACCEPT_META_DATA, false);
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ public abstract class AbstractHttpClientMockTests {
|
||||
|
||||
}
|
||||
|
||||
private static class HasAcceptHeader extends ArgumentMatcher<HttpGet> {
|
||||
private static class HasAcceptHeader implements ArgumentMatcher<HttpGet> {
|
||||
|
||||
private final String value;
|
||||
|
||||
@@ -200,11 +199,10 @@ public abstract class AbstractHttpClientMockTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
if (!(argument instanceof HttpGet)) {
|
||||
public boolean matches(HttpGet get) {
|
||||
if (get == null) {
|
||||
return false;
|
||||
}
|
||||
HttpGet get = (HttpGet) argument;
|
||||
Header acceptHeader = get.getFirstHeader(HttpHeaders.ACCEPT);
|
||||
if (this.shouldMatch) {
|
||||
return acceptHeader != null && this.value.equals(acceptHeader.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
public LocalRepositoryManager answer(
|
||||
InvocationOnMock invocation) throws Throwable {
|
||||
LocalRepository localRepository = invocation
|
||||
.getArgumentAt(1, LocalRepository.class);
|
||||
.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory()
|
||||
.newInstance(
|
||||
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
|
||||
@@ -109,8 +109,7 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
@Override
|
||||
public LocalRepositoryManager answer(InvocationOnMock invocation)
|
||||
throws Throwable {
|
||||
LocalRepository localRepository = invocation.getArgumentAt(1,
|
||||
LocalRepository.class);
|
||||
LocalRepository localRepository = invocation.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory().newInstance(
|
||||
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
|
||||
localRepository);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
|
||||
public LocalRepositoryManager answer(
|
||||
InvocationOnMock invocation) throws Throwable {
|
||||
LocalRepository localRepository = invocation
|
||||
.getArgumentAt(1, LocalRepository.class);
|
||||
.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory()
|
||||
.newInstance(session, localRepository);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user