use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.
the class NitfGmtiTransformerTest method testTre.
@Test
public void testTre() throws IOException, CatalogTransformerException, NitfFormatException {
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(getInputStream(GMTI_TEST_NITF)).allData();
Metacard metacard = metacardFactory.createMetacard("101");
nitfSegmentsFlow = nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
metacard = nitfGmtiTransformer.transform(nitfSegmentsFlow, metacard);
assertNotNull(metacard);
validateDate(metacard.getCreatedDate(), "2016-06-22 23:39:22");
validateDate(metacard.getEffectiveDate(), "2016-06-22 23:39:22");
validateDate(metacard.getModifiedDate(), "2016-06-22 23:39:22");
assertThat(metacard.getMetacardType().getName(), is("isr.gmti"));
Map<NitfAttribute, String> mtirpbAttributesMap = initMtirpbAttributes();
assertMtirpbAttributes(metacard, mtirpbAttributesMap);
}
use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.
the class ImageInputTransformerTest method testPiaprd.
@Test
public void testPiaprd() throws IOException, NitfFormatException {
File nitfFile = File.createTempFile("nitf-", ".ntf");
try {
Map<NitfAttribute, NitfValue> treMap = createNitfWithPiaprd(nitfFile);
try (InputStream inputStream = new FileInputStream(nitfFile)) {
Metacard metacard = metacardFactory.createMetacard("piaprdTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
headerTransformer.transform(nitfSegmentsFlow, metacard);
transformer.transform(nitfSegmentsFlow, metacard);
assertAttributesMap(metacard, treMap);
}
} finally {
nitfFile.delete();
}
}
use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.
the class ImageInputTransformerTest method createNitfWithAimidb.
private static Map<NitfAttribute, NitfValue> createNitfWithAimidb(File file) {
String acquisitionDate = "20161013121212";
String missionNumber = "UNKN";
String country = "US";
String location = "4559N23345W";
Tre aimidb = TreFactory.getDefault("AIMIDB", TreSource.ImageExtendedSubheaderData);
aimidb.add(new TreEntryImpl("ACQUISITION_DATE", acquisitionDate, "string"));
aimidb.add(new TreEntryImpl("MISSION_NO", missionNumber, "string"));
aimidb.add(new TreEntryImpl("MISSION_IDENTIFICATION", "NOT AVAIL.", "string"));
aimidb.add(new TreEntryImpl("FLIGHT_NO", "01", "string"));
aimidb.add(new TreEntryImpl("OP_NUM", "001", "UINT"));
aimidb.add(new TreEntryImpl("CURRENT_SEGMENT", "AA", "string"));
aimidb.add(new TreEntryImpl("REPRO_NUM", "01", "UINT"));
aimidb.add(new TreEntryImpl("REPLAY", "000", "string"));
aimidb.add(new TreEntryImpl("RESERVED_1", " ", "string"));
aimidb.add(new TreEntryImpl("START_TILE_COLUMN", "001", "UINT"));
aimidb.add(new TreEntryImpl("START_TILE_ROW", "00001", "UINT"));
aimidb.add(new TreEntryImpl("END_SEGMENT", "AA", "string"));
aimidb.add(new TreEntryImpl("END_TILE_COLUMN", "001", "UINT"));
aimidb.add(new TreEntryImpl("END_TILE_ROW", "00001", "UINT"));
aimidb.add(new TreEntryImpl("COUNTRY", country, "string"));
aimidb.add(new TreEntryImpl("RESERVED_2", " ", "string"));
aimidb.add(new TreEntryImpl("LOCATION", location, "string"));
aimidb.add(new TreEntryImpl("RESERVED_3", " ", "string"));
ImageSegment imageSegment = TreUtilityTest.createImageSegment();
imageSegment.getTREsRawStructure().add(aimidb);
new NitfCreationFlowImpl().fileHeader(() -> TreUtilityTest.createFileHeader()).imageSegment(() -> imageSegment).write(file.getAbsolutePath());
// key value pair of nitf attributes and expected getAttributes
Map<NitfAttribute, NitfValue> assertMap = new HashMap<>();
assertMap.put(AimidbAttribute.ACQUISITION_DATE_ATTRIBUTE, new NitfValue(acquisitionDate));
assertMap.put(AimidbAttribute.MISSION_NUMBER_ATTRIBUTE, new NitfValue(missionNumber));
assertMap.put(AimidbAttribute.COUNTRY_CODE_ATTRIBUTE, new NitfValue(country));
assertMap.put(AimidbAttribute.LOCATION_ATTRIBUTE, new NitfValue(location));
return assertMap;
}
use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.
the class ImageInputTransformerTest method testAimidb.
@Test
public void testAimidb() throws IOException, NitfFormatException {
File nitfFile = File.createTempFile("nitf-", ".ntf");
try {
Map<NitfAttribute, NitfValue> treMap = createNitfWithAimidb(nitfFile);
try (InputStream inputStream = new FileInputStream(nitfFile)) {
Metacard metacard = metacardFactory.createMetacard("aimidbTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
headerTransformer.transform(nitfSegmentsFlow, metacard);
transformer.transform(nitfSegmentsFlow, metacard);
assertAttributesMap(metacard, treMap);
}
} finally {
nitfFile.delete();
}
}
use of org.codice.alliance.transformer.nitf.common.NitfAttribute in project alliance by codice.
the class ImageInputTransformerTest method testExpltb.
@Test
public void testExpltb() throws IOException, NitfFormatException {
File nitfFile = File.createTempFile("nitf-", ".ntf");
try {
Map<NitfAttribute, NitfValue> treMap = createNitfWithExpltb(nitfFile);
try (InputStream inputStream = new FileInputStream(nitfFile)) {
Metacard metacard = metacardFactory.createMetacard("expltbTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
headerTransformer.transform(nitfSegmentsFlow, metacard);
transformer.transform(nitfSegmentsFlow, metacard);
assertAttributesMap(metacard, treMap);
}
} finally {
nitfFile.delete();
}
}
Aggregations