MpegTsInputTransformer implements InputTransformer { @Override public Metacard transform(InputStream inputStream) throws IOException, CatalogTransformerException { return transform(inputStream, null); } MpegTsInputTransformer(
      InputTransformer inputTransformer,
      List<MetacardType> metacardTypes,
      Stanag4609Processor stanag4609Processor,
      KlvHandlerFactory klvHandlerFactory,
      KlvHandler defaultKlvHandler,
      StanagParserFactory stanagParserFactory,
      KlvProcessor klvProcessor,
      Double distanceTolerance); @SuppressWarnings("unused") void setSubsampleCount(Integer subsampleCount); void setDistanceTolerance(Double distanceTolerance); Double getDistanceTolerance(); @Override Metacard transform(InputStream inputStream); void setSecurityClassificationCode1(String classification); void setSecurityClassificationCode2(String classification); void setSecurityClassificationCode3(String classification); void setSecurityClassificationCode4(String classification); void setSecurityClassificationCode5(String classification); void setSecurityClassificationDefault(String classification); @Override Metacard transform(InputStream inputStream, final String id); static final String CONTENT_TYPE; static final String DATA_TYPE; }
@Test public void testCopyInputTransformerAttributes() throws Exception { metacard.setContentTypeName("some/thing"); metacard.setMetadata("the metadata"); when(streamParser.parse()).thenReturn(Collections.emptyMap()); MpegTsInputTransformer t = new MpegTsInputTransformer( inputTransformer, metacardTypes, stanag4609Processor, klvHandlerFactory, defaultKlvHandler, stanagParserFactory, klvProcessor, DISTANCE_TOLERANCE); try (InputStream inputStream = new ByteArrayInputStream(new byte[] {})) { Metacard finalMetacard = t.transform(inputStream); assertThat(finalMetacard.getAttribute(Media.TYPE), is(notNullValue())); assertThat( finalMetacard.getAttribute(Media.TYPE).getValue(), is(MpegTsInputTransformer.CONTENT_TYPE)); assertThat(finalMetacard.getContentTypeName(), is(MpegTsInputTransformer.CONTENT_TYPE)); assertThat(finalMetacard.getMetadata(), is("the metadata")); } }
@Test public void testDataTypeField() throws Exception { MpegTsInputTransformer t = new MpegTsInputTransformer( inputTransformer, metacardTypes, stanag4609Processor, klvHandlerFactory, defaultKlvHandler, stanagParserFactory, klvProcessor, DISTANCE_TOLERANCE); try (InputStream inputStream = new ByteArrayInputStream(new byte[] {})) { Metacard finalMetacard = t.transform(inputStream); assertThat( finalMetacard.getAttribute(Core.DATATYPE), is(new AttributeImpl(Core.DATATYPE, MpegTsInputTransformer.DATA_TYPE))); } }
@Test(expected = CatalogTransformerException.class) public void testStanagParseError() throws Exception { when(streamParser.parse()).thenThrow(new RuntimeException()); MpegTsInputTransformer t = new MpegTsInputTransformer( inputTransformer, metacardTypes, stanag4609Processor, klvHandlerFactory, defaultKlvHandler, stanagParserFactory, klvProcessor, DISTANCE_TOLERANCE); try (InputStream inputStream = new ByteArrayInputStream(new byte[] {})) { t.transform(inputStream); } }
@Test(expected = CatalogTransformerException.class) public void testInputStreamReadError() throws Exception { MpegTsInputTransformer t = new MpegTsInputTransformer( inputTransformer, metacardTypes, stanag4609Processor, klvHandlerFactory, defaultKlvHandler, stanagParserFactory, klvProcessor, DISTANCE_TOLERANCE); InputStream inputStream = mock(InputStream.class); when(inputStream.read(any())).thenThrow(new IOException()); t.transform(inputStream); }