mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Clean up some code quality issues in GCP proxy
All changes are suggested by IntelliJ code inspection. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189586104
This commit is contained in:
parent
22b575b17d
commit
c72e01f75e
13 changed files with 27 additions and 32 deletions
|
@ -37,16 +37,13 @@ public class GcpJsonFormatterTest {
|
|||
private final LogRecord logRecord = new LogRecord(Level.WARNING, MESSAGE);
|
||||
|
||||
private static String makeJson(String severity, String source, String message) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append(
|
||||
Joiner.on(",")
|
||||
return "{"
|
||||
+ Joiner.on(",")
|
||||
.join(
|
||||
makeJsonField("severity", severity),
|
||||
makeJsonField("source", source),
|
||||
makeJsonField("message", "\\n" + message)));
|
||||
builder.append("}\n");
|
||||
return builder.toString();
|
||||
makeJsonField("message", "\\n" + message))
|
||||
+ "}\n";
|
||||
}
|
||||
|
||||
private static String makeJsonField(String name, String content) {
|
||||
|
|
|
@ -18,7 +18,6 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
|
|||
import static google.registry.proxy.ProxyConfig.Environment.TEST;
|
||||
import static google.registry.proxy.ProxyConfig.getProxyConfig;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -55,6 +54,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ProxyProtocolHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testSuccess_proxyHeaderMalformed_singleFrame() {
|
||||
header = String.format("PROXY UNKNOWN\r\n");
|
||||
header = "PROXY UNKNOWN\r\n";
|
||||
String message = "some message";
|
||||
// Header processed, rest of the message passed along.
|
||||
assertThat(channel.writeInbound(Unpooled.wrappedBuffer((header + message).getBytes(UTF_8))))
|
||||
|
|
|
@ -62,8 +62,7 @@ public class MetricParametersTest {
|
|||
ZONE_PATH,
|
||||
zoneConnection);
|
||||
private final HashMap<String, String> fakeEnvVarMap = new HashMap<>();
|
||||
private final Function<String, HttpURLConnection> fakeConnectionFactory =
|
||||
path -> mockConnections.get(path);
|
||||
private final Function<String, HttpURLConnection> fakeConnectionFactory = mockConnections::get;
|
||||
|
||||
private final MetricParameters metricParameters =
|
||||
new MetricParameters(fakeEnvVarMap, fakeConnectionFactory);
|
||||
|
|
|
@ -46,7 +46,6 @@ public class QuotaManagerTest {
|
|||
new QuotaManager(tokenStore, MoreExecutors.newDirectExecutorService());
|
||||
private QuotaRequest request;
|
||||
private QuotaResponse response;
|
||||
private QuotaRebate rebate;
|
||||
|
||||
@Test
|
||||
public void testSuccess_requestApproved() {
|
||||
|
@ -74,7 +73,7 @@ public class QuotaManagerTest {
|
|||
public void testSuccess_rebate() throws Exception {
|
||||
DateTime grantedTokenRefillTime = clock.nowUtc();
|
||||
response = QuotaResponse.create(true, USER_ID, grantedTokenRefillTime);
|
||||
rebate = QuotaRebate.create(response);
|
||||
QuotaRebate rebate = QuotaRebate.create(response);
|
||||
Future<?> unusedFuture = quotaManager.releaseQuota(rebate);
|
||||
verify(tokenStore).scheduleRefresh();
|
||||
verify(tokenStore).put(USER_ID, grantedTokenRefillTime);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue