<commit_before>package com.github.cstroe.svndumpgui.internal.transform;

import com.github.cstroe.svndumpgui.api.FileContentChunk;
import com.github.cstroe.svndumpgui.api.SvnDump;
import com.github.cstroe.svndumpgui.api.SvnDumpConsumer;
import com.github.cstroe.svndumpgui.api.SvnDumpMutator;
import com.github.cstroe.svndumpgui.api.SvnDumpPreamble;
import com.github.cstroe.svndumpgui.api.SvnDumpWriter;
import com.github.cstroe.svndumpgui.api.SvnNode;
import com.github.cstroe.svndumpgui.api.SvnRevision;
import com.github.cstroe.svndumpgui.generated.ParseException;
import com.github.cstroe.svndumpgui.generated.SvnDumpFileParser;
import com.github.cstroe.svndumpgui.internal.SvnDumpFileParserTest;
import com.github.cstroe.svndumpgui.internal.utility.TestUtil;
import com.github.cstroe.svndumpgui.internal.writer.SvnDumpInMemory;
import com.github.cstroe.svndumpgui.internal.writer.SvnDumpWriterImpl;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.Sequence;
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

public class ClearRevisionTest {

    @Test
    public void clear_revision() throws ParseException {
        String dumpFilePath = "dumps/svn_multi_file_delete.dump";
        {
            SvnDump dumpBefore = SvnDumpFileParserTest.parse(dumpFilePath);

            assertThat(dumpBefore.getRevisions().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpBefore.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(2).getNodes().size(), is(3));
        }
        {
            SvnDumpMutator cr = new ClearRevision(2);
            SvnDump dumpAfter = SvnDumpFileParserTest.consume(dumpFilePath, cr);

            assertThat(dumpAfter.getRevisions().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpAfter.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(2).getNodes().size(), is(0)); // nodes cleared
        }
    }

    @Test
    public void clear_range() throws ParseException {
        String dumpFilePath = "dumps/svn_multi_file_delete.dump";
        {
            SvnDump dumpBefore = SvnDumpFileParserTest.parse(dumpFilePath);

            assertThat(dumpBefore.getRevisions().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpBefore.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(2).getNodes().size(), is(3));
        }
        {
            SvnDumpMutator clear = new ClearRevision(1, 2);
            SvnDump dumpAfter = SvnDumpFileParserTest.consume(dumpFilePath, clear);

            assertThat(dumpAfter.getRevisions().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpAfter.getRevisions().get(1).getNodes().size(), is(0)); // nodes cleared
            assertThat(dumpAfter.getRevisions().get(2).getNodes().size(), is(0)); // nodes cleared
        }
    }

    @Test(expected = IllegalArgumentException.class)
    public void negative_revision_numbers_not_allowed() {
        new ClearRevision(-1);
    }

    @Test(expected = IllegalArgumentException.class)
    public void negative_revision_numbers_not_allowed_again() {
        new ClearRevision(-1,1);
    }
<commit_msg>100% test coverage of ClearRevision.<commit_after>package com.github.cstroe.svndumpgui.internal.transform;

import com.github.cstroe.svndumpgui.api.FileContentChunk;
import com.github.cstroe.svndumpgui.api.SvnDump;
import com.github.cstroe.svndumpgui.api.SvnDumpConsumer;
import com.github.cstroe.svndumpgui.api.SvnDumpMutator;
import com.github.cstroe.svndumpgui.api.SvnDumpPreamble;
import com.github.cstroe.svndumpgui.api.SvnDumpWriter;
import com.github.cstroe.svndumpgui.api.SvnNode;
import com.github.cstroe.svndumpgui.api.SvnRevision;
import com.github.cstroe.svndumpgui.generated.ParseException;
import com.github.cstroe.svndumpgui.generated.SvnDumpFileParser;
import com.github.cstroe.svndumpgui.internal.SvnDumpFileParserTest;
import com.github.cstroe.svndumpgui.internal.utility.TestUtil;
import com.github.cstroe.svndumpgui.internal.writer.SvnDumpInMemory;
import com.github.cstroe.svndumpgui.internal.writer.SvnDumpWriterImpl;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.Sequence;
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

public class ClearRevisionTest {

    @Test
    public void clear_revision() throws ParseException {
        String dumpFilePath = "dumps/svn_multi_file_delete.dump";
        {
            SvnDump dumpBefore = SvnDumpFileParserTest.parse(dumpFilePath);

            assertThat(dumpBefore.getRevisions().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpBefore.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(2).getNodes().size(), is(3));
        }
        {
            SvnDumpMutator cr = new ClearRevision(2);
            SvnDump dumpAfter = SvnDumpFileParserTest.consume(dumpFilePath, cr);

            assertThat(dumpAfter.getRevisions().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpAfter.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(2).getNodes().size(), is(0)); // nodes cleared
        }
    }

    @Test
    public void clear_range() throws ParseException {
        String dumpFilePath = "dumps/svn_multi_file_delete.dump";
        {
            SvnDump dumpBefore = SvnDumpFileParserTest.parse(dumpFilePath);

            assertThat(dumpBefore.getRevisions().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpBefore.getRevisions().get(1).getNodes().size(), is(3));
            assertThat(dumpBefore.getRevisions().get(2).getNodes().size(), is(3));
        }
        {
            SvnDumpMutator clear = new ClearRevision(1, 2);
            SvnDump dumpAfter = SvnDumpFileParserTest.consume(dumpFilePath, clear);

            assertThat(dumpAfter.getRevisions().size(), is(3));
            assertThat(dumpAfter.getRevisions().get(0).getNodes().size(), is(0));
            assertThat(dumpAfter.getRevisions().get(1).getNodes().size(), is(0)); // nodes cleared
            assertThat(dumpAfter.getRevisions().get(2).getNodes().size(), is(0)); // nodes cleared
        }
    }

    @Test(expected = IllegalArgumentException.class)
    public void negative_revision_numbers_not_allowed() {
        new ClearRevision(-1);
    }

    @Test(expected = IllegalArgumentException.class)
    public void negative_revision_numbers_not_allowed_again() {
        new ClearRevision(-1,1);
    }

    @Test(expected = IllegalArgumentException.class)
    public void negative_revision_numbers_not_allowed_in_toRevision() {
        new ClearRevision(1,-1);
    }

{'fraction_non_alphanumeric': 0.13273857799405245, 'fraction_numerical': 0.009867531765341985, 'mean_word_length': 3.715742511153601, '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': '2501497', 'n_tokens_mistral': 2340, 'n_tokens_neox': 2330, 'n_words': 299}