<commit_before>package net.nemerosa.ontrack.service.support

import net.nemerosa.ontrack.model.security.SecurityService
import net.nemerosa.ontrack.model.structure.NameDescription
import net.nemerosa.ontrack.model.support.ApplicationLogEntry
import net.nemerosa.ontrack.model.support.OntrackConfigProperties
import net.nemerosa.ontrack.model.support.Page
import org.junit.Test
import org.springframework.boot.actuate.metrics.CounterService

import static org.mockito.Mockito.mock
import static org.mockito.Mockito.when

class ApplicationLogServiceImplTest {

    @Test
    void 'Log entries must be served in reverse order'() {
        OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
        ontrackConfigProperties.applicationLogMaxEntries = 10

        SecurityService securityService = mock(SecurityService)
        when(securityService.getAccount()).thenReturn(Optional.empty())

        CounterService counterService = mock(CounterService)
        ApplicationLogServiceImpl service = new ApplicationLogServiceImpl(
                ontrackConfigProperties,
                securityService,
                counterService
        )
        // Creates two entries
        service.log(ApplicationLogEntry.error(
                new RuntimeException("Test 1"),
                NameDescription.nd("test1", "Test 1")
        ))
        service.log(ApplicationLogEntry.error(
                new RuntimeException("Test 2"),
                NameDescription.nd("test2", "Test 2")
        ))
        // Gets the entries
        def entries = service.getLogEntries(new Page())
        // Checks the order
        assert entries.size() == 2
        assert entries[0].type.name == "test2"
        assert entries[1].type.name == "test1"
    }

}<commit_msg>#383 Formatting of the errors - correction of integration tests<commit_after>package net.nemerosa.ontrack.service.support

import net.nemerosa.ontrack.model.security.SecurityService
import net.nemerosa.ontrack.model.structure.NameDescription
import net.nemerosa.ontrack.model.support.ApplicationLogEntry
import net.nemerosa.ontrack.model.support.OntrackConfigProperties
import net.nemerosa.ontrack.model.support.Page
import org.junit.Test
import org.springframework.boot.actuate.metrics.CounterService

import static org.mockito.Mockito.mock
import static org.mockito.Mockito.when

class ApplicationLogServiceImplTest {

    @Test
    void 'Log entries must be served in reverse order'() {
        OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
        ontrackConfigProperties.applicationLogMaxEntries = 10

        SecurityService securityService = mock(SecurityService)
        when(securityService.getAccount()).thenReturn(Optional.empty())

        CounterService counterService = mock(CounterService)
        ApplicationLogServiceImpl service = new ApplicationLogServiceImpl(
                ontrackConfigProperties,
                securityService,
                counterService
        )
        // Creates two entries
        service.log(ApplicationLogEntry.error(
                new RuntimeException("Test 1"),
                NameDescription.nd("test", "Test"),
                "Test 1"
        ))
        service.log(ApplicationLogEntry.error(
                new RuntimeException("Test 2"),
                NameDescription.nd("test", "Test"),
                "Test 2"
        ))
        // Gets the entries
        def entries = service.getLogEntries(new Page())
        // Checks the order
        assert entries.size() == 2
        assert entries[0].type.name == "test"
        assert entries[0].information == "Test 2"
        assert entries[1].type.name == "test"
        assert entries[1].information == "Test 1"
    }

}
{'fraction_non_alphanumeric': 0.08737346830047948, 'fraction_numerical': 0.007725093233883857, 'mean_word_length': 2.8831437435367113, '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': '1799365', 'n_tokens_mistral': 970, 'n_tokens_neox': 926, 'n_words': 198}