api,core,stub: fix lint errors (#6305)

This commit is contained in:
Jihun Cho 2019-10-18 17:30:00 -07:00 committed by GitHub
parent ecbc5e4f47
commit ae11b9facc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 14 deletions

View File

@ -490,7 +490,6 @@ public final class MethodDescriptor<ReqT, RespT> {
* @param responseMarshaller the marshaller to use.
* @since 1.1.0
*/
@SuppressWarnings("unchecked")
public Builder<ReqT, RespT> setResponseMarshaller(Marshaller<RespT> responseMarshaller) {
this.responseMarshaller = responseMarshaller;
return this;

View File

@ -451,7 +451,6 @@ final class DnsNameResolver extends NameResolver {
*
* @throws IOException if one of the txt records contains improperly formatted JSON.
*/
@SuppressWarnings("unchecked")
@VisibleForTesting
static List<Map<String, ?>> parseTxtResults(List<String> txtRecords) throws IOException {
List<Map<String, ?>> possibleServiceConfigChoices = new ArrayList<>();

View File

@ -355,7 +355,6 @@ public final class ServiceConfigUtil {
/**
* Extracts load balancing configs from a service config.
*/
@SuppressWarnings("unchecked")
@VisibleForTesting
public static List<Map<String, ?>> getLoadBalancingConfigsFromServiceConfig(
Map<String, ?> serviceConfig) {
@ -400,7 +399,6 @@ public final class ServiceConfigUtil {
* (map) with exactly one entry, where the key is the policy name and the value is a config object
* for that policy.
*/
@SuppressWarnings("unchecked")
public static LbConfig unwrapLoadBalancingConfig(Map<String, ?> lbConfig) {
if (lbConfig.size() != 1) {
throw new RuntimeException(
@ -414,7 +412,6 @@ public final class ServiceConfigUtil {
/**
* Given a JSON list of LoadBalancingConfigs, and convert it into a list of LbConfig.
*/
@SuppressWarnings("unchecked")
public static List<LbConfig> unwrapLoadBalancingConfigList(List<Map<String, ?>> list) {
ArrayList<LbConfig> result = new ArrayList<>();
for (Map<String, ?> rawChildPolicy : list) {

View File

@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import io.grpc.CallOptions;
@ -48,15 +49,24 @@ abstract class BaseAbstractStubTest<T extends AbstractStub<T>> {
abstract T create(@Nullable Channel channel, @Nullable CallOptions callOptions);
@Test(expected = NullPointerException.class)
@Test
public void callOptionsMustNotBeNull() {
try {
create(channel, null);
throw new NullPointerException();
fail("NullPointerException expected");
} catch (NullPointerException npe) {
// expected
}
}
@Test(expected = NullPointerException.class)
@Test
public void channelMustNotBeNull2() {
try {
create(null, CallOptions.DEFAULT);
fail("NullPointerException expected");
} catch (NullPointerException npe) {
// expected
}
}
@Test

View File

@ -134,9 +134,9 @@ public class ClientCallsTest {
};
ClientCalls.asyncUnaryCall(call, req, responseObserver);
assertThat(actualResponse.size()).isEqualTo(1);
assertThat(actualResponse).hasSize(1);
assertEquals(resp, actualResponse.get(0));
assertThat(completed.size()).isEqualTo(1);
assertThat(completed).hasSize(1);
assertThat(completed.get(0)).isTrue();
}
@ -173,7 +173,7 @@ public class ClientCallsTest {
};
ClientCalls.asyncUnaryCall(call, req, responseObserver);
assertThat(expected.size()).isEqualTo(1);
assertThat(expected).hasSize(1);
assertThat(expected.get(0)).hasMessageThat()
.isEqualTo("INTERNAL: Response message is null for unary call");
}
@ -212,7 +212,7 @@ public class ClientCallsTest {
};
ClientCalls.asyncUnaryCall(call, req, responseObserver);
assertThat(expected.size()).isEqualTo(1);
assertThat(expected).hasSize(1);
assertThat(expected.get(0)).hasMessageThat().isEqualTo("INTERNAL: Unique status");
}