use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class LookupTableFacadeTest method findExistingWithNoExistingEntity.
@Test
@MongoDBFixtures("LookupTableFacadeTest.json")
public void findExistingWithNoExistingEntity() {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.LOOKUP_TABLE_V1).data(objectMapper.convertValue(LookupTableEntity.create(ValueReference.of("some-name"), ValueReference.of("Title"), ValueReference.of("Description"), ValueReference.of("cache-id"), ValueReference.of("data-adapter-id"), ValueReference.of("Default single value"), ValueReference.of(LookupDefaultValue.Type.STRING), ValueReference.of("Default multi value"), ValueReference.of(LookupDefaultValue.Type.OBJECT)), JsonNode.class)).build();
final Optional<NativeEntity<LookupTableDto>> existingEntity = facade.findExisting(entity, Collections.emptyMap());
assertThat(existingEntity).isEmpty();
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class LookupTableFacadeTest method findExisting.
@Test
@MongoDBFixtures("LookupTableFacadeTest.json")
public void findExisting() {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.LOOKUP_TABLE_V1).data(objectMapper.convertValue(LookupTableEntity.create(ValueReference.of("http-dsv-no-cache"), ValueReference.of("HTTP DSV without Cache"), ValueReference.of("HTTP DSV without Cache"), ValueReference.of("cache-id"), ValueReference.of("data-adapter-id"), ValueReference.of("Default single value"), ValueReference.of(LookupDefaultValue.Type.STRING), ValueReference.of("Default multi value"), ValueReference.of(LookupDefaultValue.Type.OBJECT)), JsonNode.class)).build();
final NativeEntity<LookupTableDto> existingEntity = facade.findExisting(entity, Collections.emptyMap()).orElseThrow(AssertionError::new);
assertThat(existingEntity.descriptor().id()).isEqualTo(ModelId.of("5adf24dd4b900a0fdb4e530d"));
assertThat(existingEntity.descriptor().type()).isEqualTo(ModelTypes.LOOKUP_TABLE_V1);
assertThat(existingEntity.entity().name()).isEqualTo("http-dsv-no-cache");
assertThat(existingEntity.entity().title()).isEqualTo("HTTP DSV without Cache");
assertThat(existingEntity.entity().description()).isEqualTo("HTTP DSV without Cache");
assertThat(existingEntity.entity().dataAdapterId()).isEqualTo("5adf24a04b900a0fdb4e52c8");
assertThat(existingEntity.entity().cacheId()).isEqualTo("5adf24b24b900a0fdb4e52dd");
assertThat(existingEntity.entity().defaultSingleValue()).isEqualTo("Default single value");
assertThat(existingEntity.entity().defaultSingleValueType()).isEqualTo(LookupDefaultValue.Type.STRING);
assertThat(existingEntity.entity().defaultMultiValue()).isEqualTo("Default multi value");
assertThat(existingEntity.entity().defaultMultiValueType()).isEqualTo(LookupDefaultValue.Type.OBJECT);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacadeTest method exportEntity.
@Test
@MongoDBFixtures("SidecarCollectorConfigurationFacadeTest.json")
public void exportEntity() {
final EntityDescriptor descriptor = EntityDescriptor.create("5b17e1a53f3ab8204eea1051", ModelTypes.SIDECAR_COLLECTOR_CONFIGURATION_V1);
final EntityDescriptor collectorDescriptor = EntityDescriptor.create("5b4c920b4b900a0024af0001", ModelTypes.SIDECAR_COLLECTOR_V1);
final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor, collectorDescriptor);
final Entity entity = facade.exportEntity(descriptor, entityDescriptorIds).orElseThrow(AssertionError::new);
assertThat(entity).isInstanceOf(EntityV1.class);
assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
assertThat(entity.type()).isEqualTo(ModelTypes.SIDECAR_COLLECTOR_CONFIGURATION_V1);
final EntityV1 entityV1 = (EntityV1) entity;
final SidecarCollectorConfigurationEntity configEntity = objectMapper.convertValue(entityV1.data(), SidecarCollectorConfigurationEntity.class);
assertThat(configEntity.title()).isEqualTo(ValueReference.of("filebeat config"));
assertThat(configEntity.collectorId()).isEqualTo(ValueReference.of(entityDescriptorIds.get(collectorDescriptor).orElse(null)));
assertThat(configEntity.color().asString(Collections.emptyMap())).isEqualTo("#ffffff");
assertThat(configEntity.template().asString(Collections.emptyMap())).isEqualTo("empty template");
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class StreamCatalogTest method listEntityExcerpts.
@Test
@MongoDBFixtures("StreamCatalogTest.json")
public void listEntityExcerpts() {
final EntityExcerpt expectedEntityExcerpt1 = EntityExcerpt.builder().id(ModelId.of("000000000000000000000001")).type(ModelTypes.STREAM_V1).title("All messages").build();
final EntityExcerpt expectedEntityExcerpt2 = EntityExcerpt.builder().id(ModelId.of("5adf23894b900a0fdb4e517d")).type(ModelTypes.STREAM_V1).title("Test").build();
final Set<EntityExcerpt> entityExcerpts = facade.listEntityExcerpts();
assertThat(entityExcerpts).containsOnly(expectedEntityExcerpt1, expectedEntityExcerpt2);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class StreamCatalogTest method collectEntity.
@Test
@MongoDBFixtures("StreamCatalogTest.json")
public void collectEntity() {
final EntityDescriptor descriptor = EntityDescriptor.create("5adf23894b900a0fdb4e517d", ModelTypes.STREAM_V1);
final EntityDescriptor outputDescriptor = EntityDescriptor.create("5adf239e4b900a0fdb4e5197", ModelTypes.OUTPUT_V1);
final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor, outputDescriptor);
final Optional<Entity> collectedEntity = facade.exportEntity(descriptor, entityDescriptorIds);
assertThat(collectedEntity).isPresent().containsInstanceOf(EntityV1.class);
final EntityV1 entity = (EntityV1) collectedEntity.orElseThrow(AssertionError::new);
assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
assertThat(entity.type()).isEqualTo(ModelTypes.STREAM_V1);
final StreamEntity streamEntity = objectMapper.convertValue(entity.data(), StreamEntity.class);
assertThat(streamEntity.title()).isEqualTo(ValueReference.of("Test"));
assertThat(streamEntity.description()).isEqualTo(ValueReference.of("Description"));
assertThat(streamEntity.matchingType()).isEqualTo(ValueReference.of(Stream.MatchingType.AND));
assertThat(streamEntity.streamRules()).hasSize(7);
assertThat(streamEntity.outputs()).containsExactly(ValueReference.of(entityDescriptorIds.get(outputDescriptor).orElse(null)));
}
Aggregations