### Question:
UUIDGeneratorImpl implements UUIDGenerator { @Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; }  @Override String getNextUUID(); @Override String[] validateUuid(String uuid); static final String DEFAULT_HOSTNAME; }### Answer:
@Test public void tripleComponent() { UUIDGeneratorImpl impl = new UUIDGeneratorImpl(); String[] component = impl.validateUuid("abcd001-abcdef-00001:defg002-ghijkl-00001:hijk003-mnopqr-00001"); assertEquals(3, component.length); assertEquals("abcd001-abcdef-00001",component[0]); assertEquals("defg002-ghijkl-00001",component[1]); assertEquals("hijk003-mnopqr-00001",component[2]); }
@Test public void singleComponent() { UUIDGeneratorImpl impl = new UUIDGeneratorImpl(); String[] component = impl.validateUuid("abcd001-abcdef-00001"); assertEquals(3, component.length); assertNull(component[0]); assertNull(component[1]); assertEquals("abcd001-abcdef-00001",component[2]); }
@Test(expected = IllegalArgumentException.class) public void tripleComponentWrongSep() { UUIDGeneratorImpl impl = new UUIDGeneratorImpl(); impl.validateUuid("abcd001-abcdef-00001;defg002-ghijkl-00001;hijk003-mnopqr-00001"); }
@Test(expected = IllegalArgumentException.class) public void twoComponents() { UUIDGeneratorImpl impl = new UUIDGeneratorImpl(); impl.validateUuid("abcd001-abcdef-00001:defg002-ghijkl-00001"); }