use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class FindChildrenStreamEndPluginTest method setup.
@Before
public void setup() throws UnsupportedQueryException, SourceUnavailableException, FederationException {
catalogFramework = mock(CatalogFramework.class);
parentMetacard = mock(Metacard.class);
metacard1 = mock(Metacard.class);
metacard2 = mock(Metacard.class);
Result result1 = mock(Result.class);
when(result1.getMetacard()).thenReturn(metacard1);
Result result2 = mock(Result.class);
when(result2.getMetacard()).thenReturn(metacard2);
queryResponse1 = mock(QueryResponse.class);
when(queryResponse1.getHits()).thenReturn(2L);
when(queryResponse1.getResults()).thenReturn(Collections.singletonList(result1));
queryResponse2 = mock(QueryResponse.class);
when(queryResponse2.getHits()).thenReturn(2L);
when(queryResponse2.getResults()).thenReturn(Collections.singletonList(result2));
when(catalogFramework.query(any())).thenReturn(queryResponse1, queryResponse2);
UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
when(udpStreamProcessor.getCatalogFramework()).thenReturn(catalogFramework);
context = new Context(udpStreamProcessor);
context.setParentMetacard(parentMetacard);
handler = mock(FindChildrenStreamEndPlugin.Handler.class);
FindChildrenStreamEndPlugin.Factory factory = mock(FindChildrenStreamEndPlugin.Factory.class);
when(factory.build()).thenReturn(handler);
findChildrenStreamEndPlugin = new FindChildrenStreamEndPlugin(new GeotoolsFilterBuilder(), factory);
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class FlushPacketBufferStreamShutdownPluginTest method testOnShutdown.
@Test
public void testOnShutdown() throws StreamShutdownException, IOException {
Context context = mock(Context.class);
UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
PacketBuffer packetBuffer = mock(PacketBuffer.class);
File file = mock(File.class);
when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
when(udpStreamProcessor.getPacketBuffer()).thenReturn(packetBuffer);
when(packetBuffer.flushAndRotate()).thenReturn(new RotateResult(file, false));
FlushPacketBufferStreamShutdownPlugin flushPacketBufferStreamShutdownPlugin = new FlushPacketBufferStreamShutdownPlugin();
flushPacketBufferStreamShutdownPlugin.onShutdown(context);
verify(udpStreamProcessor).doRollover(file);
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class FrameCenterUpdateFieldTest method testThatGeoOperatorIsCalled.
@Test
public void testThatGeoOperatorIsCalled() throws ParseException {
String wktChild1 = "LINESTRING (30 10, 10 30, 40 40)";
GeometryOperator geometryOperator = mock(GeometryOperator.class);
Geometry geometry = new WKTReader().read("LINESTRING (0 0, 1 1)");
Context context = mock(Context.class);
GeometryOperator.Context geometryOperatorContext = new GeometryOperator.Context();
geometryOperatorContext.setSubsampleCount(FrameCenterUpdateField.MAX_SIZE * 2);
when(context.getGeometryOperatorContext()).thenReturn(geometryOperatorContext);
when(geometryOperator.apply(any(), any())).thenReturn(geometry);
Metacard parentMetacard = mock(Metacard.class);
Metacard childMetacard1 = mock(Metacard.class);
when(childMetacard1.getAttribute(AttributeNameConstants.FRAME_CENTER)).thenReturn(new AttributeImpl(AttributeNameConstants.FRAME_CENTER, wktChild1));
FrameCenterUpdateField frameCenterUpdateField = new FrameCenterUpdateField(geometryOperator, new GeometryFactory());
frameCenterUpdateField.updateField(parentMetacard, Collections.singletonList(childMetacard1), context);
verify(geometryOperator, never()).apply(any(), any());
frameCenterUpdateField.end(parentMetacard, context);
verify(geometryOperator, times(1)).apply(any(), any());
assertThat(geometryOperatorContext.getSubsampleCount(), is(FrameCenterUpdateField.MAX_SIZE * 2));
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class FrameCenterUpdateFieldTest method testForChildrenWithoutFrameCenter.
@Test
public void testForChildrenWithoutFrameCenter() {
Metacard parentMetacard = mock(Metacard.class);
Metacard childMetacard1 = mock(Metacard.class);
Metacard childMetacard2 = mock(Metacard.class);
Metacard childMetacard3 = mock(Metacard.class);
FrameCenterUpdateField frameCenterUpdateField = new FrameCenterUpdateField(GeometryOperator.IDENTITY, new GeometryFactory());
Context context = mock(Context.class);
GeometryOperator.Context geometryOperatorContext = new GeometryOperator.Context();
geometryOperatorContext.setSubsampleCount(FrameCenterUpdateField.MAX_SIZE * 2);
when(context.getGeometryOperatorContext()).thenReturn(geometryOperatorContext);
frameCenterUpdateField.updateField(parentMetacard, Collections.singletonList(childMetacard1), context);
frameCenterUpdateField.updateField(parentMetacard, Arrays.asList(childMetacard2, childMetacard3), context);
frameCenterUpdateField.end(parentMetacard, context);
ArgumentCaptor<Attribute> captor = ArgumentCaptor.forClass(Attribute.class);
verify(parentMetacard).setAttribute(captor.capture());
assertThat(captor.getValue().getValue(), is("LINESTRING EMPTY"));
assertThat(geometryOperatorContext.getSubsampleCount(), is(FrameCenterUpdateField.MAX_SIZE * 2));
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class FrameCenterUpdateFieldTest method testThatSubsampleCountIsResetOnException.
@Test(expected = RuntimeException.class)
public void testThatSubsampleCountIsResetOnException() throws ParseException {
String wktChild1 = "LINESTRING (30 10, 10 30, 40 40)";
GeometryOperator geometryOperator = mock(GeometryOperator.class);
Geometry geometry = new WKTReader().read("LINESTRING (0 0, 1 1)");
Context context = mock(Context.class);
GeometryOperator.Context geometryOperatorContext = new GeometryOperator.Context();
geometryOperatorContext.setSubsampleCount(FrameCenterUpdateField.MAX_SIZE * 2);
when(context.getGeometryOperatorContext()).thenReturn(geometryOperatorContext);
when(geometryOperator.apply(any(), any())).thenThrow(RuntimeException.class);
Metacard parentMetacard = mock(Metacard.class);
Metacard childMetacard1 = mock(Metacard.class);
when(childMetacard1.getAttribute(AttributeNameConstants.FRAME_CENTER)).thenReturn(new AttributeImpl(AttributeNameConstants.FRAME_CENTER, wktChild1));
FrameCenterUpdateField frameCenterUpdateField = new FrameCenterUpdateField(geometryOperator, new GeometryFactory());
frameCenterUpdateField.updateField(parentMetacard, Collections.singletonList(childMetacard1), context);
verify(geometryOperator, never()).apply(any(), any());
try {
frameCenterUpdateField.end(parentMetacard, context);
verify(geometryOperator, times(1)).apply(any(), any());
} finally {
assertThat(geometryOperatorContext.getSubsampleCount(), is(FrameCenterUpdateField.MAX_SIZE * 2));
}
}
Aggregations