diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/pom.xml b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/pom.xml index 7ac18837c016e88528fb27d6f002661836decf8f..25c2b28f8e0bb8ab7567a1b8d8210bd6188753f9 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/pom.xml @@ -32,7 +32,7 @@ <packaging>jar</packaging> <description>Default implementation of the Mentions components.</description> <properties> - <xwiki.jacoco.instructionRatio>0.85</xwiki.jacoco.instructionRatio> + <xwiki.jacoco.instructionRatio>0.86</xwiki.jacoco.instructionRatio> <!-- This component must be installed at the farm level because org.xwiki.eventstream.store.internal.RecordableEventListener.convertEvent uses org.xwiki.component.manager.ComponentManager. To be removed once XWIKI-17359 is fixed. --> diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProvider.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..dbba9803f170c0464eb76f8df7aa75e215847945 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProvider.java @@ -0,0 +1,59 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.mentions.internal.rendering; + +import java.util.Collections; +import java.util.List; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.rendering.syntax.Syntax; +import org.xwiki.rendering.syntax.SyntaxType; + +/** + * Register the {@code plainmentions/1.0} Syntax supported by this module. + * + * @version $Id$ + * @since 14.0RC1 + */ +@Component +@Named("plainmentions/1.0") +@Singleton +public class MentionsSyntaxProvider implements Provider<List<Syntax>> +{ + /** + * Plain Mentions syntax. + */ + public static final SyntaxType PLAINMENTIONS = new SyntaxType("plainmentions", "Plain Text Mentions"); + + /** + * Plain Mentions 1.0 syntax. + */ + public static final Syntax PLAINMENTIONS_1_0 = new Syntax(PLAINMENTIONS, "1.0"); + + @Override + public List<Syntax> get() + { + return Collections.singletonList(PLAINMENTIONS_1_0); + } +} diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsBlockRenderer.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsBlockRenderer.java index 17fd87425fe2452bd5b9ccb48a3069357f7e13c5..880025ae65e3f0363b1a1cd43a39695ba05b04b1 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsBlockRenderer.java +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsBlockRenderer.java @@ -39,7 +39,7 @@ public class PlainTextMentionsBlockRenderer extends PlainTextBlockRenderer { /** - * Used to create new plain/1.0 {@link org.xwiki.rendering.renderer.PrintRenderer}s. + * Used to create new {@code plain/1.0} {@link org.xwiki.rendering.renderer.PrintRenderer}s. */ @Inject @Named("plainmentions/1.0") diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRenderer.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRenderer.java index 6d94bad5d1c3e97944822bf8e581dc7ad93bf3db..0e9989cac39a768278ab7a79ec30bcfe4c93233c 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRenderer.java +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRenderer.java @@ -36,7 +36,7 @@ import org.xwiki.rendering.internal.renderer.plain.PlainTextRenderer; /** - * Plain text rendered with a specialization to display well formatted user mentions. + * Plain text rendered with a specialization to display well-formatted user mentions. * * @version $Id$ * @since 12.6 diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRendererFactory.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRendererFactory.java index 4a4ca7981b87f73cb869eac250ed245aa31f8514..6561b7afd84580408d81acf866d9ec55482dd16f 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRendererFactory.java +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/rendering/PlainTextMentionsRendererFactory.java @@ -25,7 +25,6 @@ import org.xwiki.component.annotation.Component; import org.xwiki.rendering.internal.renderer.AbstractPrintRendererFactory; import org.xwiki.rendering.syntax.Syntax; -import org.xwiki.rendering.syntax.SyntaxType; /** * Mentions specific plain text renderer factory. @@ -41,7 +40,6 @@ public class PlainTextMentionsRendererFactory extends AbstractPrintRendererFacto @Override public Syntax getSyntax() { - String plainmentions = "plainmentions"; - return new Syntax(new SyntaxType(plainmentions, plainmentions), "1.0"); + return MentionsSyntaxProvider.PLAINMENTIONS_1_0; } } diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/resources/META-INF/components.txt index 028a6c98a45b0b2feef7511b949ffa751a592344..21d67d8798c04595d83de71ed22686879b792e0a 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/resources/META-INF/components.txt @@ -15,6 +15,7 @@ org.xwiki.mentions.internal.MentionsConfigurationSource org.xwiki.mentions.internal.rendering.PlainTextMentionsBlockRenderer org.xwiki.mentions.internal.rendering.PlainTextMentionsRenderer org.xwiki.mentions.internal.rendering.PlainTextMentionsRendererFactory +org.xwiki.mentions.internal.rendering.MentionsSyntaxProvider org.xwiki.mentions.internal.DefaultMentionsFormatterProvider org.xwiki.mentions.internal.analyzer.CreatedDocumentMentionsAnalyzer org.xwiki.mentions.internal.analyzer.UpdatedDocumentMentionsAnalyzer diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/test/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProviderTest.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/test/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProviderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..09d715095094df5c5ef316274fccfd2135ce47b5 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/test/java/org/xwiki/mentions/internal/rendering/MentionsSyntaxProviderTest.java @@ -0,0 +1,50 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.mentions.internal.rendering; + +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.xwiki.rendering.syntax.Syntax; +import org.xwiki.test.junit5.mockito.ComponentTest; +import org.xwiki.test.junit5.mockito.InjectMockComponents; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Unit tests for {@link MentionsSyntaxProvider}. + * + * @version $Id$ + */ +@ComponentTest +class MentionsSyntaxProviderTest +{ + @InjectMockComponents + private MentionsSyntaxProvider provider; + + @Test + void get() + { + List<Syntax> syntaxes = this.provider.get(); + assertEquals(1, syntaxes.size()); + assertEquals("plainmentions/1.0", syntaxes.get(0).toIdString()); + assertEquals("Plain Text Mentions 1.0", syntaxes.get(0).toString()); + } +}