Search in sources :

Example 1 with PersistenceNodeProvider

use of org.opennms.features.topology.plugins.topo.asset.layers.PersistenceNodeProvider in project opennms by OpenNMS.

the class PersistenceNodeProviderIT method verifyLayerRestrictions.

/**
     * In order to build a valid hierarchy, each{@link Layer}
     * must ensure that the value for each node IS NOT null.
     * To let the database do the filtering, a {@link Restriction}
     * annotation must be present.
     * This tests ensures that each defined {@link Layer} actually provides a restriction and that the {@link Restriction} works as expected.
     */
@Test
public void verifyLayerRestrictions() throws Exception {
    List<LayerDefinition> mapping = new LayerDefinitionRepository().getDefinitions(NodeParamLabels.ALL_KEYS);
    Assert.assertEquals(NodeParamLabels.ALL_KEYS.size(), Layers.values().length);
    Assert.assertEquals(Layers.values().length, mapping.size());
    final List<OnmsNode> nodes = new PersistenceNodeProvider(genericPersistenceAccessor).getNodes(mapping);
    Assert.assertEquals(1, nodes.size());
    OnmsNode actualNode = nodes.get(0);
    OnmsNode expectedNode = nodeDao.findByLabel("Node 2").get(0);
    Assert.assertEquals(expectedNode.getId(), actualNode.getId());
}
Also used : LayerDefinitionRepository(org.opennms.features.topology.plugins.topo.asset.layers.LayerDefinitionRepository) OnmsNode(org.opennms.netmgt.model.OnmsNode) LayerDefinition(org.opennms.features.topology.plugins.topo.asset.layers.LayerDefinition) PersistenceNodeProvider(org.opennms.features.topology.plugins.topo.asset.layers.PersistenceNodeProvider) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 LayerDefinition (org.opennms.features.topology.plugins.topo.asset.layers.LayerDefinition)1 LayerDefinitionRepository (org.opennms.features.topology.plugins.topo.asset.layers.LayerDefinitionRepository)1 PersistenceNodeProvider (org.opennms.features.topology.plugins.topo.asset.layers.PersistenceNodeProvider)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1