UuidUtil { public static UUID mojangUuidToJavaUuid(String id) { Preconditions.checkNotNull(id, "id"); Preconditions.checkArgument(id.matches("^[a-z0-9]{32}"), "Not a valid Mojang UUID."); return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); } private  UuidUtil(); static UUID mojangUuidToJavaUuid(String id);  }
@Test public void testMojangUuidToJavaUuid() throws Exception { Assert.assertEquals(JAVA_UUID, UuidUtil.mojangUuidToJavaUuid(MOJANG_UUID)); }
@Test(expected = NullPointerException.class) public void testMojangUuidToJavaUuid_NullId() throws Exception { UuidUtil.mojangUuidToJavaUuid(null); }
@Test(expected = IllegalArgumentException.class) public void testMojangUuidToJavaUuid_InvalidRegex1() throws Exception { UuidUtil.mojangUuidToJavaUuid("42"); }
@Test(expected = IllegalArgumentException.class) public void testMojangUuidToJavaUuid_InvalidRegex2() throws Exception { UuidUtil.mojangUuidToJavaUuid(Strings.repeat("!", 32)); }