Skip to content
Snippets Groups Projects
Commit 9ae3703c authored by Vincent Massol's avatar Vincent Massol
Browse files

XWIKI-19288: Plain Text Mentions 1.0 syntax doesn't have a nice friendly name

parent 6223ed68
No related branches found
No related tags found
No related merge requests found
Showing
with 114 additions and 6 deletions
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<description>Default implementation of the Mentions components.</description> <description>Default implementation of the Mentions components.</description>
<properties> <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 <!-- This component must be installed at the farm level because
org.xwiki.eventstream.store.internal.RecordableEventListener.convertEvent uses org.xwiki.eventstream.store.internal.RecordableEventListener.convertEvent uses
org.xwiki.component.manager.ComponentManager. To be removed once XWIKI-17359 is fixed. --> org.xwiki.component.manager.ComponentManager. To be removed once XWIKI-17359 is fixed. -->
......
/*
* 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);
}
}
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
public class PlainTextMentionsBlockRenderer extends PlainTextBlockRenderer 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 @Inject
@Named("plainmentions/1.0") @Named("plainmentions/1.0")
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
import org.xwiki.rendering.internal.renderer.plain.PlainTextRenderer; 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$ * @version $Id$
* @since 12.6 * @since 12.6
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
import org.xwiki.component.annotation.Component; import org.xwiki.component.annotation.Component;
import org.xwiki.rendering.internal.renderer.AbstractPrintRendererFactory; import org.xwiki.rendering.internal.renderer.AbstractPrintRendererFactory;
import org.xwiki.rendering.syntax.Syntax; import org.xwiki.rendering.syntax.Syntax;
import org.xwiki.rendering.syntax.SyntaxType;
/** /**
* Mentions specific plain text renderer factory. * Mentions specific plain text renderer factory.
...@@ -41,7 +40,6 @@ public class PlainTextMentionsRendererFactory extends AbstractPrintRendererFacto ...@@ -41,7 +40,6 @@ public class PlainTextMentionsRendererFactory extends AbstractPrintRendererFacto
@Override @Override
public Syntax getSyntax() public Syntax getSyntax()
{ {
String plainmentions = "plainmentions"; return MentionsSyntaxProvider.PLAINMENTIONS_1_0;
return new Syntax(new SyntaxType(plainmentions, plainmentions), "1.0");
} }
} }
...@@ -15,6 +15,7 @@ org.xwiki.mentions.internal.MentionsConfigurationSource ...@@ -15,6 +15,7 @@ org.xwiki.mentions.internal.MentionsConfigurationSource
org.xwiki.mentions.internal.rendering.PlainTextMentionsBlockRenderer org.xwiki.mentions.internal.rendering.PlainTextMentionsBlockRenderer
org.xwiki.mentions.internal.rendering.PlainTextMentionsRenderer org.xwiki.mentions.internal.rendering.PlainTextMentionsRenderer
org.xwiki.mentions.internal.rendering.PlainTextMentionsRendererFactory org.xwiki.mentions.internal.rendering.PlainTextMentionsRendererFactory
org.xwiki.mentions.internal.rendering.MentionsSyntaxProvider
org.xwiki.mentions.internal.DefaultMentionsFormatterProvider org.xwiki.mentions.internal.DefaultMentionsFormatterProvider
org.xwiki.mentions.internal.analyzer.CreatedDocumentMentionsAnalyzer org.xwiki.mentions.internal.analyzer.CreatedDocumentMentionsAnalyzer
org.xwiki.mentions.internal.analyzer.UpdatedDocumentMentionsAnalyzer org.xwiki.mentions.internal.analyzer.UpdatedDocumentMentionsAnalyzer
/*
* 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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment