<commit_before>package com.imcode.imcms.domain.service.api;

import com.imcode.imcms.components.datainitializer.LanguageDataInitializer;
import com.imcode.imcms.config.TestConfig;
import com.imcode.imcms.domain.dto.LoopEntryRefDTO;
import com.imcode.imcms.domain.dto.TextDTO;
import com.imcode.imcms.domain.dto.TextHistoryDTO;
import com.imcode.imcms.domain.service.TextHistoryService;
import com.imcode.imcms.model.Language;
import com.imcode.imcms.model.LoopEntryRef;
import com.imcode.imcms.model.Roles;
import com.imcode.imcms.model.Text;
import com.imcode.imcms.persistence.repository.TextHistoryRepository;
import imcode.server.Imcms;
import imcode.server.user.UserDomainObject;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.junit.Assert.assertEquals;

@Transactional
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestConfig.class})
public class DefaultTextHistoryServiceTest {

    private final static int DOC_ID = 1001;

    @Autowired
    private TextHistoryService textHistoryService;

    @Autowired
    private LanguageDataInitializer languageDataInitializer;

    @Autowired
    private TextHistoryRepository textHistoryRepository;

    private Language language;
    private Integer index;
    private LoopEntryRef loopEntryRef;

    @BeforeClass
    public static void setUser() {
        final UserDomainObject user = new UserDomainObject(1);
        user.addRoleId(Roles.SUPER_ADMIN.getId());
        Imcms.setUser(user);
    }

    @Before
    public void setUp() {
        textHistoryRepository.deleteAll();
        this.language = languageDataInitializer.createData().get(0);
        this.index = 1;

        this.loopEntryRef = new LoopEntryRefDTO();
        loopEntryRef.setLoopEntryIndex(1);
        loopEntryRef.setLoopIndex(1);
    }

    @Test
    public void saveTextHistory_Expect_Saved() {
        final int expected = textHistoryRepository.findAll().size() + 1;
        final Text text = textList(1).get(0);
<commit_msg>IMCMS-334 New design to super admin page: link validator tab - Update test from junit4 to junit5<commit_after>package com.imcode.imcms.domain.service.api;

import com.imcode.imcms.WebAppSpringTestConfig;
import com.imcode.imcms.components.datainitializer.LanguageDataInitializer;
import com.imcode.imcms.domain.dto.LoopEntryRefDTO;
import com.imcode.imcms.domain.dto.TextDTO;
import com.imcode.imcms.domain.dto.TextHistoryDTO;
import com.imcode.imcms.domain.service.TextHistoryService;
import com.imcode.imcms.model.Language;
import com.imcode.imcms.model.LoopEntryRef;
import com.imcode.imcms.model.Roles;
import com.imcode.imcms.model.Text;
import com.imcode.imcms.persistence.repository.TextHistoryRepository;
import imcode.server.Imcms;
import imcode.server.user.UserDomainObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.assertEquals;


@Transactional
public class DefaultTextHistoryServiceTest extends WebAppSpringTestConfig {

    private final static int DOC_ID = 1001;

    @Autowired
    private TextHistoryService textHistoryService;

    @Autowired
    private LanguageDataInitializer languageDataInitializer;

    @Autowired
    private TextHistoryRepository textHistoryRepository;

    private Language language;
    private Integer index;
    private LoopEntryRef loopEntryRef;

    @BeforeAll
    public static void setUser() {
        final UserDomainObject user = new UserDomainObject(1);
        user.addRoleId(Roles.SUPER_ADMIN.getId());
        Imcms.setUser(user);
    }

    @BeforeEach
    public void setUp() {
        textHistoryRepository.deleteAll();
        this.language = languageDataInitializer.createData().get(0);
        this.index = 1;

        this.loopEntryRef = new LoopEntryRefDTO();
        loopEntryRef.setLoopEntryIndex(1);
        loopEntryRef.setLoopIndex(1);
    }

    @Test
    public void saveTextHistory_Expect_Saved() {
        final int expected = textHistoryRepository.findAll().size() + 1;
        final Text text = textList(1).get(0);

{'fraction_non_alphanumeric': 0.09180126763443058, 'fraction_numerical': 0.006542629319157636, 'mean_word_length': 4.565415244596132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2408851', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1445, 'n_words': 267}