package org.oblodiff.token.text.simple;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import org.junit.Ignore;
import org.oblodiff.token.text.linebased.Line;
import org.oblodiff.token.text.Character;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Tests for {@link Document}.
 */
public class DocumentTest {
    @Test
    public void getChildren_shouldBeEmptyIfDocumentIsEmpty() {
        assertThat(new Document("").getChildren()).isEmpty();
    }

    @Test
    public void getChildren_shouldReturnOneChildIfConsistsOfOneCarriageReturn() {
        assertThat(new Document("\r").getChildren()).containsExactly(new Character('\r'));
    }

    @Test
    public void getChildren_shouldReturnOneChildIfConsistsOfOneLineFeed() {
        assertThat(new Document("\n").getChildren()).containsExactly(new Character('\n'));
    }

    @Test
    public void getChildren_shouldReturnOneChildIfConsistsOfOneLine() {
        assertThat(new Document("super").getChildren()).containsExactly(new Line("super"));
    }

    @Test
    public void getChildren_shouldAddNewLineAsCharacter() {
        assertThat(new Document("super\n").getChildren()).containsExactly(new Line("super"), new Character('\n'));
    }

    @Test
    public void getChildren_shouldAddCarriageReturnAsCharacter() {
        assertThat(new Document("super\r").getChildren()).containsExactly(new Line("super"), new Character('\r'));
    }

    @Test
    @Ignore
    public void getChildren_shouldAddCarriageReturnLineFeedAsCharacters() {
        assertThat(new Document("one\r\nis").getChildren()).containsExactly(new Line("one"), new Character('\r'), new
            Character('\n'), new Line("is"));
    }

    @Test
    public void equalsAndHashCode() {
        // Null is avoided by validation in constructor.
        EqualsVerifier.forClass(Document.class).suppress(Warning.NULL_FIELDS).verify();
    }
}

@@ -123,80 +123,8 @@
 ng;%0A
-import org.junit.Ignore;%0Aimport org.oblodiff.token.text.linebased.Line;%0A
 impo
@@ -977,36 +977,41 @@
 ainsExactly(new 
-Line
+Paragraph
 (%22super%22));%0A    
@@ -1153,36 +1153,41 @@
 ainsExactly(new 
-Line
+Paragraph
 (%22super%22), new C
@@ -1365,20 +1365,25 @@
 tly(new 
-Line
+Paragraph
 (%22super%22
@@ -1428,20 +1428,8 @@
 est%0A
-    @Ignore%0A
     
@@ -1462,45 +1462,306 @@
 ould
-AddCarriageReturnLineFeedAsCharacters
+SplitParagraphsAtDoubleCarriageReturn() %7B%0A        assertThat(new Document(%22one%5Cr%5Cris%22).getChildren()).containsExactly(new Paragraph(%22one%22), new Character('%5Cr'), new%0A            Character('%5Cr'), new Paragraph(%22is%22));%0A    %7D%0A%0A    @Test%0A    public void getChildren_shouldSplitParagraphsAtDoubleLineFeed
 () %7B
@@ -1798,17 +1798,17 @@
 nt(%22one%5C
-r
+n
 %5Cnis%22).g
@@ -1841,20 +1841,25 @@
 tly(new 
-Line
+Paragraph
 (%22one%22),
@@ -1867,33 +1867,33 @@
 new Character('%5C
-r
+n
 '), new%0A        
@@ -1917,20 +1917,25 @@
 '), new 
-Line
+Paragraph
 (%22is%22));

Fix test.