RoutingSlip { public String channel(NitfSegmentsFlow nitfSegmentsFlow) { if (nitfSegmentsFlow == null) { throw new IllegalArgumentException("method argument 'nitfSegmentsFlow' may not be null."); } final ThreadLocal<Boolean> tresExist = new ThreadLocal<>(); tresExist.set(false); final ThreadLocal<Boolean> imagesExist = new ThreadLocal<>(); imagesExist.set(false); nitfSegmentsFlow .fileHeader(header -> tresExist.set(tresExist(header))) .forEachImageSegment(header -> imagesExist.set(true)); if (!imagesExist.get() && tresExist.get()) { return GMTI_ROUTE; } return IMAGE_ROUTE; }  String channel(NitfSegmentsFlow nitfSegmentsFlow); static final String GMTI_ROUTE; static final String IMAGE_ROUTE; }
@Test(expected = IllegalArgumentException.class) public void testChannelNullInput() { routingSlip.channel(null); }
@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)); }
@Test public void testChannelImageTre() throws FileNotFoundException, NitfFormatException { NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(IMAGE_TRE_NTF_FILENAME)).headerOnly(); String channel = routingSlip.channel(parserInputFlow); assertThat(channel, is(RoutingSlip.IMAGE_ROUTE)); }
@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)); }
@Test public void testChannelNoImageNoTre() throws FileNotFoundException, NitfFormatException { NitfSegmentsFlow parserInputFlow = new NitfParserInputFlowImpl().file(new File(NO_IMAGE_NO_TRE_NTF_FILENAME)).headerOnly(); String channel = routingSlip.channel(parserInputFlow); assertThat(channel, is(RoutingSlip.IMAGE_ROUTE)); }