mirror of
https://github.com/google/nomulus
synced 2026-09-19 06:32:00 +00:00
Bring codebase up to more recent Java standards (#2422)
This includes using the new switch format (though IntelliJ does not yet understand patterns including default so those aren't used), multiline strings, replacing some unnecessary type declarations with <>, converting some classes to records, replacing some Guava predicates with native Java code, and some other miscellaneous Code Inspection fixes.
This commit is contained in:
@@ -72,9 +72,12 @@ public record ProbingStep(
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"ProbingStep with Protocol: %s\n" + "OutboundMessage: %s\n",
|
||||
"""
|
||||
ProbingStep with Protocol: %s
|
||||
OutboundMessage: %s
|
||||
""",
|
||||
protocol(), messageTemplate().getClass().getName());
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -202,10 +202,12 @@ public abstract class ProbingAction implements Callable<ChannelFuture> {
|
||||
@Override
|
||||
public final String toString() {
|
||||
return String.format(
|
||||
"ProbingAction with delay: %d\n"
|
||||
+ "outboundMessage: %s\n"
|
||||
+ "protocol: %s\n"
|
||||
+ "host: %s\n",
|
||||
"""
|
||||
ProbingAction with delay: %d
|
||||
outboundMessage: %s
|
||||
protocol: %s
|
||||
host: %s
|
||||
""",
|
||||
delay().getStandardSeconds(), outboundMessage(), protocol(), host());
|
||||
}
|
||||
|
||||
@@ -268,7 +270,7 @@ public abstract class ProbingAction implements Callable<ChannelFuture> {
|
||||
if (channel == null) {
|
||||
bootstrap
|
||||
.handler(
|
||||
new ChannelInitializer<Channel>() {
|
||||
new ChannelInitializer<>() {
|
||||
@Override
|
||||
protected void initChannel(Channel outboundChannel) {
|
||||
// Uses Handlers from Protocol to fill pipeline in order of provided handlers.
|
||||
|
||||
@@ -264,11 +264,6 @@ public class EppModule {
|
||||
return new EppRequestMessage("hello", greetingResponse, null, (a, b) -> ImmutableMap.of());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of all possible {@link EppRequestMessage}s paired with their expected {@link
|
||||
* EppResponseMessage}s.
|
||||
*/
|
||||
|
||||
/** {@link Provides} login {@link EppRequestMessage} with expected response of success. */
|
||||
@Provides
|
||||
@Named("loginSuccess")
|
||||
|
||||
+10
-5
@@ -75,20 +75,25 @@ class EppActionHandlerTest {
|
||||
private Document getResponse(EppResponseMessage response, boolean fail, String clTrid)
|
||||
throws Exception {
|
||||
switch (response.name()) {
|
||||
case "greeting":
|
||||
case "greeting" -> {
|
||||
if (fail) {
|
||||
return EppUtils.getBasicResponse(true, clTrid, SERVER_ID);
|
||||
} else {
|
||||
return EppUtils.getGreeting();
|
||||
}
|
||||
case "domainExists":
|
||||
}
|
||||
case "domainExists" -> {
|
||||
return EppUtils.getDomainCheck(!fail, clTrid, SERVER_ID, DOMAIN_NAME);
|
||||
case "domainNotExists":
|
||||
}
|
||||
case "domainNotExists" -> {
|
||||
return EppUtils.getDomainCheck(fail, clTrid, SERVER_ID, DOMAIN_NAME);
|
||||
case "success":
|
||||
}
|
||||
case "success" -> {
|
||||
return EppUtils.getBasicResponse(!fail, clTrid, SERVER_ID);
|
||||
default:
|
||||
}
|
||||
default -> {
|
||||
return EppUtils.getBasicResponse(fail, clTrid, SERVER_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
package google.registry.monitoring.blackbox.message;
|
||||
|
||||
import google.registry.monitoring.blackbox.exception.UndeterminedStateException;
|
||||
|
||||
/**
|
||||
* {@link InboundMessageType} and {@link OutboundMessageType} type for the purpose of containing
|
||||
* String messages to be passed down channel
|
||||
@@ -34,7 +32,7 @@ public class TestMessage implements OutboundMessageType, InboundMessageType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutboundMessageType modifyMessage(String... args) throws UndeterminedStateException {
|
||||
public OutboundMessageType modifyMessage(String... args) {
|
||||
message = args[0];
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TestServer {
|
||||
ImmutableList<? extends ChannelHandler> handlers) {
|
||||
// Creates ChannelInitializer with handlers specified
|
||||
ChannelInitializer<LocalChannel> serverInitializer =
|
||||
new ChannelInitializer<LocalChannel>() {
|
||||
new ChannelInitializer<>() {
|
||||
@Override
|
||||
protected void initChannel(LocalChannel ch) {
|
||||
for (ChannelHandler handler : handlers) {
|
||||
|
||||
Reference in New Issue
Block a user