use of uk.gov.gchq.gaffer.data.generator.MapGenerator in project Gaffer by gchq.
the class MapGeneratorTest method shouldGenerateAnEmptyMap.
@Test
public void shouldGenerateAnEmptyMap() {
// Given
final Object vertex = "source vertex";
final String prop1 = "property 1";
final int count = 10;
final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
final MapGenerator generator = new MapGenerator();
// When
final Map<String, Object> map = generator.getObject(element);
// Then
final Map<String, Object> expectedMap = new LinkedHashMap<>();
assertEquals(expectedMap, map);
}
use of uk.gov.gchq.gaffer.data.generator.MapGenerator in project Gaffer by gchq.
the class MapGeneratorTest method shouldGenerateMapFromASingleProperty.
@Test
public void shouldGenerateMapFromASingleProperty() {
// Given
final Object vertex = "source vertex";
final String prop1 = "property 1";
final int count = 10;
final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
final MapGenerator generator = new MapGenerator.Builder().property(TestPropertyNames.PROP_1, "field1").build();
// When
final Map<String, Object> map = generator.getObject(element);
// Then
final Map<String, Object> expectedMap = new LinkedHashMap<>();
expectedMap.put("field1", prop1);
assertEquals(expectedMap, map);
}
use of uk.gov.gchq.gaffer.data.generator.MapGenerator in project Gaffer by gchq.
the class MapGeneratorTest method shouldGenerateMapFromElementFieldsAndConstants.
@Test
public void shouldGenerateMapFromElementFieldsAndConstants() {
// Given
final Object vertex = "source vertex";
final String prop1 = "property 1";
final int count = 10;
final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
final MapGenerator generator = new MapGenerator.Builder().vertex("field1").group("field2").property(TestPropertyNames.COUNT, "field3").property(TestPropertyNames.PROP_1, "field4").source(// the entity does not have a source so this should be skipped
"field5").property("unknown property", "field6").constant("constant1", "constantValue1").build();
// When
final Map<String, Object> map = generator.getObject(element);
// Then
final Map<String, Object> expectedMap = new LinkedHashMap<>();
expectedMap.put("field1", vertex);
expectedMap.put("field2", TestGroups.ENTITY);
expectedMap.put("field3", count);
expectedMap.put("field4", prop1);
expectedMap.put("constant1", "constantValue1");
assertEquals(expectedMap, map);
}
Aggregations