ServiceCoordinate { public static ServiceCoordinate parse(final String serviceCoordinateString) { final Matcher matcher = COORDINATE_PATTERN.matcher(serviceCoordinateString); if (!matcher.matches()) { return null; } final String[] path = new String[] {matcher.group(3), matcher.group(2), matcher.group(1)}; return new ServiceCoordinate(new CloudnamePath(path)); } ServiceCoordinate(final CloudnamePath path); String getRegion(); String getTag(); String getService(); static ServiceCoordinate parse(final String serviceCoordinateString); @Override boolean equals(final Object otherInstance); @Override int hashCode();  }
@Test public void testParse() { final ServiceCoordinate coord = ServiceCoordinate.parse("service.tag.region"); assertThat(coord.getRegion(), is("region")); assertThat(coord.getTag(), is("tag")); assertThat(coord.getService(), is("service")); }
@Test public void testInvalidCoordinateString0() { assertThat(ServiceCoordinate.parse("foo bar baz"), is(nullValue())); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCoordinateString1() { ServiceCoordinate.parse(".."); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCoordinateString2() { ServiceCoordinate.parse("_._._"); }