/** * Initializes the internal properties field if necessary. */ private void initProperties() { if (this.properties == null) { this.properties = Properties.create(); } } }
/** * Constructor */ CSVLineToElement() { this.properties = Properties.create(); }
/** * Constructor */ CSVLineToElement() { this.properties = Properties.create(); }
/** * Constructor */ CSVLineToElement() { this.properties = Properties.create(); }
/** * Constructor */ CSVLineToElement() { this.properties = Properties.create(); }
/** * Creates a new instance of this JSON string to vertex converting function. * * @param vertexFactory The vertex factory used to create new vertices. */ public MinimalJsonToVertex(EPGMVertexFactory<Vertex> vertexFactory) { this.reuse = Objects.requireNonNull(vertexFactory).createVertex(JSON_VERTEX_LABEL); this.reuse.setProperties(Properties.create()); }
@Override public ImportEdge<Long> map( Tuple2<Long, Tuple2<Long, Long>> value) throws Exception { importEdge.setId(value.f0); importEdge.setSourceId(value.f1.f0); importEdge.setTargetId(value.f1.f1); importEdge.setLabel(EDGE_LABEL); importEdge.setProperties(Properties.create()); return importEdge; } }).withForwardedFields("f0;f1.f0->f1;f1.f1->f2");
@Test public void testSetProperty() { Element elementMock = mock(Element.class, CALLS_REAL_METHODS); elementMock.setProperty(KEY_0, STRING_VAL_6); Properties properties = Properties.create(); properties.set(KEY_0, STRING_VAL_6); assertEquals(elementMock.getProperties(), properties); }
@Test(expected = NullPointerException.class) public void testGetPropertyValueNull() { Properties properties = Properties.create(); properties.set(KEY_0, STRING_VAL_6); GradoopId gradoopId = GradoopId.get(); // create element mock with property Element elementMock = mock(Element.class, withSettings() .useConstructor(gradoopId, "someLabel", properties) .defaultAnswer(CALLS_REAL_METHODS)); elementMock.getPropertyValue(null); }
@Test public void testClear() throws Exception { Properties properties = Properties.create(); properties.set(KEY_1, BOOL_VAL_1); properties.clear(); assertEquals("wrong size", 0, properties.size()); }
@Test public void testIsEmpty() throws Exception { Properties properties = Properties.create(); assertTrue("properties was not empty", properties.isEmpty()); properties.set(KEY_1, BOOL_VAL_1); assertFalse("properties was empty", properties.isEmpty()); }
@Test public void testFilterWithNoPredicates() throws Exception { CNF predicates = predicateFromQuery("MATCH (a)"); Properties properties = Properties.create(); properties.set("name", "Anton"); DataSet<Vertex> vertices = getExecutionEnvironment() .fromElements(new VertexFactory().createVertex("Person", properties)); FilterAndProjectVertices filter = new FilterAndProjectVertices(vertices, predicates, new ArrayList<>()); assertEquals(1, filter.evaluate().count()); }
@Test public void testRemoveExistentProperty() { Properties properties = Properties.create(); properties.set(KEY_0, STRING_VAL_6); GradoopId gradoopId = GradoopId.get(); // create element mock with property Element elementMock = mock(Element.class, withSettings() .useConstructor(gradoopId, "someLabel", properties) .defaultAnswer(CALLS_REAL_METHODS)); assertEquals(properties.get(KEY_0), elementMock.removeProperty(KEY_0)); assertFalse(elementMock.hasProperty(KEY_0)); }
@Test public void testProjectionOfAvailableValues() throws Exception { CNF predicates = predicateFromQuery("MATCH ()-[a]->() WHERE a.name = \"Alice\""); Properties properties = Properties.create(); properties.set("name", "Alice"); Edge edge = new EdgeFactory().createEdge("Label", GradoopId.get(), GradoopId.get(), properties); DataSet<Edge> edges = getExecutionEnvironment().fromElements(edge); List<String> projectionPropertyKeys = Lists.newArrayList("name"); Embedding result = new FilterAndProjectEdges(edges, predicates, projectionPropertyKeys, false) .evaluate().collect().get(0); assertEquals(result.getProperty(0), PropertyValue.create("Alice")); }
@Test public void testContainsKey() throws Exception { Properties properties = Properties.create(); assertFalse("unexpected key found", properties.containsKey(KEY_1)); properties.set(KEY_1, BOOL_VAL_1); assertTrue("key not found", properties.containsKey(KEY_1)); assertFalse("unexpected key found", properties.containsKey("1234")); }
@Test public void testSet2() throws Exception { Properties properties = Properties.create(); properties.set(KEY_1, BOOL_VAL_1); assertEquals(BOOL_VAL_1, properties.get(KEY_1).getObject()); // override properties.set(KEY_1, INT_VAL_2); assertEquals(INT_VAL_2, properties.get(KEY_1).getObject()); }
@Test public void testSet() throws Exception { Properties properties = Properties.create(); properties.set(Property.create(KEY_1, BOOL_VAL_1)); assertEquals(BOOL_VAL_1, properties.get(KEY_1).getObject()); // override properties.set(Property.create(KEY_1, INT_VAL_2)); assertEquals(INT_VAL_2, properties.get(KEY_1).getObject()); }
@Test public void testSet1() throws Exception { Properties properties = Properties.create(); properties.set(KEY_1, PropertyValue.create(BOOL_VAL_1)); assertEquals(BOOL_VAL_1, properties.get(KEY_1).getObject()); // override properties.set(KEY_1, PropertyValue.create(INT_VAL_2)); assertEquals(INT_VAL_2, properties.get(KEY_1).getObject()); }
@Test public void testSize() throws Exception { Properties properties = Properties.create(); assertEquals("wrong size", 0, properties.size()); properties.set(KEY_1, BOOL_VAL_1); assertEquals("wrong size", 1, properties.size()); properties.set(KEY_2, INT_VAL_2); assertEquals("wrong size", 2, properties.size()); // add existing properties.set(KEY_2, LONG_VAL_3); assertEquals("wrong size", 2, properties.size()); }
@Test public void testRemove2() throws Exception { Properties properties = Properties.create(); PropertyValue removed; properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(Property.create(KEY_1, BOOL_VAL_1)); assertEquals(0, properties.size()); assertNotNull(removed); properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(Property.create(KEY_2, BOOL_VAL_1)); assertEquals(1, properties.size()); assertNull(removed); }