StorageUtils { public static String[] parseCompositeId(String id, int requiredSize) { String[] ret = id != null ? id.split(COMPOSITE_ID_DELIMITER) : new String[0]; Assert.isTrue(ret.length == requiredSize, String.format("ID %s should contain %d independent pieces", id, requiredSize)); return ret; }  static String createCompositeId(String... pieces); static String[] parseCompositeId(String id, int requiredSize);  }
@Test public void testParseCompositeId() { assertThat(Arrays.asList(parseCompositeId("1:2:3", 3)), contains("1", "2", "3")); assertThat(Arrays.asList(parseCompositeId(null, 0)), is(empty())); }
@Test(expected = IllegalArgumentException.class) public void testParseInvalidCompositeId() { parseCompositeId("1:2:3", 4); }