package com.github.rschmitt.dynamicobject;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import clojure.java.api.Clojure;

public class DefaultReaderTest {
    @Test
    public void testUnknownReader() {
        String edn = "#some-namespace/some-record-name{:key :value}";
        Object obj = DynamicObject.deserialize(edn, Object.class);
        Unknown unknown = (Unknown) obj;

        assertEquals("some-namespace/some-record-name", unknown.getTag());
        assertEquals(Clojure.read("{:key :value}"), unknown.getElement());
        assertEquals(DynamicObject.serialize(unknown), edn);
    }

    @Test(expected = RuntimeException.class)
    public void disableUnknownReader() {
        try {
            DynamicObject.setDefaultReader(null);
            DynamicObject.deserialize("#unknown{}", Object.class);
        } finally {
            DynamicObject.setDefaultReader(Unknown::new);
        }
    }
}

@@ -55,37 +55,165 @@
 tic 
-org.junit.Assert.assertEquals
+com.github.rschmitt.dynamicobject.DynamicObject.serialize;%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap
 ;%0A%0Ai
@@ -700,30 +700,16 @@
 tEquals(
-DynamicObject.
 serializ
@@ -1028,16 +1028,16 @@
 ::new);%0A
-
         
@@ -1043,11 +1043,392 @@
  %7D%0A    %7D
+%0A%0A    @Test%0A    public void testUnknownSerialization() %7B%0A        Unknown map = new Unknown(%22tag%22, new HashMap());%0A        Unknown str = new Unknown(%22tag%22, %22asdf%22);%0A        Unknown vec = new Unknown(%22tag%22, new ArrayList());%0A%0A        assertEquals(%22#tag%7B%7D%22, serialize(map));%0A        assertEquals(%22#tag %5C%22asdf%5C%22%22, serialize(str));%0A        assertEquals(%22#tag %5B%5D%22, serialize(vec));%0A    %7D
 %0A%7D%0A

Add tests for Unknown serialization