use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class ProvisionerIT method testRequisitionedCategoriesWithPolicies.
@Test(timeout = 300000)
public void testRequisitionedCategoriesWithPolicies() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
final ForeignSource fs = m_foreignSourceRepository.getForeignSource("empty");
final PluginConfig policy = new PluginConfig("addDumbCategory", NodeCategorySettingPolicy.class.getName());
policy.addParameter("category", "Dumb");
policy.addParameter("label", "test");
fs.addPolicy(policy);
m_foreignSourceRepository.save(fs);
importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
// after import, we should have 1 category, because policies haven't been applied yet
OnmsNode n = getNodeDao().get(nextNodeId);
assertEquals(1, n.getCategories().size());
assertEquals("TotallyMadeUpCategoryName", n.getCategories().iterator().next().getName());
assertEquals(0, n.getRequisitionedCategories().size());
runPendingScans();
// when the scan has completed, both categories should have been applied
n = getNodeDao().get(nextNodeId);
assertEquals(2, n.getCategories().size());
assertTrue(n.hasCategory("TotallyMadeUpCategoryName"));
assertTrue(n.hasCategory("Dumb"));
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class ProvisionerIT method testRequisitionedCategoriesThenUpdateRequisitionToRemoveCategory.
@Test(timeout = 300000)
public void testRequisitionedCategoriesThenUpdateRequisitionToRemoveCategory() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
runPendingScans();
// make sure we have the 1 category we expect
OnmsNode n = getNodeDao().get(nextNodeId);
assertEquals(1, n.getCategories().size());
assertTrue(n.hasCategory("TotallyMadeUpCategoryName"));
importFromResource("classpath:/provisioner-testCategories-noCategories.xml", Boolean.TRUE.toString());
runPendingScans();
// when the scan has completed, the category should be removed
n = getNodeDao().get(nextNodeId);
assertEquals(0, n.getCategories().size());
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class InvalidRequisitionDataIT method testImportInvalidAsset.
@Test
public void testImportInvalidAsset() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
assertEquals(0, m_nodeDao.countAll());
final Resource invalidAssetFieldResource = getResource("classpath:/import_invalidAssetFieldName.xml");
m_eventManager.getEventAnticipator().anticipateEvent(getStarted(invalidAssetFieldResource));
m_eventManager.getEventAnticipator().anticipateEvent(getSuccessful(invalidAssetFieldResource));
m_eventManager.getEventAnticipator().anticipateEvent(getNodeAdded(nextNodeId));
m_eventManager.getEventAnticipator().anticipateEvent(getNodeGainedInterface(nextNodeId));
m_eventManager.getEventAnticipator().anticipateEvent(getNodeGainedService(nextNodeId));
m_eventManager.getEventAnticipator().anticipateEvent(getNodeScanCompleted(nextNodeId));
// This requisition has an asset on some nodes called "pollercategory".
// Change it to "pollerCategory" (capital 'C') and the test passes...
m_provisioner.doImport(invalidAssetFieldResource.getURL().toString(), Boolean.TRUE.toString());
waitForEverything();
m_eventManager.getEventAnticipator().verifyAnticipated();
// should still import the node, just skip the asset field
assertEquals(1, m_nodeDao.countAll());
OnmsNode node = m_nodeDao.get(m_nodeDao.getNodeIds().iterator().next());
assertEquals("yellow human", node.getAssetRecord().getDescription());
assertNull(node.getAssetRecord().getPollerCategory());
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class ProvisionerIT method testProvisionerAddNodeToSchedule.
@Test(timeout = 300000)
public void testProvisionerAddNodeToSchedule() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
m_provisioner.scheduleRescanForExistingNodes();
assertEquals(0, m_provisioner.getScheduleLength());
final OnmsNode node = createNode("empty");
assertEquals(nextNodeId, node.getId().intValue());
assertNotNull(m_nodeDao.get(nextNodeId));
final EventBuilder bldr = new EventBuilder(EventConstants.NODE_ADDED_EVENT_UEI, "Tests");
bldr.setNodeid(nextNodeId);
m_mockEventIpcManager.broadcastNow(bldr.getEvent());
assertEquals(1, m_provisioner.getScheduleLength());
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class ProvisionerIT method testNonSnmpImportAndScan.
@Test(timeout = 300000)
public void testNonSnmpImportAndScan() throws Exception {
importFromResource("classpath:/import_localhost.xml", Boolean.TRUE.toString());
runPendingScans();
final OnmsNode scannedNode = getNodeDao().findAll().get(0);
assertEquals("TestCategory", scannedNode.getCategories().iterator().next().getName());
}
Aggregations