Skip to content

Commit 6ce2d04

Browse files
committed
XWIKI-19900: Liked page whose FULLNAME contains dot(.) can not show in user profile.
1 parent 3de7d92 commit 6ce2d04

File tree

3 files changed

+126
-1
lines changed

3 files changed

+126
-1
lines changed

Diff for: xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-ui/pom.xml

+27
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,32 @@
7070
<scope>runtime</scope>
7171
<optional>true</optional>
7272
</dependency>
73+
<!-- Test dependencies. -->
74+
<dependency>
75+
<groupId>org.xwiki.platform</groupId>
76+
<artifactId>xwiki-platform-test-page</artifactId>
77+
<version>${project.version}</version>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.xwiki.platform</groupId>
82+
<artifactId>xwiki-platform-web-templates</artifactId>
83+
<version>${project.version}</version>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.xwiki.platform</groupId>
88+
<artifactId>xwiki-platform-like-api</artifactId>
89+
<version>${project.version}</version>
90+
<scope>test</scope>
91+
<type>test-jar</type>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.xwiki.platform</groupId>
95+
<artifactId>xwiki-platform-user-default</artifactId>
96+
<version>${project.version}</version>
97+
<scope>test</scope>
98+
<type>test-jar</type>
99+
</dependency>
73100
</dependencies>
74101
</project>

Diff for: xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-ui/src/main/resources/XWiki/Like/Code/LiveTableResultPage.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<minorEdit>false</minorEdit>
3737
<syntaxId>xwiki/2.1</syntaxId>
3838
<hidden>true</hidden>
39-
<content>{{velocity}}
39+
<content>{{velocity wiki="false"}}
4040
#if ($xcontext.action == 'get')
4141
#template('hierarchy_macros.vm')
4242
#if("$!{request.xpage}" == 'plain')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.like;
21+
22+
import java.util.List;
23+
24+
import javax.inject.Named;
25+
26+
import org.junit.jupiter.api.Test;
27+
import org.xwiki.like.script.LikeScriptServiceComponentList;
28+
import org.xwiki.model.reference.DocumentReference;
29+
import org.xwiki.model.script.ModelScriptService;
30+
import org.xwiki.ratings.RatingsManager;
31+
import org.xwiki.ratings.internal.DefaultRating;
32+
import org.xwiki.rendering.syntax.Syntax;
33+
import org.xwiki.template.script.TemplateScriptService;
34+
import org.xwiki.test.annotation.ComponentList;
35+
import org.xwiki.test.junit5.mockito.MockComponent;
36+
import org.xwiki.test.page.PageTest;
37+
import org.xwiki.test.page.XWikiSyntax21ComponentList;
38+
import org.xwiki.user.UserReferenceComponentList;
39+
40+
import com.xpn.xwiki.doc.XWikiDocument;
41+
42+
import net.sf.json.JSONObject;
43+
44+
import static org.junit.jupiter.api.Assertions.assertEquals;
45+
import static org.mockito.ArgumentMatchers.any;
46+
import static org.mockito.ArgumentMatchers.anyBoolean;
47+
import static org.mockito.ArgumentMatchers.anyInt;
48+
import static org.mockito.ArgumentMatchers.anyMap;
49+
import static org.mockito.Mockito.when;
50+
51+
/**
52+
* Test of {@code XWiki.Like.Code.LiveTableResultPage}.
53+
*
54+
* @version $Id$
55+
* @since 15.1
56+
* @since 14.10.6
57+
*/
58+
@XWikiSyntax21ComponentList
59+
@LikeScriptServiceComponentList
60+
@UserReferenceComponentList
61+
@ComponentList({
62+
TemplateScriptService.class,
63+
ModelScriptService.class
64+
})
65+
class LiveTableResultPagePageTest extends PageTest
66+
{
67+
private static final DocumentReference DOCUMENT_REFERENCE =
68+
new DocumentReference("xwiki", List.of("XWiki", "Like", "Code"), "LiveTableResultPage");
69+
70+
@MockComponent
71+
@Named("solr")
72+
private RatingsManager ratingsManager;
73+
74+
@Test
75+
void likedPageWithADot() throws Exception
76+
{
77+
DocumentReference likedPageReference = new DocumentReference("xwiki", "Space", "With.ADot");
78+
79+
// Create an empty page to be returned as a liked page.
80+
XWikiDocument likedDocument = this.xwiki.getDocument(likedPageReference, this.context);
81+
this.xwiki.saveDocument(likedDocument, this.context);
82+
83+
// The rating manager is mocked for now as the focus of the tests is currently not to test the likes indexing.
84+
when(this.ratingsManager.getRatings(anyMap(), anyInt(), anyInt(), any(RatingsManager.RatingQueryField.class),
85+
anyBoolean())).thenReturn(List.of(new DefaultRating("id1").setReference(likedPageReference)));
86+
87+
setOutputSyntax(Syntax.PLAIN_1_0);
88+
this.context.setAction("get");
89+
90+
this.request.put("offset", "1");
91+
this.request.put("reqNo", "1");
92+
this.request.put("limit", "10");
93+
94+
JSONObject object = renderJSONPage(DOCUMENT_REFERENCE);
95+
96+
assertEquals("xwiki:Space.With\\.ADot", object.getJSONArray("rows").getJSONObject(0).getString("doc_fullName"));
97+
}
98+
}

0 commit comments

Comments
 (0)