@Test public void testBadNames() throws Exception { List<String> badNames = ImmutableList.of("9to5", "^aaa", "test&me", "name with spaces", " no-trim "); for (String badName : badNames) { BaseCompact baseCompact = BaseCompact.create("id-1", badName); ImmutableList<String> violations = validator.validate(baseCompact); assertThat(violations.size(), is(1)); assertThat(violations.get(0), containsString("must match \"^[a-zA-Z][a-zA-Z0-9-]*\"")); } }
public static BaseCompact create(String id, String name) { BaseCompact result = new BaseCompact(); result.setId(id); result.setName(name); return result; }
BaseCompact implements Named { public static BaseCompact create(String id, String name) { BaseCompact result = new BaseCompact(); result.setId(id); result.setName(name); return result; } }
BaseCompact implements Named { public static BaseCompact create(String id, String name) { BaseCompact result = new BaseCompact(); result.setId(id); result.setName(name); return result; }  }
BaseCompact implements Named { public static BaseCompact create(String id, String name) { BaseCompact result = new BaseCompact(); result.setId(id); result.setName(name); return result; }  static BaseCompact create(String id, String name); String getId(); void setId(String id); String getName(); void setName(String name); @Override boolean equals(Object o); @Override int hashCode(); }
BaseCompact implements Named { public static BaseCompact create(String id, String name) { BaseCompact result = new BaseCompact(); result.setId(id); result.setName(name); return result; }  static BaseCompact create(String id, String name); String getId(); void setId(String id); String getName(); void setName(String name); @Override boolean equals(Object o); @Override int hashCode();  }