AddServerOptions extends BaseHttpRequestOptions { public AddServerOptions withDescription(String description) { checkArgument(description.length() <= 500, "Description cannot be longer than 500 characters"); checkState(!queryParameters.containsKey(DESCRIPTION_KEY), "Can't have duplicate server description"); queryParameters.put(DESCRIPTION_KEY, description); return this; }  AddServerOptions withDescription(String description); AddServerOptions asSandboxType();  }
@Test public void testWithDescription() { AddServerOptions options = new AddServerOptions(); options.withDescription("test"); assertEquals(options.buildQueryParameters().get("description"), ImmutableList.of("test")); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWith501LengthDescription() { AddServerOptions options = new AddServerOptions(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 1 * 501; i++) builder.append('a'); String description = builder.toString(); options.withDescription(description); }
@Test public void testWith500LengthDescription() { AddServerOptions options = new AddServerOptions(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 1 * 500; i++) builder.append('a'); String description = builder.toString(); options.withDescription(description); assertEquals(options.buildQueryParameters().get("description"), ImmutableList.of(description)); }
@Test public void testWithDescriptionStatic() { AddServerOptions options = withDescription("test"); assertEquals(options.buildQueryParameters().get("description"), ImmutableList.of("test")); }
@Test(expectedExceptions = NullPointerException.class) public void testWithDescriptionNPE() { withDescription(null); }