2929import com .pragmaticobjects .oo .atom .tests .AssertAtomsToString ;
3030import com .pragmaticobjects .oo .atom .tests .TestCase ;
3131import com .pragmaticobjects .oo .atom .tests .TestsSuite ;
32+ import java .util .HashMap ;
3233
3334/**
3435 * Tests suite for Atoms toString logic.
@@ -52,8 +53,8 @@ public ToStringTest() {
5253 "" ,
5354 "{" ,
5455 "\" @type\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$SimpleAtom\" , " ,
55- "\" a\" : \" 1/2 \" , " ,
56- "\" b\" : \" 3/4 \" " ,
56+ "\" a\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" , " ,
57+ "\" b\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" " ,
5758 "}"
5859 )
5960 )
@@ -77,17 +78,30 @@ public ToStringTest() {
7778 "\" @type\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$ComplexAtom\" , " ,
7879 "\" a\" : {" ,
7980 "\" @type\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$SimpleAtom\" , " ,
80- "\" a\" : \" 1/2 \" , " ,
81- "\" b\" : \" 3/4 \" " ,
81+ "\" a\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" , " ,
82+ "\" b\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" " ,
8283 "}, " ,
8384 "\" b\" : {" ,
8485 "\" @type\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$SimpleAtom\" , " ,
85- "\" a\" : \" 5/6 \" , " ,
86- "\" b\" : \" 7/8 \" " ,
86+ "\" a\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" , " ,
87+ "\" b\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$NotAtom#42 \" " ,
8788 "}" ,
8889 "}"
8990 )
9091 )
92+ ),
93+ new TestCase (
94+ "Atom with a link to itself via non-atom attribute" ,
95+ new AssertAtomsToString (
96+ new AtomWithRecursiveNonAtomLink (),
97+ String .join (
98+ "" ,
99+ "{" ,
100+ "\" @type\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$AtomWithRecursiveNonAtomLink\" , " ,
101+ "\" hashMap\" : \" com.pragmaticobjects.oo.atom.it.ToStringTest$AtomWithRecursiveNonAtomLink$AHashMap#42\" " ,
102+ "}"
103+ )
104+ )
91105 )
92106 );
93107 }
@@ -128,4 +142,19 @@ public String toString() {
128142 return a + "/" + b ;
129143 }
130144 }
145+
146+ public static class AtomWithRecursiveNonAtomLink {
147+ private final HashMap hashMap ;
148+
149+ public AtomWithRecursiveNonAtomLink () {
150+ this .hashMap = new AHashMap (this );
151+ }
152+
153+ @ com .pragmaticobjects .oo .atom .anno .NotAtom
154+ private static class AHashMap extends HashMap {
155+ public AHashMap (Object that ) {
156+ put ("this" , that );
157+ }
158+ }
159+ }
131160}
0 commit comments