Search in sources :

Example 86 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.

the class KafkaBackendProviderTest method TestOTBackendEventResolution.

@Test
public void TestOTBackendEventResolution() {
    String brokerHost = "kafka-test.hypertrace.com";
    String brokerPort = "9092";
    Entity entity = backendEntityEnricher.resolve(getOTKafkaBackendEvent(brokerHost, brokerPort), structuredTrace, structuredTraceGraph).get().getEntity();
    Assertions.assertEquals(String.format("%s:%s", brokerHost, brokerPort), entity.getEntityName());
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) Test(org.junit.jupiter.api.Test)

Example 87 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.

the class KafkaBackendProviderTest method TestOtelBackendEventResolution.

@Test
public void TestOtelBackendEventResolution() {
    String broker = "kafka-test.hypertrace.com:9092";
    BackendInfo backendInfo = backendEntityEnricher.resolve(getOtelKafkaBackendEvent(broker), structuredTrace, structuredTraceGraph).get();
    Entity entity = backendInfo.getEntity();
    Assertions.assertEquals(broker, entity.getEntityName());
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("receive")), attributes);
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Example 88 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project beam by apache.

the class DatastoreV1Test method testReadFnRetriesErrors.

/**
 * Tests that {@link ReadFn} retries after an error.
 */
@Test
public void testReadFnRetriesErrors() throws Exception {
    // An empty query to read entities.
    Query query = Query.newBuilder().setLimit(Int32Value.newBuilder().setValue(1)).build();
    // Use mockResponseForQuery to generate results.
    when(mockDatastore.runQuery(any(RunQueryRequest.class))).thenThrow(new DatastoreException("RunQuery", Code.DEADLINE_EXCEEDED, "", null)).thenAnswer(invocationOnMock -> {
        Query q = ((RunQueryRequest) invocationOnMock.getArguments()[0]).getQuery();
        return mockResponseForQuery(q);
    });
    ReadFn readFn = new ReadFn(V_1_OPTIONS, mockDatastoreFactory);
    DoFnTester<Query, Entity> doFnTester = DoFnTester.of(readFn);
    doFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE);
    doFnTester.processBundle(query);
    verifyMetricWasSet("BatchDatastoreRead", "ok", NAMESPACE, 1);
    verifyMetricWasSet("BatchDatastoreRead", "unknown", NAMESPACE, 1);
}
Also used : Entity(com.google.datastore.v1.Entity) DeleteEntity(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity) GqlQuery(com.google.datastore.v1.GqlQuery) Query(com.google.datastore.v1.Query) ReadFn(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.Read.ReadFn) RunQueryRequest(com.google.datastore.v1.RunQueryRequest) DatastoreException(com.google.datastore.v1.client.DatastoreException) Test(org.junit.Test)

Example 89 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project beam by apache.

the class DatastoreV1Test method testAddEntities.

@Test
public /**
 * Test that entities with valid keys are transformed to upsert mutations.
 */
void testAddEntities() throws Exception {
    Key key = makeKey("bird", "finch").build();
    Entity entity = Entity.newBuilder().setKey(key).build();
    UpsertFn upsertFn = new UpsertFn();
    Mutation expectedMutation = makeUpsert(entity).build();
    assertEquals(expectedMutation, upsertFn.apply(entity));
}
Also used : Entity(com.google.datastore.v1.Entity) DeleteEntity(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity) UpsertFn(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.UpsertFn) Mutation(com.google.datastore.v1.Mutation) DeleteKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey) Key(com.google.datastore.v1.Key) DatastoreHelper.makeKey(com.google.datastore.v1.client.DatastoreHelper.makeKey) DatastoreV1.isValidKey(org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey) Test(org.junit.Test)

Example 90 with Entity

use of com.google.cloud.videointelligence.v1p2beta1.Entity in project beam by apache.

the class EntityToRowRowToEntityTest method testRowToEntityConverterWithoutKey.

@Test
public void testRowToEntityConverterWithoutKey() {
    Schema schemaWithoutKey = Schema.builder().addFields(SCHEMA.getFields().stream().filter(f -> !f.getName().equals("__key__")).collect(Collectors.toList())).build();
    Row rowWithoutKey = Row.withSchema(schemaWithoutKey).addValues(schemaWithoutKey.getFieldNames().stream().map(ROW::getValue).collect(Collectors.toList())).build();
    PCollection<Entity> result = pipeline.apply(Create.of(rowWithoutKey)).setRowSchema(schemaWithoutKey).apply(RowToEntity.createTest(UUID_VALUE, "__key__", KIND));
    PAssert.that(result).containsInAnyOrder(ENTITY);
    pipeline.run().waitUntilFinish();
}
Also used : Arrays(java.util.Arrays) RunWith(org.junit.runner.RunWith) DatastoreHelper.makeValue(com.google.datastore.v1.client.DatastoreHelper.makeValue) INT64(org.apache.beam.sdk.schemas.Schema.FieldType.INT64) DOUBLE(org.apache.beam.sdk.schemas.Schema.FieldType.DOUBLE) Key(com.google.datastore.v1.Key) Create(org.apache.beam.sdk.transforms.Create) DatastoreHelper.makeKey(com.google.datastore.v1.client.DatastoreHelper.makeKey) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Value(com.google.datastore.v1.Value) Row(org.apache.beam.sdk.values.Row) FieldType.array(org.apache.beam.sdk.schemas.Schema.FieldType.array) DateTimeFormat(org.joda.time.format.DateTimeFormat) PAssert(org.apache.beam.sdk.testing.PAssert) DateTime(org.joda.time.DateTime) FieldType(org.apache.beam.sdk.schemas.Schema.FieldType) Test(org.junit.Test) BYTES(org.apache.beam.sdk.schemas.Schema.FieldType.BYTES) UUID(java.util.UUID) JUnit4(org.junit.runners.JUnit4) DATETIME(org.apache.beam.sdk.schemas.Schema.FieldType.DATETIME) PCollection(org.apache.beam.sdk.values.PCollection) Collectors(java.util.stream.Collectors) Schema(org.apache.beam.sdk.schemas.Schema) StandardCharsets(java.nio.charset.StandardCharsets) Entity(com.google.datastore.v1.Entity) ByteString(com.google.protobuf.ByteString) BOOLEAN(org.apache.beam.sdk.schemas.Schema.FieldType.BOOLEAN) Rule(org.junit.Rule) STRING(org.apache.beam.sdk.schemas.Schema.FieldType.STRING) Collections(java.util.Collections) Entity(com.google.datastore.v1.Entity) Schema(org.apache.beam.sdk.schemas.Schema) Row(org.apache.beam.sdk.values.Row) Test(org.junit.Test)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 LivingEntity (org.bukkit.entity.LivingEntity)95 Test (org.junit.jupiter.api.Test)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)40 org.bukkit.entity (org.bukkit.entity)40 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)33 Location (org.bukkit.Location)33 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Mob (net.minecraft.world.entity.Mob)20 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17 Entity (com.google.cloud.videointelligence.v1.Entity)17