use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class LegacyMongoIndexRangeServiceTest method testFindAll.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testFindAll() throws Exception {
final SortedSet<IndexRange> indexRanges = indexRangeService.findAll();
final DateTime end0 = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end1 = new DateTime(2015, 1, 2, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end2 = new DateTime(2015, 1, 3, 0, 0, 0, 0, DateTimeZone.UTC);
final DateTime end99 = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
assertThat(indexRanges).containsExactly(MongoIndexRange.create(new ObjectId("56250da2d400000000000001"), "graylog_0", EPOCH, end0, end0, 0), MongoIndexRange.create(new ObjectId("56250da2d400000000000099"), "graylog_99", EPOCH, end99, EPOCH, 0), MongoIndexRange.create(new ObjectId("56250da2d400000000000002"), "graylog_1", EPOCH, end1, end1, 1), MongoIndexRange.create(new ObjectId("56250da2d400000000000003"), "graylog_2", EPOCH, end2, end2, 2));
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method getReturnsAbsentOptionalIfIndexSetConfigDoesNotExist.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getReturnsAbsentOptionalIfIndexSetConfigDoesNotExist() throws Exception {
final Optional<IndexSetConfig> indexSetConfig = indexSetService.get(new ObjectId("57f3d3f0a43c2d595eb0a348"));
assertThat(indexSetConfig).isEmpty();
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method deleteRemovesExistingIndexSetConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void deleteRemovesExistingIndexSetConfig() throws Exception {
final IndexSetDeletedSubscriber subscriber = new IndexSetDeletedSubscriber();
clusterEventBus.registerClusterEventSubscriber(subscriber);
final int deletedEntries = indexSetService.delete(new ObjectId("57f3d721a43c2d59cb750001"));
assertThat(deletedEntries).isEqualTo(1);
assertThat(indexSetService.get("57f3d721a43c2d59cb750001")).isEmpty();
assertThat(subscriber.getEvents()).hasSize(1).containsExactly(IndexSetDeletedEvent.create("57f3d721a43c2d59cb750001"));
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class PersistedImplTest method testConstructorWithFieldsAndId.
@Test
public void testConstructorWithFieldsAndId() throws Exception {
Map<String, Object> fields = Maps.newHashMap();
ObjectId id = new ObjectId();
Persisted persisted = new PersistedImplSUT(id, fields);
assertNotNull(persisted);
assertNotNull(persisted.getId());
assertFalse(persisted.getId().isEmpty());
assertEquals(id.toString(), persisted.getId());
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class PersistedImplTest method testEqualityForSameRecord.
@Test
public void testEqualityForSameRecord() throws Exception {
Map<String, Object> fields = Maps.newHashMap();
fields.put("foo", "bar");
fields.put("bar", 42);
ObjectId id = new ObjectId();
Persisted persisted1 = new PersistedImplSUT(id, fields);
Persisted persisted2 = new PersistedImplSUT(id, fields);
assertEquals(persisted1, persisted2);
}
Aggregations