Search in sources :

Example 21 with Context

use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.

the class FrameCenterUpdateFieldTest method testVariousInvalidAndValidFrameCenterValues.

@Test
public void testVariousInvalidAndValidFrameCenterValues() throws ParseException {
    String wktChild1 = "LINESTRING (30 10, 10 30, 40 40)";
    Context context = mock(Context.class);
    GeometryOperator.Context geometryOperatorContext = new GeometryOperator.Context();
    geometryOperatorContext.setSubsampleCount(FrameCenterUpdateField.MAX_SIZE * 2);
    when(context.getGeometryOperatorContext()).thenReturn(geometryOperatorContext);
    Metacard parentMetacard = mock(Metacard.class);
    // this metacard has a valid frame center
    Metacard childMetacard1 = mock(Metacard.class);
    when(childMetacard1.getAttribute(AttributeNameConstants.FRAME_CENTER)).thenReturn(new AttributeImpl(AttributeNameConstants.FRAME_CENTER, wktChild1));
    // this metacard is missing the frame center attribute
    Metacard childMetacard2 = mock(Metacard.class);
    // this metacard has an empty frame center attribute
    Metacard childMetacard3 = mock(Metacard.class);
    when(childMetacard3.getAttribute(AttributeNameConstants.FRAME_CENTER)).thenReturn(new AttributeImpl(AttributeNameConstants.FRAME_CENTER, ""));
    // this metacard has a non-String frame center attribute
    Metacard childMetacard4 = mock(Metacard.class);
    when(childMetacard4.getAttribute(AttributeNameConstants.FRAME_CENTER)).thenReturn(new AttributeImpl(AttributeNameConstants.FRAME_CENTER, 1L));
    FrameCenterUpdateField frameCenterUpdateField = new FrameCenterUpdateField(GeometryOperator.IDENTITY, new GeometryFactory());
    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 (30 10, 10 30, 40 40)"));
    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) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) Test(org.junit.Test)

Example 22 with Context

use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.

the class ListStreamCreationPluginTest method testOnCreate.

@Test
public void testOnCreate() throws StreamCreationException {
    Context context = mock(Context.class);
    StreamCreationPlugin streamCreationPlugin = mock(StreamCreationPlugin.class);
    ListStreamCreationPlugin listStreamCreationPlugin = new ListStreamCreationPlugin(Collections.singletonList(streamCreationPlugin));
    listStreamCreationPlugin.onCreate(context);
    verify(streamCreationPlugin).onCreate(context);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Test(org.junit.Test)

Example 23 with Context

use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.

the class LocationUpdateFieldTest method testPolygon.

@Test
public void testPolygon() {
    String wktChild1 = "POLYGON ((0  0, 10 0, 10 10, 0  10, 0  0))";
    String wktChild2 = "POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))";
    String wktChild3 = "POLYGON ((20 0, 30 0, 30 10, 20 10, 20 0))";
    String wktExpected = "POLYGON ((20 0, 10 0, 0 0, 0 10, 10 10, 20 10, 30 10, 30 0, 20 0))";
    Metacard parentMetacard = mock(Metacard.class);
    Metacard childMetacard1 = mock(Metacard.class);
    when(childMetacard1.getLocation()).thenReturn(wktChild1);
    Metacard childMetacard2 = mock(Metacard.class);
    when(childMetacard2.getLocation()).thenReturn(wktChild2);
    Metacard childMetacard3 = mock(Metacard.class);
    when(childMetacard3.getLocation()).thenReturn(wktChild3);
    LocationUpdateField locUpdateField = new LocationUpdateField(GeometryOperator.IDENTITY, GeometryOperator.IDENTITY);
    Context context = mock(Context.class);
    locUpdateField.updateField(parentMetacard, Collections.singletonList(childMetacard1), context);
    locUpdateField.updateField(parentMetacard, Arrays.asList(childMetacard2, childMetacard3), context);
    locUpdateField.end(parentMetacard, context);
    ArgumentCaptor<Attribute> captor = ArgumentCaptor.forClass(Attribute.class);
    verify(parentMetacard).setAttribute(captor.capture());
    assertThat(captor.getValue().getValue(), is(wktExpected));
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) Attribute(ddf.catalog.data.Attribute) Test(org.junit.Test)

Example 24 with Context

use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.

the class ParentMetacardStreamCreationPluginTest method setup.

@Before
public void setup() throws SourceUnavailableException, IngestException {
    context = mock(Context.class);
    uri = URI.create("udp://127.0.0.1:10000");
    title = "theTitleString";
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(udpStreamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
    when(udpStreamProcessor.getTitle()).thenReturn(Optional.of(title));
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    Security security = mock(Security.class);
    Subject subject = mock(Subject.class);
    when(security.getSystemSubject()).thenReturn(subject);
    catalogFramework = mock(CatalogFramework.class);
    parentMetacardStreamCreationPlugin = new ParentMetacardStreamCreationPlugin(catalogFramework, Collections.singletonList(mock(MetacardType.class)));
    CreateResponse createResponse = mock(CreateResponse.class);
    Metacard createdParentMetacard = mock(Metacard.class);
    context.setParentMetacard(createdParentMetacard);
    when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdParentMetacard));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) CatalogFramework(ddf.catalog.CatalogFramework) Security(org.codice.ddf.security.common.Security) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Subject(ddf.security.Subject) MetacardType(ddf.catalog.data.MetacardType) Before(org.junit.Before)

Example 25 with Context

use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.

the class ResetPacketBufferStreamShutdownPluginTest method testOnShutdown.

@Test
public void testOnShutdown() throws StreamShutdownException {
    PacketBuffer packetBuffer = mock(PacketBuffer.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    Context context = mock(Context.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(udpStreamProcessor.getPacketBuffer()).thenReturn(packetBuffer);
    ResetPacketBufferStreamShutdownPlugin resetPacketBufferStreamShutdownPlugin = new ResetPacketBufferStreamShutdownPlugin();
    resetPacketBufferStreamShutdownPlugin.onShutdown(context);
    verify(packetBuffer).reset();
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) PacketBuffer(org.codice.alliance.video.stream.mpegts.netty.PacketBuffer) 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