package org.protempa.dest.table;

/*-
 * #%L
 * Protempa Framework
 * %%
 * Copyright (C) 2012 - 2017 Emory University
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;
import org.junit.Assert;
import org.junit.Test;
import org.protempa.KnowledgeSourceReadException;

/**
 *
 * @author Andrew Post
 */
public class ConstantColumnSpecTest {
    
    @Test
    public void testHeading() throws KnowledgeSourceReadException {
        ConstantColumnSpec ccs = new ConstantColumnSpec("heading", "value");
        Assert.assertArrayEquals(new String[]{"heading"}, ccs.columnNames(null));
    }
    
    @Test
    public void testValue() throws IOException, TabularWriterException {
        ConstantColumnSpec ccs = new ConstantColumnSpec("heading", "value");
        StringWriter sw = new StringWriter();
        try (FileTabularWriter ftw = new FileTabularWriter(new BufferedWriter(sw), '\t')) {
            ccs.columnValues("00001", null, null, null, null, null, ftw);
        }
        Assert.assertEquals("value", sw.toString());
    }
}

@@ -1248,21 +1248,8 @@
 rows
- IOException,
  Tab
@@ -1262,32 +1262,32 @@
 iterException %7B%0A
+
         Constant
@@ -1565,24 +1565,24 @@
 ;%0A        %7D%0A
-
         Asse
@@ -1628,10 +1628,443 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void testNullValue() throws TabularWriterException %7B%0A        ConstantColumnSpec ccs = new ConstantColumnSpec(%22heading%22, null);%0A        StringWriter sw = new StringWriter();%0A        try (FileTabularWriter ftw = new FileTabularWriter(new BufferedWriter(sw), '%5Ct')) %7B%0A            ccs.columnValues(%2200001%22, null, null, null, null, null, ftw);%0A        %7D%0A        Assert.assertEquals(%22NULL%22, sw.toString());%0A    %7D%0A
 %7D%0A

Add unit test for null value in a ConstantColumnSpec.