Search in sources :

Example 6 with ExecutableRule

use of com.buschmais.jqassistant.core.rule.api.model.ExecutableRule in project jqa-core-framework by buschmais.

the class SubGraphFactoryTest method collectionOfNodesAndCollectionOfRelationships.

@Test
public void collectionOfNodesAndCollectionOfRelationships() throws ReportException {
    MapBuilder<String, Object> builder = MapBuilder.builder();
    builder.entry("nodes", asList(asList(getNeo4jNode(1l), getNeo4jNode(2l))));
    builder.entry("relations", asList(asList(getNeo4jRelationship(1l, "TEST"), getNeo4jRelationship(2l, "TEST"))));
    Result<ExecutableRule> result = Result.builder().rows(singletonList(builder.build())).build();
    SubGraph graph = factory.createSubGraph(result);
    assertThat(graph.getId()).isEqualTo(-1l);
    assertThat(graph.getParent()).isNull();
    assertThat(graph.getSubGraphs()).isEmpty();
    Map<Long, Node> nodes = graph.getNodes();
    assertThat(nodes).hasSize(2);
    Node node1 = nodes.get(1l);
    assertThat(node1.getId()).isEqualTo(1l);
    Node node2 = nodes.get(2l);
    assertThat(node2.getId()).isEqualTo(2l);
    Map<Long, Relationship> relationships = graph.getRelationships();
    assertThat(relationships).hasSize(2);
    Relationship relationship1 = relationships.get(1l);
    assertThat(relationship1.getId()).isEqualTo(1l);
    Relationship relationship2 = relationships.get(2l);
    assertThat(relationship2.getId()).isEqualTo(2l);
}
Also used : ExecutableRule(com.buschmais.jqassistant.core.rule.api.model.ExecutableRule) Node(com.buschmais.jqassistant.core.report.api.graph.model.Node) Neo4jNode(com.buschmais.xo.neo4j.api.model.Neo4jNode) Neo4jRelationship(com.buschmais.xo.neo4j.api.model.Neo4jRelationship) Relationship(com.buschmais.jqassistant.core.report.api.graph.model.Relationship) CompositeObject(com.buschmais.xo.api.CompositeObject) SubGraph(com.buschmais.jqassistant.core.report.api.graph.model.SubGraph) Test(org.junit.jupiter.api.Test)

Example 7 with ExecutableRule

use of com.buschmais.jqassistant.core.rule.api.model.ExecutableRule in project jqa-core-framework by buschmais.

the class SubGraphFactoryTest method virtualRelationship.

@Test
public void virtualRelationship() throws ReportException {
    Map<Object, Object> properties = MapBuilder.builder().entry("key", "value").build();
    Map<String, Object> virtualNode = // 
    MapBuilder.<String, Object>builder().entry("role", // 
    "relationship").entry("label", // 
    "Virtual Relationship").entry("type", // 
    "TEST").entry("properties", // 
    properties).entry("startNode", // 
    getNeo4jNode(1l)).entry("endNode", // 
    getNeo4jNode(2l)).build();
    MapBuilder<String, Object> builder = MapBuilder.builder();
    builder.entry("relationships", singletonList(virtualNode));
    Result<ExecutableRule> result = Result.builder().rows(singletonList(builder.build())).build();
    SubGraph graph = factory.createSubGraph(result);
    Map<Long, Relationship> relationships = graph.getRelationships();
    assertThat(relationships.size()).isEqualTo(1);
    Relationship relationship = relationships.get(-1l);
    assertThat(relationship).isNotNull();
    assertThat(relationship.getId()).isEqualTo(-1l);
    assertThat(relationship.getLabel()).isEqualTo("Virtual Relationship");
    assertThat(relationship.getType()).isEqualTo("TEST");
    assertThat(relationship.getProperties()).isEqualTo(properties);
    Node startNode = relationship.getStartNode();
    assertThat(startNode).isNotNull();
    assertThat(startNode.getId()).isEqualTo(1l);
    Node endNode = relationship.getEndNode();
    assertThat(endNode).isNotNull();
    assertThat(endNode.getId()).isEqualTo(2l);
}
Also used : ExecutableRule(com.buschmais.jqassistant.core.rule.api.model.ExecutableRule) Neo4jRelationship(com.buschmais.xo.neo4j.api.model.Neo4jRelationship) Relationship(com.buschmais.jqassistant.core.report.api.graph.model.Relationship) Node(com.buschmais.jqassistant.core.report.api.graph.model.Node) Neo4jNode(com.buschmais.xo.neo4j.api.model.Neo4jNode) CompositeObject(com.buschmais.xo.api.CompositeObject) SubGraph(com.buschmais.jqassistant.core.report.api.graph.model.SubGraph) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutableRule (com.buschmais.jqassistant.core.rule.api.model.ExecutableRule)7 Node (com.buschmais.jqassistant.core.report.api.graph.model.Node)6 SubGraph (com.buschmais.jqassistant.core.report.api.graph.model.SubGraph)6 CompositeObject (com.buschmais.xo.api.CompositeObject)6 Neo4jNode (com.buschmais.xo.neo4j.api.model.Neo4jNode)6 Test (org.junit.jupiter.api.Test)6 Relationship (com.buschmais.jqassistant.core.report.api.graph.model.Relationship)4 Neo4jRelationship (com.buschmais.xo.neo4j.api.model.Neo4jRelationship)4 Constraint (com.buschmais.jqassistant.core.rule.api.model.Constraint)1