use of org.hypertrace.entity.data.service.v1.EnrichedEntity in project entity-service by hypertrace.
the class EntityDataServiceClient method getEnrichedEntityById.
@Nullable
@Override
public EnrichedEntity getEnrichedEntityById(String tenantId, String entityId) {
ByIdRequest byIdRequest = ByIdRequest.newBuilder().setEntityId(entityId).build();
EnrichedEntity entity = execute(tenantId, () -> blockingStub.getEnrichedEntityById(byIdRequest));
// Handle this here, so that callers can just do a null check
return entity.equals(EnrichedEntity.getDefaultInstance()) ? null : entity;
}
use of org.hypertrace.entity.data.service.v1.EnrichedEntity in project entity-service by hypertrace.
the class EdsCacheClientTest method testGetEnrichedEntityByIdForNull.
@Test
public void testGetEnrichedEntityByIdForNull() {
String tenantId = "tenant";
String enrichedEntityId = "enriched-12345";
when(entityDataServiceClient.getEnrichedEntityById(anyString(), anyString())).thenReturn(null);
EnrichedEntity enrichedEntity = edsCacheClient.getEnrichedEntityById(tenantId, enrichedEntityId);
Assertions.assertNull(enrichedEntity);
enrichedEntity = edsCacheClient.getEnrichedEntityById(tenantId, enrichedEntityId);
Assertions.assertNull(enrichedEntity);
verify(entityDataServiceClient, times(2)).getEnrichedEntityById("tenant", "enriched-12345");
}
use of org.hypertrace.entity.data.service.v1.EnrichedEntity in project entity-service by hypertrace.
the class EntityDataServiceTest method testBulkUpsertEnrichedEntities.
@Test
public void testBulkUpsertEnrichedEntities() {
EnrichedEntity entity1 = EnrichedEntity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").setEntityId(UUID.randomUUID().toString()).putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), generateRandomUUIDAttrValue()).build();
EnrichedEntity entity2 = EnrichedEntity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.DOCKER_CONTAINER.name()).setEntityName("Some container").setEntityId(UUID.randomUUID().toString()).putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), generateRandomUUIDAttrValue()).putRelatedEntities(EntityType.K8S_POD.name(), EnrichedEntities.newBuilder().addEntities(entity1).build()).build();
entityDataServiceClient.upsertEnrichedEntities(TENANT_ID, EnrichedEntities.newBuilder().addEntities(entity1).addEntities(entity2).build());
EnrichedEntity actualEntity1 = entityDataServiceClient.getEnrichedEntityById(TENANT_ID, entity1.getEntityId());
assertEquals(entity1, actualEntity1);
EnrichedEntity actualEntity2 = entityDataServiceClient.getEnrichedEntityById(TENANT_ID, entity2.getEntityId());
assertEquals(entity2, actualEntity2);
}
Aggregations