Search in sources :

Example 81 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceServiceTest method findByIdWithInvalidId.

@Test
@MongoDBFixtures("ContentPackInstallationPersistenceServiceTest.json")
public void findByIdWithInvalidId() {
    final Optional<ContentPackInstallation> contentPacks = persistenceService.findById(new ObjectId("0000000000000000deadbeef"));
    assertThat(contentPacks).isEmpty();
}
Also used : ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ObjectId(org.bson.types.ObjectId) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 82 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceServiceTest method findByContentPackId.

@Test
@MongoDBFixtures("ContentPackInstallationPersistenceServiceTest.json")
public void findByContentPackId() {
    final ModelId id = ModelId.of("4e3d7025-881e-6870-da03-cafebabe0001");
    final Set<ContentPackInstallation> contentPacks = persistenceService.findByContentPackId(id);
    assertThat(contentPacks).hasSize(2).allSatisfy(contentPackInstallation -> assertThat(contentPackInstallation.contentPackId()).isEqualTo(id)).anySatisfy(contentPackInstallation -> assertThat(contentPackInstallation.id()).isEqualTo(new ObjectId("5b4c935b4b900a0000000001"))).anySatisfy(contentPackInstallation -> assertThat(contentPackInstallation.id()).isEqualTo(new ObjectId("5b4c935b4b900a0000000002")));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ModelId(org.graylog2.contentpacks.model.ModelId) ImmutableMap(com.google.common.collect.ImmutableMap) ZonedDateTime(java.time.ZonedDateTime) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Set(java.util.Set) Test(org.junit.Test) Rule(org.junit.Rule) MongoDBInstance(org.graylog.testing.mongodb.MongoDBInstance) ObjectId(org.bson.types.ObjectId) Optional(java.util.Optional) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) ZoneOffset(java.time.ZoneOffset) Before(org.junit.Before) ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ObjectId(org.bson.types.ObjectId) ModelId(org.graylog2.contentpacks.model.ModelId) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 83 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceServiceTest method deleteByIdWithInvalidId.

@Test
@MongoDBFixtures("ContentPackInstallationPersistenceServiceTest.json")
public void deleteByIdWithInvalidId() {
    final int deletedContentPacks = persistenceService.deleteById(new ObjectId("0000000000000000deadbeef"));
    final Set<ContentPackInstallation> contentPacks = persistenceService.loadAll();
    assertThat(deletedContentPacks).isEqualTo(0);
    assertThat(contentPacks).hasSize(4);
}
Also used : ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ObjectId(org.bson.types.ObjectId) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 84 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceServiceTest method findById.

@Test
@MongoDBFixtures("ContentPackInstallationPersistenceServiceTest.json")
public void findById() {
    final ObjectId objectId = new ObjectId("5b4c935b4b900a0000000001");
    final Optional<ContentPackInstallation> contentPacks = persistenceService.findById(objectId);
    assertThat(contentPacks).isPresent().get().satisfies(contentPackInstallation -> assertThat(contentPackInstallation.id()).isEqualTo(objectId));
}
Also used : ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ObjectId(org.bson.types.ObjectId) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 85 with MongoDBFixtures

use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceServiceTest method findByContentPackIdAndRevision.

@Test
@MongoDBFixtures("ContentPackInstallationPersistenceServiceTest.json")
public void findByContentPackIdAndRevision() {
    final ModelId id = ModelId.of("4e3d7025-881e-6870-da03-cafebabe0001");
    final Set<ContentPackInstallation> contentPack = persistenceService.findByContentPackIdAndRevision(id, 1);
    assertThat(contentPack).hasSize(1).anySatisfy(c -> assertThat(c.contentPackId()).isEqualTo(id));
}
Also used : ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) ModelId(org.graylog2.contentpacks.model.ModelId) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Aggregations

MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)167 Test (org.junit.Test)167 Entity (org.graylog2.contentpacks.model.entities.Entity)47 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)47 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)42 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)24 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)23 DateTime (org.joda.time.DateTime)17 ObjectId (org.bson.types.ObjectId)15 EntityExcerpt (org.graylog2.contentpacks.model.entities.EntityExcerpt)15 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)15 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)11 AbstractMap (java.util.AbstractMap)10 MigrationCompleted (org.graylog.plugins.views.migrations.V20191203120602_MigrateSavedSearchesToViewsSupport.V20191203120602_MigrateSavedSearchesToViews.MigrationCompleted)10 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)10 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)10 MongoDBServiceTest (org.graylog2.database.MongoDBServiceTest)10 GRN (org.graylog.grn.GRN)9 PipelineEntity (org.graylog2.contentpacks.model.entities.PipelineEntity)9 Document (org.bson.Document)8