Skip to content

Commit 0685f27

Browse files
committed
#4 Recursive association
Add test to verify
1 parent 878e736 commit 0685f27

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

modello-core/src/test/java/org/codehaus/modello/core/DefaultModelloCoreTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,11 @@ public void testModelWithDuplicateAssociations()
8181
assertEquals( "Duplicate field in MyClass: MyAssociation.", ex.getMessage() );
8282
}
8383
}
84+
85+
public void testRecursion() throws Exception
86+
{
87+
ModelloCore modello = (ModelloCore) lookup( ModelloCore.ROLE );
88+
89+
modello.loadModel( getTestFile( "src/test/resources/models/recursion.mdo" ) );
90+
}
8491
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
2+
license agreements. See the NOTICE file distributed with this work for additional
3+
information regarding copyright ownership. The ASF licenses this file to
4+
you under the Apache License, Version 2.0 (the "License"); you may not use
5+
this file except in compliance with the License. You may obtain a copy of
6+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
7+
by applicable law or agreed to in writing, software distributed under the
8+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9+
OF ANY KIND, either express or implied. See the License for the specific
10+
language governing permissions and limitations under the License. -->
11+
12+
<model xmlns="http://codehaus-plexus.github.io/MODELLO/1.8.0"
13+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
xsi:schemaLocation="http://codehaus-plexus.github.io/MODELLO/1.8.0 http://codehaus-plexus.github.io/modello/xsd/modello-1.8.0.xsd">
15+
<id>recursion</id>
16+
<name>RecursionNode</name>
17+
<defaults>
18+
<default>
19+
<key>package</key>
20+
<value>com.github.jasminb.jsonapi.models.recursion</value>
21+
</default>
22+
</defaults>
23+
24+
<classes>
25+
<class rootElement="true">
26+
<name>RecursionNode</name>
27+
<version>0.0.0+</version>
28+
<fields>
29+
<field>
30+
<name>parent</name>
31+
<association>
32+
<multiplicity>1</multiplicity>
33+
<type>RecursionNode</type>
34+
</association>
35+
</field>
36+
<field>
37+
<name>children</name>
38+
<type>List</type>
39+
<association>
40+
<type>RecursionNode</type>
41+
<multiplicity>*</multiplicity>
42+
</association>
43+
</field>
44+
</fields>
45+
</class>
46+
</classes>
47+
</model>

0 commit comments

Comments
 (0)