Fix issue 306: UUID support is complete
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java
index 63134b0..3622868 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java
@@ -22,24 +22,47 @@
 import org.yaml.snakeyaml.nodes.Tag;
 
 import java.util.UUID;
+import java.util.regex.Pattern;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class UuidSupportTest {
 
-    //TODO @Test
-    public void loadFromString() {
-        String str = UUID.randomUUID().toString();
+    public static final Pattern UUID_PATTERN = Pattern
+            .compile("^(?:\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12})$");
+    public static final Tag UUID_TAG = new Tag(Tag.PREFIX + "java.util.UUID");
+
+    @Test
+    public void pattern() {
+        assertTrue(UUID_PATTERN.matcher("7f511847-781a-45df-9c8d-1e32e028b9b3").matches());
+        assertTrue(UUID_PATTERN.matcher("AC4877BE-0C31-4458-A86E-0272EFE1AAA8").matches());
+    }
+
+    @Test
+    public void dumpAsString() {
+        UUID uuid = UUID.randomUUID();
+        String str = uuid.toString();
         Yaml yaml = new Yaml();
-        UUID uuid = (UUID) yaml.load(str);
-        assertEquals(str, uuid.toString());
+        yaml.addImplicitResolver(UUID_TAG, UUID_PATTERN, null);
+        String output = yaml.dump(str);
+        assertEquals("'" + str + "'\n", output);
+        assertEquals(str + "\n", yaml.dump(uuid));
+    }
+
+    @Test
+    public void loadAsUuid() {
+        Yaml yaml = new Yaml();
+        yaml.addImplicitResolver(UUID_TAG, UUID_PATTERN, null);
+        UUID uuid = (UUID) yaml.load("7f511847-781a-45df-9c8d-1e32e028b9b3");
+        assertEquals("7f511847-781a-45df-9c8d-1e32e028b9b3", uuid.toString());
     }
 
     @Test
     public void loadFromBean() {
         String input = Util.getLocalResource("issues/issue306-1.yaml");
         Yaml yaml = new Yaml();
-        BeanWithId bean = (BeanWithId) yaml.loadAs(input, BeanWithId.class);
+        BeanWithId bean = yaml.loadAs(input, BeanWithId.class);
         assertEquals("7f511847-781a-45df-9c8d-1e32e028b9b3", bean.getId().toString());
     }