<commit_before>package net.stuha.messages.formattedText;

import net.stuha.messages.MessageReplyTo;
import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class FormattedTextTest {

    @Test
    public void textProcessing() {
        String rough = "Ahoj @Test User, my friend.\n\rHave you seen http://seznam.cz? What do you think about this, @Test User(1)?";

        List<MessageReplyTo> messageReplyTos = new ArrayList<>();

        MessageReplyTo messageReply = new MessageReplyTo();
        messageReply.setReplyToId("111111-1111-1111-1111-111111111111");
        messageReply.setKey("@Test User");
        messageReply.setCaptionFromFormatted("{\"textNodes\":[{\"type\":\"PLAIN_TEXT\",\"text\":\"Hi \"},{\"type\":\"REPLY_TO\",\"replyToId\":\"33333333-3333-3333-3333-333333333333\",\"iconPath\":\"2_1\",\"caption\":\"Something very interresting Here ...\"},{\"type\":\"PLAIN_TEXT\",\"text\":\", how are you Today?\"}]}");
        messageReplyTos.add(messageReply);

        MessageReplyTo messageReply2 = new MessageReplyTo();
        messageReply2.setReplyToId("222222-2222-2222-2222-222222222222");
        messageReply2.setKey("@Test User(1)");
        messageReplyTos.add(messageReply2);

        FormattedText formattedText = new FormattedText(rough, messageReplyTos);

        Assert.assertTrue(formattedText.getTextNodes().size() == 10);
    }

    @Test
    public void spaceInside() {
        String roughWithBlankStringInside = "http://seznam.cz http://seznam.cz";
        FormattedText formattedText = new FormattedText(roughWithBlankStringInside, new ArrayList<>());

        String formatted = formattedText.toString();
        Assert.assertTrue("{\"textNodes\":[{\"type\":\"LINK\",\"url\":\"http://seznam.cz\",\"label\":\"seznam.cz\",\"shortened\":false},{\"type\":\"LINK\",\"url\":\"http://seznam.cz\",\"label\":\"seznam.cz\",\"shortened\":false}]}".equals(formatted));
    }
}<commit_msg>fixed space between nodes issue<commit_after>package net.stuha.messages.formattedText;

import net.stuha.messages.MessageReplyTo;
import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class FormattedTextTest {

    /**
     * ReplyTos
     * (@User Name) in the rough text of the message should match the value in Key of messageReplyTo objects.
     */
    @Test
    public void textProcessing() {
        String rough = "Ahoj @Test User, my friend.\n\rHave you seen http://seznam.cz? What do you think about this, @Test User(1)?";

        List<MessageReplyTo> messageReplyTos = new ArrayList<>();

        MessageReplyTo messageReply = new MessageReplyTo();
        messageReply.setReplyToId("111111-1111-1111-1111-111111111111");
        messageReply.setKey("@Test User");
        messageReply.setCaptionFromFormatted("{\"textNodes\":[{\"type\":\"PLAIN_TEXT\",\"text\":\"Hi \"},{\"type\":\"REPLY_TO\",\"replyToId\":\"33333333-3333-3333-3333-333333333333\",\"iconPath\":\"2_1\",\"caption\":\"Something very interresting Here ...\"},{\"type\":\"PLAIN_TEXT\",\"text\":\", how are you Today?\"}]}");
        messageReplyTos.add(messageReply);

        MessageReplyTo messageReply2 = new MessageReplyTo();
        messageReply2.setReplyToId("222222-2222-2222-2222-222222222222");
        messageReply2.setKey("@Test User(1)");
        messageReplyTos.add(messageReply2);

        FormattedText formattedText = new FormattedText(rough, messageReplyTos);

        Assert.assertTrue(formattedText.getTextNodes().size() == 10);
    }

    /**
     * Space between two nodes (link or replyTo) should be ignored.
     */
    @Test
    public void spaceInside() {
        String roughWithBlankStringInside = "http://seznam.cz http://seznam.cz";
        FormattedText formattedText = new FormattedText(roughWithBlankStringInside, new ArrayList<>());

        Assert.assertTrue(formattedText.getTextNodes().size() == 2);
    }
}
{'fraction_non_alphanumeric': 0.1682765632943569, 'fraction_numerical': 0.052109811896288764, 'mean_word_length': 3.695704057279236, 'pattern_counts': {'":': 27, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941159', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1171, 'n_words': 215}