use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.
the class EntityNormalizerTest method throwsOnV1EntityTypeMissingIdAttr.
@Test
void throwsOnV1EntityTypeMissingIdAttr() {
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).build();
Exception exception = assertThrows(IllegalArgumentException.class, () -> this.normalizer.normalize(TENANT_ID, inputEntity));
assertEquals("Received and expected identifying attributes differ. Received: [] . Expected: [required-attr]", exception.getMessage());
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.
the class EntityNormalizerTest method throwsOnV2EntityMissingId.
@Test
void throwsOnV2EntityMissingId() {
when(this.mockEntityTypeClient.get(V2_ENTITY_TYPE)).thenReturn(Single.just(EntityType.getDefaultInstance()));
Entity inputEntity = Entity.newBuilder().setEntityType(V2_ENTITY_TYPE).build();
Exception exception = assertThrows(IllegalArgumentException.class, () -> this.normalizer.normalize(TENANT_ID, inputEntity));
assertEquals("Entity ID is empty", exception.getMessage());
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project entity-service by hypertrace.
the class DocStoreConverterTest method entityToJSONDocumentConversion64BitNumberFixup.
@Test
public void entityToJSONDocumentConversion64BitNumberFixup() throws IOException {
// Verify that timestamp attribute which is a long number won't get
// converted to string
Entity testEntity = Entity.newBuilder().setTenantId("tenant1").setEntityName("myentity1").putIdentifyingAttributes("entity_id", AttributeValue.newBuilder().setValue(Value.newBuilder().setString("my-entity-id-1")).build()).putAttributes("timestamp", AttributeValue.newBuilder().setValue(Value.newBuilder().setLong(1584055141072L)).build()).build();
JSONDocument jsonDocument = DocStoreConverter.transform(testEntity);
Assertions.assertEquals("{\"tenantId\":\"tenant1\",\"entityName\":\"myentity1\",\"identifyingAttributes\":{\"entity_id\":{\"value\":{\"string\":\"my-entity-id-1\"}}},\"attributes\":{\"timestamp\":{\"value\":{\"long\":1584055141072}}}}", jsonDocument.toJson());
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project osmosis by openstreetmap.
the class EntityProgressLogger method process.
/**
* {@inheritDoc}
*/
public void process(EntityContainer entityContainer) {
Entity entity;
entity = entityContainer.getEntity();
if (progressTracker.updateRequired()) {
LOG.info(prefix + "Processing " + entity.getType() + " " + entity.getId() + ", " + progressTracker.getObjectsPerSecond() + " objects/second.");
}
sink.process(entityContainer);
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project osmosis by openstreetmap.
the class TagSorter method process.
/**
* {@inheritDoc}
*/
public void process(EntityContainer entityContainer) {
EntityContainer writeableContainer;
Entity entity;
Collection<Tag> sortedTags;
writeableContainer = entityContainer.getWriteableInstance();
entity = writeableContainer.getEntity();
sortedTags = sortTags(entity.getTags());
entity.getTags().clear();
entity.getTags().addAll(sortedTags);
sink.process(writeableContainer);
}
Aggregations