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));
}
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));
}
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;
}
Aggregations