Stanag4609ProcessorImpl implements Stanag4609Processor { @Override public void handle( Map<String, KlvHandler> handlers, KlvHandler defaultHander, Map<Integer, List<DecodedKLVMetadataPacket>> stanagMetadata) { stanagMetadata.values().stream() .flatMap(List::stream) .forEach( decodedKLVMetadataPacket -> { Map<String, KlvDataElement> dataElements = new HashMap<>(); handle( handlers, defaultHander, decodedKLVMetadataPacket.getDecodedKLV(), dataElements); postProcessor.postProcess(dataElements, handlers); }); } Stanag4609ProcessorImpl(PostProcessor postProcessor); @Override void handle(
      Map<String, KlvHandler> handlers,
      KlvHandler defaultHander,
      Map<Integer, List<DecodedKLVMetadataPacket>> stanagMetadata); @Override void handle(
      Map<String, KlvHandler> handlers,
      KlvHandler defaultHandler,
      KlvContext klvContext,
      Map<String, KlvDataElement> dataElements); @Override void handle(
      Map<String, KlvHandler> handlers,
      KlvHandler defaultHandler,
      KlvDataElement klvDataElement,
      Map<String, KlvDataElement> dataElements); @Override void callDataElementHandlers(
      Map<String, KlvHandler> handlers,
      KlvHandler defaultHandler,
      KlvDataElement klvDataElement,
      Map<String, KlvDataElement> dataElements); @Override void handle(
      Map<String, KlvHandler> handlers,
      KlvHandler defaultHandler,
      KlvLocalSet klvLocalSet,
      Map<String, KlvDataElement> dataElements);  }
@Test public void testHandleWithKlvContext() throws KlvDecodingException { KlvContext klvContext = new KlvContext( Klv.KeyLength.ONE_BYTE, Klv.LengthEncoding.ONE_BYTE, Collections.singleton(klvIntegerEncodedFloatingPoint)); stanag4609Processor.handle( Collections.singletonMap(FIELD_NAME, klvHandler), defaultKlvHandler, klvContext, dataElements); verify(klvHandler, atLeastOnce()).accept(klvIntegerEncodedFloatingPoint); }
@Test public void testHandleWithKlvLocalSet() throws KlvDecodingException { KlvContext klvContext = new KlvContext( Klv.KeyLength.ONE_BYTE, Klv.LengthEncoding.ONE_BYTE, Collections.singleton(klvIntegerEncodedFloatingPoint)); KlvDataElement klvLocalSet = mock(KlvLocalSet.class); when(klvLocalSet.getValue()).thenReturn(klvContext); stanag4609Processor.handle( Collections.singletonMap(FIELD_NAME, klvHandler), defaultKlvHandler, klvLocalSet, dataElements); verify(klvHandler, atLeastOnce()).accept(klvIntegerEncodedFloatingPoint); }
@Test public void testHandleWithKlvDataElement() throws KlvDecodingException { stanag4609Processor.handle( Collections.singletonMap(FIELD_NAME, klvHandler), defaultKlvHandler, klvIntegerEncodedFloatingPoint, dataElements); verify(klvHandler, atLeastOnce()).accept(klvIntegerEncodedFloatingPoint); }
@Test public void testHandleWithStanagMetadata() throws KlvDecodingException { DecodedKLVMetadataPacket p2 = mock(DecodedKLVMetadataPacket.class); when(p2.getDecodedKLV()) .thenReturn( new KlvContext( Klv.KeyLength.ONE_BYTE, Klv.LengthEncoding.ONE_BYTE, Collections.singleton(klvIntegerEncodedFloatingPoint))); Map<String, KlvHandler> handlers = Collections.singletonMap(FIELD_NAME, klvHandler); Map<Integer, List<DecodedKLVMetadataPacket>> stanag = Collections.singletonMap(1, Collections.singletonList(p2)); stanag4609Processor.handle(handlers, defaultKlvHandler, stanag); verify(klvHandler, atLeastOnce()).accept(klvIntegerEncodedFloatingPoint); }