@Test public void no_properties_by_default() { assertThat(beanVertex.getProperty("color")).isNull(); assertThat(beanVertex.getProperty("code")).isNull(); assertThat(beanVertex.getProperty("alive")).isNull(); assertThat(beanVertex.getPropertyKeys()).isEmpty(); }
@Before public void before() { TinkerGraph graph = new TinkerGraph(); beanGraph = new BeanGraph(graph); Vertex vertex = graph.addVertex(null); beanVertex = new BeanVertex() {}; beanVertex.setElement(vertex); beanVertex.setBeanGraph(beanGraph); }
@Test public void should_remove_property() { beanVertex.setProperty("color", "red"); beanVertex.setProperty("code", 123); beanVertex.setProperty("alive", true); beanVertex.removeProperty("color"); beanVertex.removeProperty("code"); beanVertex.removeProperty("alive"); beanVertex.removeProperty("other"); assertThat(beanVertex.getProperty("color")).isNull(); assertThat(beanVertex.getProperty("code")).isNull(); assertThat(beanVertex.getProperty("alive")).isNull(); assertThat(beanVertex.getPropertyKeys()).isEmpty(); }
@Test public void should_unset_properties_with_null_values() { beanVertex.setProperty("color", "red"); beanVertex.setProperty("code", 123); beanVertex.setProperty("alive", true); beanVertex.setProperty("color", null); beanVertex.setProperty("code", null); beanVertex.setProperty("alive", null); beanVertex.setProperty("other", null); assertThat(beanVertex.getProperty("color")).isNull(); assertThat(beanVertex.getProperty("code")).isNull(); assertThat(beanVertex.getProperty("alive")).isNull(); assertThat(beanVertex.getPropertyKeys()).isEmpty(); }
public final <T extends BeanVertex> T createAdjacentVertex( BeanVertex from, Class<T> beanClass, String edgeLabel, String... edgeProperties) { T to = createVertex(beanClass); Edge edge = graph.addEdge(null, from.element(), to.element(), edgeLabel); ElementHelper.setProperties(edge, edgeProperties); return to; }
@Test public void should_set_properties() { beanVertex.setProperty("color", "red"); beanVertex.setProperty("code", 123); beanVertex.setProperty("alive", true); assertThat(beanVertex.getProperty("color")).isEqualTo("red"); assertThat(beanVertex.getProperty("code")).isEqualTo(123); assertThat(beanVertex.getProperty("alive")).isEqualTo(true); assertThat(beanVertex.getPropertyKeys()).containsOnly("color", "code", "alive"); }
@Test public void should_set_required_fields() { assertThat(beanVertex.beanGraph()).isSameAs(beanGraph); assertThat(beanVertex.element()).isInstanceOf(Vertex.class); }