5050 */
5151@ ComponentTest
5252@ ComponentList ({ DefaultSymbolScheme .class })
53- public class DefaultReferenceEntityReferenceResolverTest implements TestConstants
53+ class DefaultReferenceEntityReferenceResolverTest implements TestConstants
5454{
5555 @ MockComponent
5656 private EntityReferenceProvider referenceProvider ;
@@ -59,7 +59,7 @@ public class DefaultReferenceEntityReferenceResolverTest implements TestConstant
5959 private DefaultReferenceEntityReferenceResolver resolver ;
6060
6161 @ BeforeComponent
62- public void beforeComponent ()
62+ void beforeComponent ()
6363 {
6464 when (this .referenceProvider .getDefaultReference (EntityType .WIKI )).thenReturn (DEFAULT_WIKI_REFERENCE );
6565 when (this .referenceProvider .getDefaultReference (EntityType .SPACE )).thenReturn (DEFAULT_SPACE_REFERENCE );
@@ -78,7 +78,7 @@ public void beforeComponent()
7878 }
7979
8080 @ Test
81- public void resolveDocumentReferenceWhenMissingParents ()
81+ void resolveDocumentReferenceWhenMissingParents ()
8282 {
8383 EntityReference partialReference = new EntityReference ("document" , EntityType .DOCUMENT );
8484
@@ -89,10 +89,29 @@ public void resolveDocumentReferenceWhenMissingParents()
8989 assertEquals (EntityType .SPACE , reference .getParent ().getType ());
9090 assertEquals (DEFAULT_WIKI , reference .getParent ().getParent ().getName ());
9191 assertEquals (EntityType .WIKI , reference .getParent ().getParent ().getType ());
92+
93+ partialReference = new EntityReference ("WebHome" , EntityType .DOCUMENT );
94+ reference = this .resolver .resolve (partialReference , EntityType .DOCUMENT );
95+
96+ assertNotSame (partialReference , reference );
97+ assertEquals (DEFAULT_SPACE , reference .getParent ().getName ());
98+ assertEquals (EntityType .SPACE , reference .getParent ().getType ());
99+ assertEquals (DEFAULT_WIKI , reference .getParent ().getParent ().getName ());
100+ assertEquals (EntityType .WIKI , reference .getParent ().getParent ().getType ());
101+
102+ EntityReference spaceReference = new EntityReference ("Space" , EntityType .SPACE );
103+ partialReference = new EntityReference ("WebHome" , EntityType .DOCUMENT , spaceReference );
104+ reference = this .resolver .resolve (partialReference , EntityType .DOCUMENT );
105+
106+ assertNotSame (partialReference , reference );
107+ assertEquals ("Space" , reference .getParent ().getName ());
108+ assertEquals (EntityType .SPACE , reference .getParent ().getType ());
109+ assertEquals (DEFAULT_WIKI , reference .getParent ().getParent ().getName ());
110+ assertEquals (EntityType .WIKI , reference .getParent ().getParent ().getType ());
92111 }
93112
94113 @ Test
95- public void resolveAttachmentReferenceWhenMissingParents ()
114+ void resolveAttachmentReferenceWhenMissingParents ()
96115 {
97116 EntityReference reference =
98117 this .resolver .resolve (new EntityReference ("filename" , EntityType .ATTACHMENT ), EntityType .ATTACHMENT );
@@ -106,7 +125,7 @@ public void resolveAttachmentReferenceWhenMissingParents()
106125 }
107126
108127 @ Test
109- public void resolveDocumentReferenceWhenMissingParentBetweenReferences ()
128+ void resolveDocumentReferenceWhenMissingParentBetweenReferences ()
110129 {
111130 EntityReference partialReference =
112131 new EntityReference ("document" , EntityType .DOCUMENT , new EntityReference ("wiki" , EntityType .WIKI ));
@@ -122,7 +141,7 @@ public void resolveDocumentReferenceWhenMissingParentBetweenReferences()
122141 }
123142
124143 @ Test
125- public void resolveAttachmentReferenceWhenMissingParentBetweenReferences ()
144+ void resolveAttachmentReferenceWhenMissingParentBetweenReferences ()
126145 {
127146 EntityReference reference = this .resolver .resolve (
128147 new EntityReference ("filename" , EntityType .ATTACHMENT , new EntityReference ("wiki" , EntityType .WIKI )),
@@ -137,7 +156,7 @@ public void resolveAttachmentReferenceWhenMissingParentBetweenReferences()
137156 }
138157
139158 @ Test
140- public void resolveDocumentReferenceWhenInvalidReference ()
159+ void resolveDocumentReferenceWhenInvalidReference ()
141160 {
142161 try {
143162 this .resolver .resolve (new EntityReference ("document" , EntityType .DOCUMENT ,
@@ -150,7 +169,7 @@ public void resolveDocumentReferenceWhenInvalidReference()
150169 }
151170
152171 @ Test
153- public void resolveDocumentReferenceWhenTypeIsSpace ()
172+ void resolveDocumentReferenceWhenTypeIsSpace ()
154173 {
155174 EntityReference reference =
156175 this .resolver .resolve (new EntityReference ("space" , EntityType .SPACE ), EntityType .DOCUMENT );
@@ -164,7 +183,7 @@ public void resolveDocumentReferenceWhenTypeIsSpace()
164183 }
165184
166185 @ Test
167- public void resolveSpaceReferenceWhenTypeIsDocument ()
186+ void resolveSpaceReferenceWhenTypeIsDocument ()
168187 {
169188 EntityReference reference =
170189 this .resolver .resolve (new EntityReference ("document" , EntityType .DOCUMENT ), EntityType .SPACE );
@@ -179,7 +198,7 @@ public void resolveSpaceReferenceWhenTypeIsDocument()
179198 * Tests that a relative object reference is resolved correctly and completed with the default document parent.
180199 */
181200 @ Test
182- public void resolveObjectReferenceWhenMissingParents ()
201+ void resolveObjectReferenceWhenMissingParents ()
183202 {
184203 EntityReference reference =
185204 resolver .resolve (new EntityReference ("object" , EntityType .OBJECT ), EntityType .OBJECT );
@@ -197,7 +216,7 @@ public void resolveObjectReferenceWhenMissingParents()
197216 * Tests that a relative object property is resolved correctly and completed with the default object parent.
198217 */
199218 @ Test
200- public void resolveObjectPropertyReferenceWhenMissingParents ()
219+ void resolveObjectPropertyReferenceWhenMissingParents ()
201220 {
202221 EntityReference reference =
203222 resolver .resolve (new EntityReference ("property" , EntityType .OBJECT_PROPERTY ), EntityType .OBJECT_PROPERTY );
@@ -218,7 +237,7 @@ public void resolveObjectPropertyReferenceWhenMissingParents()
218237 * values for object name.
219238 */
220239 @ Test
221- public void resolveObjectReferenceWhenTypeIsDocument ()
240+ void resolveObjectReferenceWhenTypeIsDocument ()
222241 {
223242 EntityReference reference = resolver .resolve (
224243 new EntityReference ("document" , EntityType .DOCUMENT ,
@@ -239,7 +258,7 @@ public void resolveObjectReferenceWhenTypeIsDocument()
239258 * values for object and property name.
240259 */
241260 @ Test
242- public void resolveObjectPropertyReferenceWhenTypeIsDocument ()
261+ void resolveObjectPropertyReferenceWhenTypeIsDocument ()
243262 {
244263 EntityReference reference = resolver .resolve (
245264 new EntityReference ("document" , EntityType .DOCUMENT ,
@@ -258,7 +277,7 @@ public void resolveObjectPropertyReferenceWhenTypeIsDocument()
258277 }
259278
260279 @ Test
261- public void resolveDocumentReferenceWhenNullReference ()
280+ void resolveDocumentReferenceWhenNullReference ()
262281 {
263282 EntityReference reference = this .resolver .resolve (null , EntityType .DOCUMENT );
264283
@@ -271,7 +290,7 @@ public void resolveDocumentReferenceWhenNullReference()
271290 }
272291
273292 @ Test
274- public void resolvePageReferenceWhenTypeIsDocument ()
293+ void resolvePageReferenceWhenTypeIsDocument ()
275294 {
276295 EntityReference reference =
277296 this .resolver .resolve (new EntityReference ("document" , EntityType .DOCUMENT ), EntityType .PAGE );
@@ -284,7 +303,7 @@ public void resolvePageReferenceWhenTypeIsDocument()
284303 }
285304
286305 @ Test
287- public void resolvePageReferenceWhenTypeIsSpace ()
306+ void resolvePageReferenceWhenTypeIsSpace ()
288307 {
289308 EntityReference reference =
290309 this .resolver .resolve (new EntityReference ("space" , EntityType .SPACE ), EntityType .PAGE );
@@ -293,7 +312,7 @@ public void resolvePageReferenceWhenTypeIsSpace()
293312 }
294313
295314 @ Test
296- public void resolveDocumentReferenceWhenTypeIsPage ()
315+ void resolveDocumentReferenceWhenTypeIsPage ()
297316 {
298317 EntityReference reference =
299318 this .resolver .resolve (new EntityReference ("page" , EntityType .PAGE ), EntityType .DOCUMENT );
@@ -303,12 +322,14 @@ public void resolveDocumentReferenceWhenTypeIsPage()
303322 reference = this .resolver .resolve (
304323 new EntityReference ("page1" , EntityType .PAGE , new EntityReference ("page2" , EntityType .PAGE )),
305324 EntityType .DOCUMENT );
306-
325+
326+ // FIXME: there should be a check if the page exists or not.
327+ // See https://jira.xwiki.org/browse/XWIKI-22699
307328 assertEquals (new DocumentReference (DEFAULT_WIKI , List .of ("page2" , "page1" ), DEFAULT_DOCUMENT ), reference );
308329 }
309330
310331 @ Test
311- public void resolveSpaceReferenceWhenTypeIsPage ()
332+ void resolveSpaceReferenceWhenTypeIsPage ()
312333 {
313334 EntityReference reference =
314335 this .resolver .resolve (new EntityReference ("page" , EntityType .PAGE ), EntityType .SPACE );
0 commit comments