use of org.graylog2.buffers.processors.fakestreams.FakeStream in project graylog2-server by Graylog2.
the class SearchesIT method testCountWithFilter.
@Test
public void testCountWithFilter() throws Exception {
importFixture("org/graylog2/indexer/searches/SearchesIT.json");
final IndexSetConfig indexSetConfig = IndexSetConfig.builder().id("id").title("title").indexPrefix("prefix").shards(1).replicas(0).rotationStrategy(MessageCountRotationStrategyConfig.createDefault()).retentionStrategyClass(DeletionRetentionStrategy.class.getCanonicalName()).retentionStrategy(DeletionRetentionStrategyConfig.createDefault()).creationDate(ZonedDateTime.of(2017, 5, 24, 0, 0, 0, 0, ZoneOffset.UTC)).indexAnalyzer("standard").indexTemplateName("template").indexOptimizationMaxNumSegments(1).indexOptimizationDisabled(false).build();
final IndexSet indexSet = new TestIndexSet(indexSetConfig);
final Stream stream = new FakeStream("test") {
@Override
public IndexSet getIndexSet() {
return indexSet;
}
};
when(streamService.load(STREAM_ID)).thenReturn(stream);
CountResult result = searches.count("*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)), "streams:" + STREAM_ID);
assertThat(result.count()).isEqualTo(5L);
}
use of org.graylog2.buffers.processors.fakestreams.FakeStream in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method deleteWithAssignedStreams.
@Test
@MongoDBFixtures("MongoIndexSetServiceTest.json")
public void deleteWithAssignedStreams() throws Exception {
final IndexSetDeletedSubscriber subscriber = new IndexSetDeletedSubscriber();
clusterEventBus.registerClusterEventSubscriber(subscriber);
final FakeStream stream1 = new FakeStream("Test stream 1");
final String streamId = "57f3d721a43c2d59cb750001";
stream1.setIndexSetId(streamId);
when(streamService.loadAllWithIndexSet(streamId)).thenReturn(Collections.singletonList(stream1));
final int deletedEntries = indexSetService.delete(streamId);
assertThat(deletedEntries).isEqualTo(0);
assertThat(indexSetService.get(streamId)).isPresent();
assertThat(indexSetService.findAll()).hasSize(3);
assertThat(subscriber.getEvents()).isEmpty();
}
use of org.graylog2.buffers.processors.fakestreams.FakeStream in project graylog2-server by Graylog2.
the class PipelineFacadeTest method createNativeEntityWithDefaultStream.
@Test
public void createNativeEntityWithDefaultStream() throws NotFoundException {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.PIPELINE_V1).data(objectMapper.convertValue(PipelineEntity.create(ValueReference.of("Title"), ValueReference.of("Description"), ValueReference.of("pipeline \"Title\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"), Collections.singleton(ValueReference.of(Stream.DEFAULT_STREAM_ID))), JsonNode.class)).build();
final FakeStream fakeDefaultStream = new FakeStream("All message Fake") {
@Override
protected ObjectId getObjectId() {
return new ObjectId(Stream.DEFAULT_STREAM_ID);
}
};
when(streamService.load(Stream.DEFAULT_STREAM_ID)).thenReturn(fakeDefaultStream);
final Map<EntityDescriptor, Object> nativeEntities = Collections.emptyMap();
final NativeEntity<PipelineDao> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), nativeEntities, "username");
assertThat(connectionsService.load(fakeDefaultStream.getId()).pipelineIds()).containsOnly(nativeEntity.entity().id());
}
Aggregations