<commit_before>package org.mitallast.queue.log;

import org.junit.Test;
import org.mitallast.queue.common.BaseIntegrationTest;
import org.mitallast.queue.common.settings.ImmutableSettings;
import org.mitallast.queue.log.entry.TextLogEntry;
import org.mitallast.queue.node.InternalNode;

public class LogServiceTest extends BaseIntegrationTest {

    @Test
    public void test() throws Exception {
        InternalNode node = createNode(ImmutableSettings.builder()
            .put(settings())
            .put("raft.enabled", false)
            .put("rest.enabled", false)
            .build());


        LogService logService = node.injector().getInstance(LogService.class);

        Log log = logService.log("test log");

        log.appendEntry(TextLogEntry.builder()
            .setIndex(log.nextIndex())
            .setMessage("hello world")
            .build());

        log.appendEntry(TextLogEntry.builder()
            .setIndex(log.nextIndex())
            .setMessage("hello world")
            .build());
    }
}<commit_msg>log service test<commit_after>package org.mitallast.queue.log;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mitallast.queue.common.BaseIntegrationTest;
import org.mitallast.queue.common.settings.Settings;
import org.mitallast.queue.common.stream.InternalStreamService;
import org.mitallast.queue.common.stream.StreamService;
import org.mitallast.queue.log.entry.LogEntry;
import org.mitallast.queue.log.entry.TextLogEntry;
import org.unitils.reflectionassert.ReflectionAssert;

public class LogServiceTest extends BaseIntegrationTest {

    private LogService logService;

    @Before
    public void setUp() throws Exception {
        Settings settings = settings();
        StreamService streamService = new InternalStreamService(settings);
        new LogStreamService(streamService);
        logService = new LogService(settings, streamService);
        logService.start();
    }

    @After
    public void tearDown() throws Exception {
        logService.stop();
        logService.close();
    }

    @Test
    public void test() throws Exception {
        Log log = logService.log("test log");

        long id1 = log.nextIndex();
        TextLogEntry entry1 = TextLogEntry.builder()
            .setIndex(id1)
            .setMessage("hello world")
            .build();
        log.appendEntry(entry1);

        long id2 = log.nextIndex();
        TextLogEntry entry2 = TextLogEntry.builder()
            .setIndex(id2)
            .setMessage("hello world")
            .build();
        log.appendEntry(entry2);

        LogEntry saved1 = log.getEntry(id1);
        LogEntry saved2 = log.getEntry(id2);

        ReflectionAssert.assertReflectionEquals(entry1, saved1);
        ReflectionAssert.assertReflectionEquals(entry2, saved2);
    }
}
{'fraction_non_alphanumeric': 0.10726887791107975, 'fraction_numerical': 0.0056457304163726185, 'mean_word_length': 2.894230769230769, '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': '6199771', 'n_tokens_mistral': 792, 'n_tokens_neox': 774, 'n_words': 151}