Search in sources :

Example 61 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project entity-service by hypertrace.

the class EntityNormalizerTest method normalizesV1EntityWithAttrs.

@Test
void normalizesV1EntityWithAttrs() {
    Map<String, AttributeValue> valueMap = buildValueMap(Map.of(V1_ID_ATTR.getName(), "foo-value"));
    when(this.mockIdGenerator.generateEntityId(TENANT_ID, V1_ENTITY_TYPE, valueMap)).thenReturn("generated-id");
    when(this.mockIdAttrCache.getIdentifyingAttributes(TENANT_ID, V1_ENTITY_TYPE)).thenReturn(List.of(V1_ID_ATTR));
    when(this.mockEntityTypeClient.get(V1_ENTITY_TYPE)).thenReturn(Single.error(new RuntimeException()));
    Entity inputEntity = Entity.newBuilder().setEntityType(V1_ENTITY_TYPE).putAllIdentifyingAttributes(valueMap).build();
    Entity expectedNormalized = inputEntity.toBuilder().setEntityId("generated-id").setTenantId(TENANT_ID).putAllAttributes(valueMap).build();
    assertEquals(expectedNormalized, this.normalizer.normalize(TENANT_ID, inputEntity));
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.entity.data.service.v1.AttributeValue) Test(org.junit.jupiter.api.Test)

Example 62 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project entity-service by hypertrace.

the class EntityNormalizerTest method normalizesV1EntityTypeWithExtraIdAttr.

@Test
void normalizesV1EntityTypeWithExtraIdAttr() {
    Map<String, AttributeValue> valueMap = buildValueMap(Map.of(V1_ID_ATTR.getName(), "foo-value", "other", "other-value"));
    when(this.mockIdGenerator.generateEntityId(TENANT_ID, V1_ENTITY_TYPE, valueMap)).thenReturn("generated-id");
    when(this.mockIdAttrCache.getIdentifyingAttributes(TENANT_ID, V1_ENTITY_TYPE)).thenReturn(List.of(V1_ID_ATTR));
    when(this.mockEntityTypeClient.get(V1_ENTITY_TYPE)).thenReturn(Single.error(new RuntimeException()));
    Entity inputEntity = Entity.newBuilder().setEntityType(V1_ENTITY_TYPE).putAllIdentifyingAttributes(valueMap).build();
    Entity expectedNormalized = inputEntity.toBuilder().setEntityId("generated-id").setTenantId(TENANT_ID).putAllAttributes(valueMap).build();
    assertEquals(expectedNormalized, this.normalizer.normalize(TENANT_ID, inputEntity));
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.entity.data.service.v1.AttributeValue) Test(org.junit.jupiter.api.Test)

Example 63 with AttributeValue

use of org.hypertrace.entity.data.service.v1.AttributeValue in project entity-service by hypertrace.

the class DocStoreConverter method createEqFilterForAttributeValue.

private static Filter createEqFilterForAttributeValue(String fieldName, AttributeValue attributeValue) {
    Filter f = new Filter();
    f.setFieldName(fieldName);
    f.setOp(Op.EQ);
    f.setValue(prepareRhsValueForSpecialValueListCase(attributeValue));
    // Set child filters to empty array
    f.setChildFilters(new Filter[] {});
    return f;
}
Also used : Filter(org.hypertrace.core.documentstore.Filter) AttributeFilter(org.hypertrace.entity.data.service.v1.AttributeFilter)

Aggregations

Test (org.junit.jupiter.api.Test)39 Entity (org.hypertrace.entity.data.service.v1.Entity)37 AttributeValue (org.hypertrace.entity.data.service.v1.AttributeValue)24 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)20 Event (org.hypertrace.core.datamodel.Event)12 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)11 AttributeValue (com.google.devtools.cloudtrace.v2.AttributeValue)10 Test (org.junit.Test)10 HashMap (java.util.HashMap)9 ByTypeAndIdentifyingAttributes (org.hypertrace.entity.data.service.v1.ByTypeAndIdentifyingAttributes)9 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)7 Span (zipkin2.Span)7 AttributesExtractor.toAttributeValue (zipkin2.translation.stackdriver.AttributesExtractor.toAttributeValue)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Span (com.google.devtools.cloudtrace.v2.Span)3 TruncatableString (com.google.devtools.cloudtrace.v2.TruncatableString)3