/**
 * Copyright (c) Codice Foundation
 * 
 * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details. A copy of the GNU Lesser General Public License
 * is distributed along with this program and can be found at
 * <http://www.gnu.org/licenses/lgpl.html>.
 * 
 **/
package org.codice.nitf.filereader;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.io.InputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.EnumSet;

import org.junit.Test;

public class Nitf21GraphicParsingTest {

    @Test
    public void testExtractionWithOptionTurnedOn() throws IOException, ParseException {
        NitfFile file = new NitfFile();
        file.parse(getInputStream(), EnumSet.of(ParseOption.EXTRACT_GRAPHIC_SEGMENT_DATA));
        assertEquals(1, file.getNumberOfGraphicSegments());

        NitfGraphicSegment graphicSegment = file.getGraphicSegment(1);
        assertGraphicSegmentMetadataIsAsExpected(graphicSegment);
        assertEquals(780, graphicSegment.getGraphicData().length);
    }

    @Test
    public void testExtractionWithOptionTurnedOff() throws IOException, ParseException {
        NitfFile file = new NitfFile();
        file.parse(getInputStream(), EnumSet.noneOf(ParseOption.class));
        assertEquals(1, file.getNumberOfGraphicSegments());

        NitfGraphicSegment graphicSegment = file.getGraphicSegment(1);
        assertGraphicSegmentMetadataIsAsExpected(graphicSegment);
        assertNull(graphicSegment.getGraphicData());
    }

    private void assertGraphicSegmentMetadataIsAsExpected(NitfGraphicSegment graphicSegment) {
        assertNotNull(graphicSegment);
        // TODO: check all the graphic bits
    }

    private InputStream getInputStream() {
        final String testfile = "/i_3051e.ntf";

        assertNotNull("Test file missing", getClass().getResource(testfile));
        return getClass().getResourceAsStream(testfile);
    }

}
@@ -2189,282 +2189,2208 @@
     
-// TODO: check all the graphic bits%0A    %7D%0A%0A    private InputStream getInputStream() %7B%0A        final String testfile = %22/i_3051e.ntf%22;%0A%0A        assertNotNull(%22Test file missing%22, getClass().getResource(testfile));%0A        return getClass().getResourceAsStream(testfile);%0A    %7D%0A%0A%7D
+assertEquals(%220000000001%22, graphicSegment.getIdentifier());%0A        assertEquals(%22multi.cgm  SYMBOL.%22, graphicSegment.getGraphicName());%0A        assertUnclasAndEmpty(graphicSegment.getSecurityMetadata());%0A        assertEquals(1, graphicSegment.getGraphicDisplayLevel());%0A        assertEquals(0, graphicSegment.getAttachmentLevel());%0A        assertEquals(0, graphicSegment.getGraphicLocationRow());%0A        assertEquals(0, graphicSegment.getGraphicLocationColumn());%0A        assertEquals(25, graphicSegment.getBoundingBox1Row());%0A        assertEquals(25, graphicSegment.getBoundingBox1Column());%0A        assertEquals(GraphicColour.COLOUR, graphicSegment.getGraphicColour());%0A        assertEquals(79, graphicSegment.getBoundingBox2Row());%0A        assertEquals(430, graphicSegment.getBoundingBox2Column());%0A    %7D%0A%0A    private InputStream getInputStream() %7B%0A        final String testfile = %22/i_3051e.ntf%22;%0A%0A        assertNotNull(%22Test file missing%22, getClass().getResource(testfile));%0A        return getClass().getResourceAsStream(testfile);%0A    %7D%0A%0A    void assertUnclasAndEmpty(NitfSecurityMetadata securityMetadata) %7B%0A        assertEquals(NitfSecurityClassification.UNCLASSIFIED, securityMetadata.getSecurityClassification());%0A        assertEquals(%22%22, securityMetadata.getSecurityClassificationSystem());%0A        assertEquals(%22%22, securityMetadata.getCodewords());%0A        assertEquals(%22%22, securityMetadata.getControlAndHandling());%0A        assertEquals(%22%22, securityMetadata.getReleaseInstructions());%0A        assertEquals(%22%22, securityMetadata.getDeclassificationType());%0A        assertEquals(%22%22, securityMetadata.getDeclassificationDate());%0A        assertEquals(%22%22, securityMetadata.getDeclassificationExemption());%0A        assertEquals(%22%22, securityMetadata.getDowngrade());%0A        assertEquals(%22%22, securityMetadata.getDowngradeDate());%0A        assertEquals(%22%22, securityMetadata.getClassificationText());%0A        assertEquals(%22%22, securityMetadata.getClassificationAuthorityType());%0A        assertEquals(%22%22, securityMetadata.getClassificationAuthority());%0A        assertEquals(%22%22, securityMetadata.getClassificationReason());%0A        assertEquals(%22%22, securityMetadata.getSecurityControlNumber());%0A    %7D%0A%0A%7D%0A

Implement TODO item for NITF 2.1 graphic segment tests