Search in sources :

Example 1 with CatalogResolveResponse

use of org.graylog2.rest.models.system.contentpacks.responses.CatalogResolveResponse in project graylog2-server by Graylog2.

the class CatalogResourceTest method resolveEntities.

@Test
public void resolveEntities() {
    final EntityDescriptor entityDescriptor = EntityDescriptor.builder().id(ModelId.of("1234567890")).type(ModelType.of("test", "1")).build();
    final MutableGraph<EntityDescriptor> entityDescriptors = GraphBuilder.directed().build();
    entityDescriptors.addNode(entityDescriptor);
    final EntityV1 entity = EntityV1.builder().id(ModelId.of("1234567890")).type(ModelType.of("test", "1")).data(new ObjectNode(JsonNodeFactory.instance).put("test", "1234")).build();
    when(mockEntityFacade.resolveNativeEntity(entityDescriptor)).thenReturn(entityDescriptors);
    when(mockEntityFacade.exportEntity(eq(entityDescriptor), any(EntityDescriptorIds.class))).thenReturn(Optional.of(entity));
    final CatalogResolveRequest request = CatalogResolveRequest.create(entityDescriptors.nodes());
    final CatalogResolveResponse catalogResolveResponse = catalogResource.resolveEntities(request);
    assertThat(catalogResolveResponse.entities()).containsOnly(entity);
}
Also used : EntityV1(org.graylog2.contentpacks.model.entities.EntityV1) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) CatalogResolveRequest(org.graylog2.rest.models.system.contentpacks.responses.CatalogResolveRequest) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) CatalogResolveResponse(org.graylog2.rest.models.system.contentpacks.responses.CatalogResolveResponse) Test(org.junit.Test)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)1 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)1 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)1 CatalogResolveRequest (org.graylog2.rest.models.system.contentpacks.responses.CatalogResolveRequest)1 CatalogResolveResponse (org.graylog2.rest.models.system.contentpacks.responses.CatalogResolveResponse)1 Test (org.junit.Test)1