Search in sources :

Example 1 with Context

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);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) QueryResponse(ddf.catalog.operation.QueryResponse) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) CatalogFramework(ddf.catalog.CatalogFramework) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Result(ddf.catalog.data.Result) Before(org.junit.Before)

Example 2 with Context

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);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) File(java.io.File) PacketBuffer(org.codice.alliance.video.stream.mpegts.netty.PacketBuffer) RotateResult(org.codice.alliance.video.stream.mpegts.netty.RotateResult) Test(org.junit.Test)

Example 3 with Context

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));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeometryOperator(org.codice.alliance.libs.klv.GeometryOperator) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Example 4 with Context

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));
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeometryOperator(org.codice.alliance.libs.klv.GeometryOperator) Attribute(ddf.catalog.data.Attribute) Test(org.junit.Test)

Example 5 with Context

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));
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeometryOperator(org.codice.alliance.libs.klv.GeometryOperator) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Aggregations

Context (org.codice.alliance.video.stream.mpegts.Context)29 Test (org.junit.Test)24 Metacard (ddf.catalog.data.Metacard)19 UdpStreamProcessor (org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor)10 GeometryOperator (org.codice.alliance.libs.klv.GeometryOperator)8 Attribute (ddf.catalog.data.Attribute)7 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)6 CatalogFramework (ddf.catalog.CatalogFramework)5 Geometry (com.vividsolutions.jts.geom.Geometry)4 WKTReader (com.vividsolutions.jts.io.WKTReader)4 List (java.util.List)3 Timer (java.util.Timer)3 Before (org.junit.Before)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)2 MetacardType (ddf.catalog.data.MetacardType)2 CreateRequest (ddf.catalog.operation.CreateRequest)2 CreateResponse (ddf.catalog.operation.CreateResponse)2 Update (ddf.catalog.operation.Update)2 UpdateResponse (ddf.catalog.operation.UpdateResponse)2