CreateServerOptions implements MapBinder { public CreateServerOptions withSharedIp(String publicIp) { checkState(sharedIpGroupId != null, "sharedIp is invalid unless a shared ip group is specified."); this.publicIp = checkNotNull(publicIp, "ip"); return this; }  @Override R bindToRequest(R request, Map<String, Object> postParams); CreateServerOptions withFile(String path, byte[] contents); CreateServerOptions withSharedIpGroup(int id); CreateServerOptions withMetadata(Map<String, String> metadata); CreateServerOptions withSharedIp(String publicIp); @Override R bindToRequest(R request, Object input);  }
@Test public void testWithSharedIp() { CreateServerOptions options = new CreateServerOptions(); options.withSharedIpGroup(3).withSharedIp("127.0.0.1"); HttpRequest request = buildRequest(options); assertSharedIp(request); }
@Test(expectedExceptions = IllegalStateException.class) public void testWithSharedIpNoGroup() { CreateServerOptions options = new CreateServerOptions(); options.withSharedIp("127.0.0.1"); buildRequest(options); }
@Test(expectedExceptions = IllegalStateException.class) public void testWithSharedIpNoGroupStatic() { CreateServerOptions options = withSharedIp("127.0.0.1"); buildRequest(options); }