diff --git a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java index c2192118..ad2ebdea 100644 --- a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java +++ b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java @@ -70,7 +70,7 @@ public class ServerConnectRequest * Class that sets default properties/adds methods to the lombok builder * generated class. */ - public static class ServerConnectRequestBuilder + public static class Builder { private int connectTimeout = 5000; // TODO: Configurable diff --git a/api/src/test/java/net/md_5/bungee/api/ServerConnectRequestTest.java b/api/src/test/java/net/md_5/bungee/api/ServerConnectRequestTest.java new file mode 100644 index 00000000..4a028379 --- /dev/null +++ b/api/src/test/java/net/md_5/bungee/api/ServerConnectRequestTest.java @@ -0,0 +1,81 @@ +package net.md_5.bungee.api; + +import java.net.InetSocketAddress; +import java.util.Collection; +import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ServerConnectEvent; +import org.junit.Assert; +import org.junit.Test; + +public class ServerConnectRequestTest +{ + + private static final ServerInfo DUMMY_INFO = new ServerInfo() + { + @Override + public String getName() + { + return null; + } + + @Override + public InetSocketAddress getAddress() + { + return null; + } + + @Override + public Collection getPlayers() + { + return null; + } + + @Override + public String getMotd() + { + return null; + } + + @Override + public boolean canAccess(CommandSender sender) + { + return false; + } + + @Override + public void sendData(String channel, byte[] data) + { + } + + @Override + public boolean sendData(String channel, byte[] data, boolean queue) + { + return false; + } + + @Override + public void ping(Callback callback) + { + } + }; + + @Test + public void testDefaultConnectTimeout() + { + ServerConnectRequest request = ServerConnectRequest.builder().target( DUMMY_INFO ).reason( ServerConnectEvent.Reason.JOIN_PROXY ).build(); + Assert.assertEquals( 5000, request.getConnectTimeout() ); + } + + @Test(expected = NullPointerException.class) + public void testNullTarget() + { + ServerConnectRequest.builder().target( null ).reason( ServerConnectEvent.Reason.JOIN_PROXY ).build(); + } + + @Test(expected = NullPointerException.class) + public void testNullReason() + { + ServerConnectRequest.builder().target( DUMMY_INFO ).reason( null ).build(); + } +}