Search in sources :

Example 1 with DefaultEdge

use of com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge in project hugegraph-computer by hugegraph.

the class DefaultEdgeTest method testEquals.

@Test
public void testEquals() {
    DefaultEdge edge1 = new DefaultEdge(graphFactory());
    edge1.label("knows");
    edge1.name("2021-06-01");
    edge1.targetId(BytesId.of(1L));
    Properties properties = new DefaultProperties(graphFactory());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    edge1.properties(properties);
    DefaultEdge edge2 = new DefaultEdge(graphFactory(), "knows", "2021-06-01", BytesId.of(1L));
    edge2.properties().put("p1", new LongValue(1L));
    edge2.properties().put("p2", new DoubleValue(2.0D));
    Assert.assertEquals(edge1, edge2);
    Assert.assertNotEquals(edge1, properties);
}
Also used : DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) DefaultEdge(com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) Test(org.junit.Test)

Example 2 with DefaultEdge

use of com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge in project hugegraph-computer by hugegraph.

the class DefaultEdgeTest method testOverwrite.

@Test
public void testOverwrite() {
    DefaultEdge edge = new DefaultEdge(graphFactory());
    edge.label("knows");
    edge.name("2021-06-01");
    edge.targetId(BytesId.of(1L));
    Properties properties = new DefaultProperties(graphFactory());
    properties.put("p1", new LongValue(1L));
    properties.put("p2", new DoubleValue(2.0D));
    edge.properties(properties);
    Assert.assertEquals("knows", edge.label());
    Assert.assertEquals("2021-06-01", edge.name());
    Assert.assertEquals(BytesId.of(1L), edge.targetId());
    Assert.assertEquals(properties, edge.properties());
}
Also used : DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) LongValue(com.baidu.hugegraph.computer.core.graph.value.LongValue) DefaultEdge(com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge) Properties(com.baidu.hugegraph.computer.core.graph.properties.Properties) DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) Test(org.junit.Test)

Example 3 with DefaultEdge

use of com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge in project hugegraph-computer by hugegraph.

the class DefaultEdgeTest method testConstructor.

@Test
public void testConstructor() {
    DefaultEdge edge = new DefaultEdge(graphFactory());
    Assert.assertEquals(Constants.EMPTY_STR, edge.label());
    Assert.assertEquals(Constants.EMPTY_STR, edge.name());
    Assert.assertNull(edge.targetId());
    Assert.assertEquals(new DefaultProperties(graphFactory()), edge.properties());
    edge = new DefaultEdge(graphFactory(), "knows", "2021-06-01", BytesId.of(1L));
    Assert.assertEquals("knows", edge.label());
    Assert.assertEquals("2021-06-01", edge.name());
    Assert.assertEquals(BytesId.of(1L), edge.targetId());
    Assert.assertEquals(new DefaultProperties(graphFactory()), edge.properties());
}
Also used : DefaultProperties(com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties) DefaultEdge(com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge) Test(org.junit.Test)

Aggregations

DefaultEdge (com.baidu.hugegraph.computer.core.graph.edge.DefaultEdge)3 DefaultProperties (com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties)3 Test (org.junit.Test)3 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)2 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)2 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)2