use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class UpdateParentTest method testCallUpdateAfterEnd.
@Test(expected = IllegalStateException.class)
public void testCallUpdateAfterEnd() {
UpdateParent.UpdateField updateField = new UpdateParent.BaseUpdateField() {
@Override
protected void doEnd(Metacard parent, Context context) {
}
@Override
protected void doUpdateField(Metacard parent, List<Metacard> children, Context context) {
}
};
Context context = mock(Context.class);
Metacard parent = mock(Metacard.class);
Metacard child = mock(Metacard.class);
updateField.end(parent, context);
updateField.updateField(parent, Collections.singletonList(child), context);
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class CatalogRolloverActionTest method setup.
@Before
public void setup() throws SourceUnavailableException, IngestException {
FilenameGenerator filenameGenerator = mock(FilenameGenerator.class);
String filenameTemplate = "filenameTemplate";
StreamProcessor streamProcessor = mock(StreamProcessor.class);
when(streamProcessor.getMetacardUpdateInitialDelay()).thenReturn(1L);
catalogFramework = mock(CatalogFramework.class);
MetacardType metacardType = mock(MetacardType.class);
tempFile = new File("someTempFile");
URI uri = URI.create("udp://127.0.0.1:10000");
String title = "theTitleString";
childWkt = "POLYGON (( 0.5 0.5, 1.5 0.5, 1.5 1.5, 0.5 1.5, 0.5 0.5 ))";
when(metacardType.getAttributeDescriptor(AttributeNameConstants.TEMPORAL_START)).thenReturn(mock(AttributeDescriptor.class));
when(metacardType.getAttributeDescriptor(AttributeNameConstants.TEMPORAL_END)).thenReturn(mock(AttributeDescriptor.class));
UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
when(udpStreamProcessor.getSubject()).thenReturn(new SimpleSubject());
Context context = new Context(udpStreamProcessor);
when(udpStreamProcessor.getMetacardTypeList()).thenReturn(Collections.singletonList(metacardType));
when(udpStreamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
when(udpStreamProcessor.getTitle()).thenReturn(Optional.of(title));
Security security = mock(Security.class);
Subject subject = mock(Subject.class);
when(security.getSystemSubject()).thenReturn(subject);
GeometryOperator postUnionGeometryOperator = new GeometryOperatorList(Arrays.asList(new SimplifyGeometryFunction(), new NormalizeGeometry()));
UuidGenerator uuidGenerator = mock(UuidGenerator.class);
when(uuidGenerator.generateUuid()).thenReturn("anId");
catalogRolloverAction = new CatalogRolloverAction(filenameGenerator, filenameTemplate, catalogFramework, context, new ListMetacardUpdater(Arrays.asList(new LocationMetacardUpdater(postUnionGeometryOperator, GeometryOperator.IDENTITY), new TemporalStartMetacardUpdater(), new TemporalEndMetacardUpdater(), new ModifiedDateMetacardUpdater(), new FrameCenterMetacardUpdater(postUnionGeometryOperator))), uuidGenerator);
createdParentMetacard = mock(Metacard.class);
when(createdParentMetacard.getMetacardType()).thenReturn(metacardType);
context.setParentMetacard(createdParentMetacard);
context.getGeometryOperatorContext().setDistanceTolerance(0.0025);
createdChildMetacard = mock(Metacard.class);
when(createdChildMetacard.getMetacardType()).thenReturn(metacardType);
Metacard updatedParentMetacard = mock(Metacard.class);
when(updatedParentMetacard.getMetacardType()).thenReturn(metacardType);
Metacard updatedChildMetacard = mock(Metacard.class);
when(updatedChildMetacard.getMetacardType()).thenReturn(metacardType);
CreateResponse createResponse = mock(CreateResponse.class);
CreateResponse storageCreateResponse = mock(CreateResponse.class);
Update childUpdate = mock(Update.class);
childUpdateResponse = mock(UpdateResponse.class);
Update parentUpdate = mock(Update.class);
parentUpdateResponse = mock(UpdateResponse.class);
when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdParentMetacard));
when(storageCreateResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdChildMetacard));
when(childUpdate.getNewMetacard()).thenReturn(updatedChildMetacard);
when(childUpdateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(childUpdate));
when(parentUpdate.getNewMetacard()).thenReturn(updatedParentMetacard);
when(parentUpdateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(parentUpdate));
when(filenameGenerator.generateFilename(any())).thenReturn("someFileName");
when(streamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
when(streamProcessor.getTitle()).thenReturn(Optional.of(title));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
when(catalogFramework.create(any(CreateStorageRequest.class))).thenReturn(storageCreateResponse);
when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(childUpdateResponse).thenReturn(parentUpdateResponse);
when(createdChildMetacard.getLocation()).thenReturn(childWkt);
when(createdChildMetacard.getAttribute(AttributeNameConstants.TEMPORAL_START)).thenReturn(new AttributeImpl(AttributeNameConstants.TEMPORAL_START, TEMPORAL_START_DATE));
when(createdChildMetacard.getAttribute(AttributeNameConstants.TEMPORAL_END)).thenReturn(new AttributeImpl(AttributeNameConstants.TEMPORAL_END, TEMPORAL_END_DATE));
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class LineStringMetacardUpdaterTest method testParentMergedWithChild.
@Test
public void testParentMergedWithChild() throws ParseException {
when(parentAttr.getValue()).thenReturn("LINESTRING(0 0, 1 1)");
when(childAttr.getValue()).thenReturn("LINESTRING(2 2, 3 3)");
when(parentMetacard.getAttribute(attrName)).thenReturn(parentAttr);
when(childMetacard.getAttribute(attrName)).thenReturn(childAttr);
Context context = mock(Context.class);
lineStringMetacardUpdater.update(parentMetacard, childMetacard, context);
ArgumentCaptor<Attribute> argumentCaptor = ArgumentCaptor.forClass(Attribute.class);
verify(parentMetacard).setAttribute(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getValue(), is(normalize("LINESTRING(0 0, 1 1, 2 2, 3 3)")));
}
use of org.codice.alliance.video.stream.mpegts.Context in project alliance by codice.
the class ListMetacardUpdaterTest method testUpdate.
@Test
public void testUpdate() {
MetacardUpdater updater1 = mock(MetacardUpdater.class);
MetacardUpdater updater2 = mock(MetacardUpdater.class);
ListMetacardUpdater listMetacardUpdater = new ListMetacardUpdater(Arrays.asList(updater1, updater2));
Metacard parent = mock(Metacard.class);
Metacard child = mock(Metacard.class);
Context context = mock(Context.class);
listMetacardUpdater.update(parent, child, context);
verify(updater1).update(parent, child, context);
verify(updater2).update(parent, child, context);
}
Aggregations