Search in sources :

Example 6 with DateTime

use of org.codice.imaging.nitf.core.common.DateTime in project alliance by codice.

the class ImageInputTransformerTest method testNitfWithDifferentImageDates.

@Test
public void testNitfWithDifferentImageDates() throws Exception {
    File nitfFile = File.createTempFile("nitf-", ".ntf");
    try {
        final DateTime fileDateTime = NitfTestCommons.createNitfDateTime(2016, 1, 1, 0, 0, 0);
        DateTime[] imageDateTimes = { NitfTestCommons.createNitfDateTime(2001, 1, 1, 0, 0, 0), NitfTestCommons.createNitfDateTime(2002, 1, 1, 0, 0, 0), NitfTestCommons.createNitfDateTime(2003, 1, 1, 0, 0, 0) };
        createNitfWithDifferentImageDateTimes(nitfFile, fileDateTime, imageDateTimes);
        try (InputStream inputStream = new FileInputStream(nitfFile)) {
            Metacard metacard = metacardFactory.createMetacard("differentImageDateTimesTest");
            NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
            nitfSegmentsFlow = headerTransformer.transform(nitfSegmentsFlow, metacard);
            metacard = transformer.transform(nitfSegmentsFlow, metacard);
            assertNotNull(metacard);
            validateDates(metacard, fileDateTime, imageDateTimes);
        }
    } finally {
        nitfFile.delete();
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NitfSegmentsFlow(org.codice.imaging.nitf.fluent.NitfSegmentsFlow) NitfParserInputFlowImpl(org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl) File(java.io.File) DateTime(org.codice.imaging.nitf.core.common.DateTime) FileInputStream(java.io.FileInputStream) TreUtilityTest(org.codice.alliance.transformer.nitf.TreUtilityTest) Test(org.junit.Test)

Example 7 with DateTime

use of org.codice.imaging.nitf.core.common.DateTime in project alliance by codice.

the class NitfAttributeConvertersTest method testConvertNitfDateWithNullZonedTime.

@Test
public void testConvertNitfDateWithNullZonedTime() {
    // setup
    DateTime mockDateTime = mock(DateTime.class);
    doReturn(null).when(mockDateTime).getZonedDateTime();
    // when
    Date convertedDate = NitfAttributeConverters.nitfDate(mockDateTime);
    // then
    assertThat(convertedDate, is(nullValue()));
}
Also used : DateTime(org.codice.imaging.nitf.core.common.DateTime) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateTime (org.codice.imaging.nitf.core.common.DateTime)7 Test (org.junit.Test)5 DataSource (org.codice.imaging.nitf.core.DataSource)3 NitfHeader (org.codice.imaging.nitf.core.header.NitfHeader)3 ImageCoordinates (org.codice.imaging.nitf.core.image.ImageCoordinates)3 ImageSegment (org.codice.imaging.nitf.core.image.ImageSegment)3 FileSecurityMetadata (org.codice.imaging.nitf.core.security.FileSecurityMetadata)3 SecurityMetadata (org.codice.imaging.nitf.core.security.SecurityMetadata)3 NitfSegmentsFlow (org.codice.imaging.nitf.fluent.NitfSegmentsFlow)3 NitfParserInputFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl)3 NitfSegmentsFlowImpl (org.codice.imaging.nitf.fluent.impl.NitfSegmentsFlowImpl)3 BinaryContent (ddf.catalog.data.BinaryContent)2 BufferedImage (java.awt.image.BufferedImage)2 Date (java.util.Date)2 NitfFormatException (org.codice.imaging.nitf.core.common.NitfFormatException)2 TargetIdImpl (org.codice.imaging.nitf.core.image.impl.TargetIdImpl)2 Metacard (ddf.catalog.data.Metacard)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1