ServiceEndPointBuilder { public ServiceEndPointBuilder withId(String id) { Preconditions.checkArgument(getCheckExpression(id)); _id = id; return this; }  ServiceEndPointBuilder withServiceName(String serviceName); ServiceEndPointBuilder withId(String id); ServiceEndPointBuilder withPayload(String payload); ServiceEndPoint build();  }
@Test public void testInvalidIds() { String[] invalidIds = new String[] {"Foo$Bar", "%", "a@b", "!", null, ""}; for (String id : invalidIds) { try { new ServiceEndPointBuilder().withId(id); fail(id + " was allowed"); } catch (AssertionError e) { throw e; } catch (IllegalArgumentException e) { } catch (Throwable t) { fail(id + " threw " + t.getMessage()); } } }