use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method indexSetsCacheShouldBeInvalidatedForIndexSetDeletion.
@Test
public void indexSetsCacheShouldBeInvalidatedForIndexSetDeletion() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
final List<IndexSetConfig> result = this.indexSetsCache.get();
assertThat(result).isNotNull().hasSize(1).containsExactly(indexSetConfig);
this.indexSetsCache.handleIndexSetDeletion(mock(IndexSetDeletedEvent.class));
final IndexSetConfig newIndexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> newIndexSetConfigs = Collections.singletonList(newIndexSetConfig);
when(indexSetService.findAll()).thenReturn(newIndexSetConfigs);
final List<IndexSetConfig> newResult = this.indexSetsCache.get();
assertThat(newResult).isNotNull().hasSize(1).containsExactly(newIndexSetConfig);
verify(indexSetService, times(2)).findAll();
}
use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method getAllShouldNotBeCachedForCallAfterInvalidate.
@Test
public void getAllShouldNotBeCachedForCallAfterInvalidate() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
final MongoIndexSet indexSet = mock(MongoIndexSet.class);
when(mongoIndexSetFactory.create(indexSetConfig)).thenReturn(indexSet);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
assertThat(this.indexSetRegistry.getAll()).isNotNull().isNotEmpty().hasSize(1).containsExactly(indexSet);
this.indexSetsCache.invalidate();
assertThat(this.indexSetRegistry.getAll()).isNotNull().isNotEmpty().hasSize(1).containsExactly(indexSet);
verify(indexSetService, times(2)).findAll();
}
use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method indexSetsCacheShouldReturnNewListAfterInvalidate.
@Test
public void indexSetsCacheShouldReturnNewListAfterInvalidate() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
final List<IndexSetConfig> result = this.indexSetsCache.get();
assertThat(result).isNotNull().hasSize(1).containsExactly(indexSetConfig);
this.indexSetsCache.invalidate();
final IndexSetConfig newIndexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> newIndexSetConfigs = Collections.singletonList(newIndexSetConfig);
when(indexSetService.findAll()).thenReturn(newIndexSetConfigs);
final List<IndexSetConfig> newResult = this.indexSetsCache.get();
assertThat(newResult).isNotNull().hasSize(1).containsExactly(newIndexSetConfig);
verify(indexSetService, times(2)).findAll();
}
use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.
the class MongoIndexSetRegistryTest method indexSetsCacheShouldBeInvalidatedForIndexSetCreation.
@Test
public void indexSetsCacheShouldBeInvalidatedForIndexSetCreation() {
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> indexSetConfigs = Collections.singletonList(indexSetConfig);
when(indexSetService.findAll()).thenReturn(indexSetConfigs);
final List<IndexSetConfig> result = this.indexSetsCache.get();
assertThat(result).isNotNull().hasSize(1).containsExactly(indexSetConfig);
this.indexSetsCache.handleIndexSetCreation(mock(IndexSetCreatedEvent.class));
final IndexSetConfig newIndexSetConfig = mock(IndexSetConfig.class);
final List<IndexSetConfig> newIndexSetConfigs = Collections.singletonList(newIndexSetConfig);
when(indexSetService.findAll()).thenReturn(newIndexSetConfigs);
final List<IndexSetConfig> newResult = this.indexSetsCache.get();
assertThat(newResult).isNotNull().hasSize(1).containsExactly(newIndexSetConfig);
verify(indexSetService, times(2)).findAll();
}
use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method save.
@Test
public void save() {
final IndexSetConfig indexSetConfig = IndexSetConfig.create("title", "description", true, "prefix", 1, 0, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(1), ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC), "standard", "prefix-template", 1, false);
final IndexSetConfig savedIndexSetConfig = indexSetConfig.toBuilder().id("id").build();
when(indexSetService.save(indexSetConfig)).thenReturn(savedIndexSetConfig);
final IndexSetSummary summary = indexSetsResource.save(IndexSetSummary.fromIndexSetConfig(indexSetConfig, false));
verify(indexSetService, times(1)).save(indexSetConfig);
verify(indexSetService, times(1)).getDefault();
verifyNoMoreInteractions(indexSetService);
assertThat(summary.toIndexSetConfig()).isEqualTo(savedIndexSetConfig);
}
Aggregations