use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.
the class RoutingSlipTest method testChannelImageNoTres.
@Test
public void testChannelImageNoTres() throws FileNotFoundException, NitfFormatException {
NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(IMAGE_NO_TRE_NTF_FILENAME)).headerOnly();
String channel = routingSlip.channel(parserInputFlow);
assertThat(channel, is(RoutingSlip.IMAGE_ROUTE));
}
use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.
the class RoutingSlipTest method testChannelNoImageTre.
@Test
public void testChannelNoImageTre() throws FileNotFoundException, NitfFormatException {
NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(NO_IMAGE_TRE_NTF_FILENAME)).headerOnly();
String channel = routingSlip.channel(parserInputFlow);
assertThat(channel, is(RoutingSlip.GMTI_ROUTE));
}
use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.
the class NitfHeaderTransformerTest method testValidationWarningsOnNitfAttributeTransformException.
@Test
public void testValidationWarningsOnNitfAttributeTransformException() throws Exception {
String originalNitfValue = "US";
NitfTestCommons.setupNitfUtilities(originalNitfValue, Arrays.asList("USA", "CAN"));
File nitfFile = temporaryFolder.newFile("nitf-attribute-header-test.ntf");
FileSecurityMetadata fileSecurityMetadata = TreUtilityTest.createSecurityMetadata();
when(fileSecurityMetadata.getSecurityClassificationSystem()).thenReturn(originalNitfValue);
Supplier<NitfHeader> nitfHeader = () -> TreUtilityTest.createFileHeader(fileSecurityMetadata);
new NitfCreationFlowImpl().fileHeader(nitfHeader).write(nitfFile.getAbsolutePath());
Metacard metacard;
try (InputStream inputStream = new FileInputStream(nitfFile)) {
metacard = metacardFactory.createMetacard("nitfHeaderTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
}
assertThat(metacard, is(not(nullValue())));
assertThat(metacard.getAttribute(Validation.VALIDATION_WARNINGS).getValues().size(), equalTo(1));
assertThat(metacard.getAttribute(Security.CLASSIFICATION_SYSTEM).getValue(), is(originalNitfValue));
}
use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl 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();
}
}
use of org.codice.imaging.nitf.fluent.impl.NitfParserInputFlowImpl in project alliance by codice.
the class ImageInputTransformerTest method testPiaimc.
@Test
public void testPiaimc() throws IOException, NitfFormatException {
File nitfFile = File.createTempFile("nitf-", ".ntf");
try {
createNitfWithPiaimc(nitfFile);
try (InputStream inputStream = new FileInputStream(nitfFile)) {
Metacard metacard = metacardFactory.createMetacard("csexraTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
transformer.transform(nitfSegmentsFlow, metacard);
assertThat(metacard.getAttribute(Isr.CLOUD_COVER).getValue(), is(70.0));
}
} finally {
nitfFile.delete();
}
}
Aggregations