use of org.graylog2.contentpacks.model.entities.EntityDescriptor 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)));
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class PipelineRuleFacadeTest method resolveEntityDescriptor.
@Test
@MongoDBFixtures("PipelineRuleFacadeTest.json")
public void resolveEntityDescriptor() {
final EntityDescriptor descriptor = EntityDescriptor.create("debug", ModelTypes.PIPELINE_RULE_V1);
final Graph<EntityDescriptor> graph = facade.resolveNativeEntity(descriptor);
assertThat(graph.nodes()).containsOnly(descriptor);
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class PipelineRuleFacadeTest method exportEntity.
@Test
public void exportEntity() {
final RuleDao pipelineRule = RuleDao.builder().id("id").title("title").description("description").source("rule \"debug\"\nwhen\n true\nthen\n debug($message.message);\nend").build();
final EntityDescriptor descriptor = EntityDescriptor.create("id", ModelTypes.PIPELINE_RULE_V1);
final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
final Entity entity = facade.exportNativeEntity(pipelineRule, entityDescriptorIds);
assertThat(entity).isInstanceOf(EntityV1.class);
assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
assertThat(entity.type()).isEqualTo(ModelTypes.PIPELINE_RULE_V1);
final EntityV1 entityV1 = (EntityV1) entity;
final PipelineRuleEntity ruleEntity = objectMapper.convertValue(entityV1.data(), PipelineRuleEntity.class);
assertThat(ruleEntity.title()).isEqualTo(ValueReference.of("title"));
assertThat(ruleEntity.description()).isEqualTo(ValueReference.of("description"));
assertThat(ruleEntity.source().asString(Collections.emptyMap())).startsWith("rule \"debug\"\n");
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class SidecarCollectorFacadeTest method resolveEntityDescriptor.
@Test
@MongoDBFixtures("SidecarCollectorFacadeTest.json")
public void resolveEntityDescriptor() {
final EntityDescriptor descriptor = EntityDescriptor.create("5b4c920b4b900a0024af0001", ModelTypes.SIDECAR_COLLECTOR_V1);
final Graph<EntityDescriptor> graph = facade.resolveNativeEntity(descriptor);
assertThat(graph.nodes()).containsOnly(descriptor);
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class SidecarCollectorFacadeTest method exportEntity.
@Test
@MongoDBFixtures("SidecarCollectorFacadeTest.json")
public void exportEntity() {
final EntityDescriptor descriptor = EntityDescriptor.create("5b4c920b4b900a0024af0001", ModelTypes.SIDECAR_COLLECTOR_V1);
final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
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_V1);
final EntityV1 entityV1 = (EntityV1) entity;
final SidecarCollectorEntity collectorEntity = objectMapper.convertValue(entityV1.data(), SidecarCollectorEntity.class);
assertThat(collectorEntity.name()).isEqualTo(ValueReference.of("filebeat"));
assertThat(collectorEntity.serviceType()).isEqualTo(ValueReference.of("exec"));
assertThat(collectorEntity.nodeOperatingSystem()).isEqualTo(ValueReference.of("linux"));
assertThat(collectorEntity.executablePath()).isEqualTo(ValueReference.of("/usr/lib/graylog-sidecar/filebeat"));
assertThat(collectorEntity.executeParameters()).isEqualTo(ValueReference.of("-c %s"));
assertThat(collectorEntity.validationParameters()).isEqualTo(ValueReference.of("test config -c %s"));
assertThat(collectorEntity.defaultTemplate()).isEqualTo(ValueReference.of(""));
}
Aggregations