Search in sources :

Example 81 with ui.ex1.entity

use of ui.ex1.entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method splitEntitiesByKind.

@Test
void splitEntitiesByKind() {
    TupleTagList tags = getDeletionTags(2);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
    PCollectionView<Map<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags).apply(View.asMap());
    Entity entityA = createTestEntity("A", 1);
    Entity entityB = createTestEntity("B", 2);
    PCollection<Entity> entities = testPipeline.apply("InjectEntities", Create.of(entityA, entityB));
    PCollectionTuple allCollections = entities.apply("SplitByKind", ParDo.of(new SplitEntities(kindToTagMapping)).withSideInputs(kindToTagMapping).withOutputTags(getOneDeletionTag("placeholder"), tags));
    PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(0))).containsInAnyOrder(entityA);
    PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(1))).containsInAnyOrder(entityB);
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) SplitEntities(google.registry.beam.datastore.BulkDeleteDatastorePipeline.SplitEntities) TupleTagList(org.apache.beam.sdk.values.TupleTagList) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.jupiter.api.Test)

Example 82 with ui.ex1.entity

use of ui.ex1.entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method mapKindsToTags_fewerKindsThanTags.

@Test
void mapKindsToTags_fewerKindsThanTags() {
    TupleTagList tags = getDeletionTags(3);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
    PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
    PAssert.thatMap(kindToTagMapping).isEqualTo(ImmutableMap.of("A", new TupleTag<Entity>("0"), "B", new TupleTag<Entity>("1")));
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) TupleTagList(org.apache.beam.sdk.values.TupleTagList) TupleTag(org.apache.beam.sdk.values.TupleTag) KV(org.apache.beam.sdk.values.KV) Test(org.junit.jupiter.api.Test)

Example 83 with ui.ex1.entity

use of ui.ex1.entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method mapKindsToTags.

@Test
void mapKindsToTags() {
    TupleTagList tags = getDeletionTags(2);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
    PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
    PAssert.thatMap(kindToTagMapping).isEqualTo(ImmutableMap.of("A", new TupleTag<Entity>("0"), "B", new TupleTag<Entity>("1")));
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) TupleTagList(org.apache.beam.sdk.values.TupleTagList) TupleTag(org.apache.beam.sdk.values.TupleTag) KV(org.apache.beam.sdk.values.KV) Test(org.junit.jupiter.api.Test)

Example 84 with ui.ex1.entity

use of ui.ex1.entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method mapKindsToTags_moreKindsThanTags.

@Test
void mapKindsToTags_moreKindsThanTags() {
    TupleTagList tags = getDeletionTags(2);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B", "C"));
    PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
    PAssert.thatMap(kindToTagMapping).isEqualTo(ImmutableMap.of("A", new TupleTag<Entity>("0"), "B", new TupleTag<Entity>("1"), "C", new TupleTag<Entity>("0")));
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) TupleTagList(org.apache.beam.sdk.values.TupleTagList) TupleTag(org.apache.beam.sdk.values.TupleTag) KV(org.apache.beam.sdk.values.KV) Test(org.junit.jupiter.api.Test)

Example 85 with ui.ex1.entity

use of ui.ex1.entity in project DataflowTemplates by GoogleCloudPlatform.

the class BigQueryConvertersTest method testAvroToEntityInvalidTimestampField.

/**
 * Tests that {@link BigQueryConverters.AvroToEntity} creates an Entity without a valid key when a
 * Timestamp field is invalid.
 */
@Test
public void testAvroToEntityInvalidTimestampField() throws Exception {
    // Create test data
    List<TableFieldSchema> fields = new ArrayList<>();
    fields.add(new TableFieldSchema().setName(idField).setType("STRING"));
    fields.add(new TableFieldSchema().setName(invalidTimestampField).setType("TIMESTAMP"));
    TableSchema bqSchema = new TableSchema().setFields(fields);
    Schema avroSchema = new Schema.Parser().parse(String.format(avroSchemaTemplate, new StringBuilder().append(String.format(avroFieldTemplate, idField, "string", idFieldDesc)).append(",").append(String.format(avroFieldTemplate, invalidTimestampField, "long", invalidTimestampFieldDesc)).toString()));
    GenericRecordBuilder builder = new GenericRecordBuilder(avroSchema);
    builder.set(idField, idFieldValueStr);
    builder.set(invalidTimestampField, invalidTimestampFieldValueNanos);
    Record record = builder.build();
    SchemaAndRecord inputBqData = new SchemaAndRecord(record, bqSchema);
    // Run the test
    Entity outputEntity = converter.apply(inputBqData);
    // Assess results
    assertTrue(!outputEntity.hasKey());
    assertTrue(outputEntity.getPropertiesMap().get("cause").getStringValue().startsWith("Timestamp is not valid"));
    assertEquals(record.toString(), outputEntity.getPropertiesMap().get("row").getStringValue());
}
Also used : Entity(com.google.datastore.v1.Entity) AvroToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.AvroToEntity) TableSchema(com.google.api.services.bigquery.model.TableSchema) TableSchema(com.google.api.services.bigquery.model.TableSchema) Schema(org.apache.avro.Schema) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) ArrayList(java.util.ArrayList) GenericRecordBuilder(org.apache.avro.generic.GenericRecordBuilder) Record(org.apache.avro.generic.GenericData.Record) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) Test(org.junit.Test)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)94 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)32 org.bukkit.entity (org.bukkit.entity)32 Entity (com.google.datastore.v1.Entity)31 Location (org.bukkit.Location)29 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21 Entity (net.minecraft.server.v1_12_R1.Entity)20 Entity (net.minecraft.server.v1_16_R3.Entity)19 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)17 Entity (net.minecraft.server.v1_11_R1.Entity)16 Mob (net.minecraft.world.entity.Mob)16 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)16 org.bukkit.craftbukkit.v1_17_R1.entity (org.bukkit.craftbukkit.v1_17_R1.entity)16 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)13 Entity (net.minecraft.server.v1_15_R1.Entity)12 Entity (net.minecraft.server.v1_13_R2.Entity)11 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)11