Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excavator: Upgrades Baseline to the latest version #1247

Merged
merged 3 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
<module name="NestedTryDepth"/> <!-- Java Coding Guide: Try/catch blocks: never nested -->
<module name="NonEmptyAtclauseDescription"/> <!-- Java Style Guide: At-clauses -->
<module name="ParameterName"> <!-- Java Style Guide: Parameter names -->
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
<property name="format" value="^_?[a-z][a-zA-Z0-9]+$"/>
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc"/> <!-- Java Style Guide: General form -->
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:7.0.1'
classpath 'com.netflix.nebula:nebula-publishing-plugin:13.5.1'
classpath 'com.palantir.baseline:gradle-baseline-java:2.5.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.7.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ private static Optional<HostAndPort> meshProxy(Optional<ProxyConfiguration> prox
private static ProxySelector fixedProxySelectorFor(Proxy proxy) {
return new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
public List<Proxy> select(URI _uri) {
return ImmutableList.of(proxy);
}

@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {}
public void connectFailed(URI _uri, SocketAddress _sa, IOException _ioe) {}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private LongAsStringDeserializer() {
}

@Override
public Long deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
public Long deserialize(JsonParser jsonParser, DeserializationContext _ctxt) throws IOException {
switch (jsonParser.currentToken()) {
case VALUE_NUMBER_INT:
return jsonParser.getLongValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package com.palantir.conjure.java.client.jaxrs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.google.common.collect.Lists;
import com.palantir.conjure.java.client.config.ClientConfiguration;
Expand All @@ -35,6 +34,7 @@
import java.util.concurrent.Future;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.assertj.core.api.HamcrestCondition;
import org.junit.Test;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.FromDataPoints;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testConnectionError_performsFailover(
failoverTestCase.server1.shutdown();
failoverTestCase.server2.enqueue(new MockResponse().setBody("\"foo\""));

assertThat(proxy.string(), is("foo"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand All @@ -107,7 +107,7 @@ public void testConnectionError_performsFailover_concurrentRequests(
things.add(executorService.submit(() -> proxy.string()));
}
for (int i = 0; i < 10; i++) {
assertThat(things.get(i).get(), is("foo"));
assertThat(things.get(i).get()).is(new HamcrestCondition<>(is("foo")));
}
}

Expand All @@ -123,16 +123,16 @@ public void testConnectionError_whenOneCallFailsThenSubsequentNewCallsCanStillSu

try {
proxy.string();
fail();
fail("fail");
} catch (RetryableException e) {
assertThat(e.getMessage(), startsWith("Failed to complete the request due to an IOException"));
assertThat(e.getMessage()).startsWith("Failed to complete the request due to an IOException");
}

// Subsequent call (with the same proxy instance) succeeds.
MockWebServer anotherServer1 = new MockWebServer(); // Not a @Rule so we can control start/stop/port explicitly
anotherServer1.start(failoverTestCase.server1.getPort());
anotherServer1.enqueue(new MockResponse().setBody("\"foo\""));
assertThat(proxy.string(), is("foo"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("foo")));
anotherServer1.shutdown();
}

Expand All @@ -146,7 +146,7 @@ public void testQosError_performsFailover(
failoverTestCase.server1.enqueue(new MockResponse().setBody("\"foo\""));
failoverTestCase.server2.enqueue(new MockResponse().setBody("\"bar\""));

assertThat(proxy.string(), is("bar"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("bar")));
}

@Test
Expand All @@ -163,8 +163,8 @@ public void testConnectionError_performsFailoverOnDnsFailure(
"http://localhost:" + failoverTestCase.server1.getPort()))
.maxNumRetries(2)
.build());
assertThat(bogusHostProxy.string(), is("foo"));
assertThat(failoverTestCase.server1.getRequestCount(), is(1));
assertThat(bogusHostProxy.string()).is(new HamcrestCondition<>(is("foo")));
assertThat(failoverTestCase.server1.getRequestCount()).is(new HamcrestCondition<>(is(1)));
}

@Test
Expand All @@ -182,7 +182,7 @@ public void testQosError_performsRetryWithOneNode() throws Exception {
.maxNumRetries(2)
.build());

assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand All @@ -201,7 +201,7 @@ public void testQosError_performsRetryWithOneNodeAndCache() throws Exception {
.failedUrlCooldown(Duration.ofMillis(CACHE_DURATION))
.build());

assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand Down Expand Up @@ -231,7 +231,7 @@ public void testCache_recovery() throws Exception {

anotherServer1.enqueue(new MockResponse().setResponseCode(503));
anotherServer1.enqueue(new MockResponse().setBody("\"foo\""));
assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
anotherServer1.shutdown();
}

Expand All @@ -249,8 +249,8 @@ public void testPerformsRoundRobin() throws Exception {
proxy.string();
proxy.string();

assertThat(failoverTestCase.server1.getRequestCount(), is(1));
assertThat(failoverTestCase.server2.getRequestCount(), is(1));
assertThat(failoverTestCase.server1.getRequestCount()).is(new HamcrestCondition<>(is(1)));
assertThat(failoverTestCase.server2.getRequestCount()).is(new HamcrestCondition<>(is(1)));
}

private static class FailoverTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.palantir.conjure.java.client.jaxrs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.palantir.conjure.java.okhttp.HostMetricsRegistry;
import javax.ws.rs.GET;
Expand All @@ -29,6 +29,7 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.assertj.core.api.HamcrestCondition;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -79,65 +80,65 @@ public void testCannotDecorateInterfaceWithOptionalPathParam() {
AGENT,
new HostMetricsRegistry(),
createTestConfig("http://localhost:" + server.getPort()));
fail();
fail("fail");
} catch (RuntimeException e) {
assertThat(e.getMessage(),
is("Cannot use Guava Optionals with PathParams. (Class: com.palantir.conjure"
assertThat(e.getMessage()).isEqualTo(
"Cannot use Guava Optionals with PathParams. (Class: com.palantir.conjure"
+ ".java.client.jaxrs.JaxRsClientGuavaOptionalHandlingTest$CannotDecorateInterface,"
+ " Method: path, Param: arg0)"));
+ " Method: path, Param: arg0)");
}
}

@Test
public void testRegularPathParam() throws Exception {
proxy.path("str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getPath(), is("/foo/str2"));
assertThat(takeRequest.getPath()).is(new HamcrestCondition<>(is("/foo/str2")));
}

@Test
public void testAbsentQuery() throws Exception {
proxy.query(com.google.common.base.Optional.absent(), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?req=str2 HTTP/1.1")));
}

@Test
public void testEmptyStringQuery() throws Exception {
proxy.query(com.google.common.base.Optional.of(""), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?opt=&req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?opt=&req=str2 HTTP/1.1")));
}

@Test
public void testStringQuery() throws Exception {
proxy.query(com.google.common.base.Optional.of("str"), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?opt=str&req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?opt=str&req=str2 HTTP/1.1")));
}

@Test
public void testAbsentHeader() throws Exception {
proxy.header(com.google.common.base.Optional.absent(), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is(""));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

@Test
public void testEmptyStringHeader() throws Exception {
proxy.header(com.google.common.base.Optional.of(""), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is(""));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

@Test
public void testStringHeader() throws Exception {
proxy.header(com.google.common.base.Optional.of("str"), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is("str"));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("str")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

}
Loading