use of net.minecraft.server.v1_8_R1.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();
}
use of net.minecraft.server.v1_8_R1.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();
}
use of net.minecraft.server.v1_8_R1.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();
}
use of net.minecraft.server.v1_8_R1.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());
}
use of net.minecraft.server.v1_8_R1.Entity in project DataflowTemplates by GoogleCloudPlatform.
the class BigQueryConvertersTest method testAvroToEntityStringIdColumn.
/**
* Tests that {@link BigQueryConverters.AvroToEntity} creates an Entity with a valid key when the
* unique name column is string.
*/
@Test
public void testAvroToEntityStringIdColumn() throws Exception {
// Create test data
List<TableFieldSchema> fields = new ArrayList<>();
fields.add(new TableFieldSchema().setName(idField).setType("STRING"));
fields.add(new TableFieldSchema().setName(shortStringField).setType("STRING"));
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(generateShortStringField()).toString()));
GenericRecordBuilder builder = new GenericRecordBuilder(avroSchema);
builder.set(idField, idFieldValueStr);
builder.set(shortStringField, shortStringFieldValue);
Record record = builder.build();
SchemaAndRecord inputBqData = new SchemaAndRecord(record, bqSchema);
// Run the test
Entity outputEntity = converter.apply(inputBqData);
assertTrue(outputEntity.hasKey());
assertEquals(idFieldValueStr, outputEntity.getKey().getPath(0).getName());
validateMetadata(outputEntity);
}
Aggregations