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));
}
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);
}
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));
}
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);
}
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();
}
Aggregations