package fr.jmini.asciidoctorj.converter.mockcode;

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

import java.util.Arrays;
import java.util.Collections;

import org.asciidoctor.ast.Column;
import org.asciidoctor.ast.Table;
import org.junit.Test;

import fr.jmini.asciidoctorj.converter.code.CodeTestingUtility;

public class MockCodeConverterColumnTest {

    @Test
    public void testColumn() throws Exception {
        Column mockColumn = createMock();
        mock(Column.class);
        when(mockColumn.getStyle()).thenReturn("STYLE");
        when(mockColumn.getTable()).thenReturn(null);
        when(mockColumn.getColumnNumber()).thenReturn(2);
        when(mockColumn.getWidth()).thenReturn(550);
        when(mockColumn.getHorizontalAlignment()).thenReturn(Table.HorizontalAlignment.CENTER);
        when(mockColumn.getVerticalAlignment()).thenReturn(Table.VerticalAlignment.MIDDLE);

        MockCodeConverter converter = new MockCodeConverter(null, null);
        StringBuilder sb = new StringBuilder();
        converter.createColumnCode(sb, mockColumn);
        CodeTestingUtility.testGeneratedCode(sb.toString(), this.getClass());
    }

    // tag::generated-code[]
public Column createMock() {
Column mockColumn1 = mock(Column.class);
when(mockColumn1.getId()).thenReturn(null);
when(mockColumn1.getNodeName()).thenReturn(null);
when(mockColumn1.getParent()).thenReturn(null);
when(mockColumn1.getContext()).thenReturn(null);
when(mockColumn1.getDocument()).thenReturn(null);
when(mockColumn1.isInline()).thenReturn(false);
when(mockColumn1.isBlock()).thenReturn(false);
when(mockColumn1.getAttributes()).thenReturn(Collections.emptyMap());
when(mockColumn1.getRoles()).thenReturn(Arrays.asList("r1", "r2", "r3"));
when(mockColumn1.isReftext()).thenReturn(false);
when(mockColumn1.getStyle()).thenReturn("STYLE");
when(mockColumn1.getTable()).thenReturn(null);
when(mockColumn1.getColumnNumber()).thenReturn(2);
when(mockColumn1.getWidth()).thenReturn(550);
when(mockColumn1.getHorizontalAlignment()).thenReturn(Table.HorizontalAlignment.CENTER);
when(mockColumn1.getVerticalAlignment()).thenReturn(Table.VerticalAlignment.MIDDLE);
return mockColumn1;
}
 // end::generated-code[]
}

@@ -1209,16 +1209,20 @@
 -code%5B%5D%0A
+    
 public C
@@ -1242,16 +1242,24 @@
 ock() %7B%0A
+        
 Column m
@@ -1291,16 +1291,24 @@
 class);%0A
+        
 when(moc
@@ -1335,32 +1335,40 @@
 enReturn(null);%0A
+        
 when(mockColumn1
@@ -1393,32 +1393,40 @@
 enReturn(null);%0A
+        
 when(mockColumn1
@@ -1449,32 +1449,40 @@
 enReturn(null);%0A
+        
 when(mockColumn1
@@ -1506,32 +1506,40 @@
 enReturn(null);%0A
+        
 when(mockColumn1
@@ -1564,32 +1564,40 @@
 enReturn(null);%0A
+        
 when(mockColumn1
@@ -1620,32 +1620,40 @@
 nReturn(false);%0A
+        
 when(mockColumn1
@@ -1675,32 +1675,40 @@
 nReturn(false);%0A
+        
 when(mockColumn1
@@ -1757,24 +1757,32 @@
 mptyMap());%0A
+        
 when(mockCol
@@ -1843,16 +1843,24 @@
 %22r3%22));%0A
+        
 when(moc
@@ -1900,16 +1900,24 @@
 false);%0A
+        
 when(moc
@@ -1958,16 +1958,24 @@
 TYLE%22);%0A
+        
 when(moc
@@ -2013,16 +2013,24 @@
 (null);%0A
+        
 when(moc
@@ -2072,16 +2072,24 @@
 urn(2);%0A
+        
 when(moc
@@ -2126,16 +2126,24 @@
 n(550);%0A
+        
 when(moc
@@ -2223,16 +2223,24 @@
 ENTER);%0A
+        
 when(moc
@@ -2316,16 +2316,24 @@
 IDDLE);%0A
+        
 return m
@@ -2344,18 +2344,25 @@
 olumn1;%0A
-%7D%0A
+    %7D%0A   
  // end:

format code