use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class RequisitionFrom18Test method test18Requisitions.
@Test
public void test18Requisitions() {
final Set<Requisition> requisitions = m_foreignSourceRepository.getRequisitions();
assertEquals(11, requisitions.size());
int nodeCount = 0;
int interfaceCount = 0;
for (final Requisition r : requisitions) {
LOG.debug("got requisition: {}", r);
nodeCount += r.getNodeCount();
for (RequisitionNode node : r.getNode()) {
interfaceCount += node.getInterfaceCount();
if ("pgvip-master.somemediathing.net".equals(node.getNodeLabel())) {
// Make sure that parent-foreign-source and parent-foreign-id work
assertEquals("postgres", node.getParentForeignSource());
assertEquals("1241674181872", node.getParentForeignId());
assertEquals("barbacoa.somemediathing.net", node.getParentNodeLabel());
}
}
}
assertEquals("There is an unexpected number of nodes in the test requisitions", 49, nodeCount);
assertEquals("There is an unexpected number of interfaces in the test requisitions", 60, interfaceCount);
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method createRequisition.
private Requisition createRequisition() throws Exception {
FileSystemResource resource = new FileSystemResource(getRequisitionFile());
Requisition r = m_foreignSourceRepository.importResourceRequisition(resource);
m_foreignSourceRepository.save(r);
m_foreignSourceRepository.flush();
// Give enough time to watcher's thread to cache the requisition
Thread.sleep(2000);
return r;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method testRequisition.
@Test
public void testRequisition() throws Exception {
createRequisition();
Requisition r = m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName);
TestVisitor v = new TestVisitor();
r.visit(v);
assertEquals("number of nodes visited", 2, v.getNodeReqs().size());
assertEquals("node name matches", "apknd", v.getNodeReqs().get(0).getNodeLabel());
// Modifying the requisition outside the repository and verifying that the repository cache was updated.
modifyRequisition();
r = m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName);
v = new TestVisitor();
r.visit(v);
assertEquals("number of nodes visited", 3, v.getNodeReqs().size());
assertEquals("node name matches", "apknd_2", v.getNodeReqs().get(0).getNodeLabel());
assertEquals("node name matches", "wan0", v.getNodeReqs().get(1).getNodeLabel());
assertEquals("node name matches", "utility-robot", v.getNodeReqs().get(2).getNodeLabel());
// Removing the requisition outside the repository and verifying that the repository cache was updated.
deleteRequisition();
r = m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName);
Assert.assertNull(r);
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FastFilesystemForeignSourceRepositoryTest method modifyRequisition.
private void modifyRequisition() throws Exception {
Requisition r = JaxbUtils.unmarshal(Requisition.class, getRequisitionFile());
Assert.assertNotNull(r);
// Modify existing node
r.getNode("4243").setNodeLabel("apknd_2");
RequisitionNode n = new RequisitionNode();
n.setForeignId("R2D2");
n.setNodeLabel("utility-robot");
n.getCategories().add(new RequisitionCategory("StarWars"));
n.getCategories().add(new RequisitionCategory("Rebels"));
// Add a new node
r.getNodes().add(n);
JaxbUtils.marshal(r, new FileWriter(getRequisitionFile()));
// Give enough time to watcher's thread to cache the requisition
Thread.sleep(2000);
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FasterFilesystemForeignSourceRepositoryTest method testImportHttpSource.
@Test
@JUnitHttpServer(port = 9162)
public void testImportHttpSource() throws Exception {
FileSystemBuilder bldr = new FileSystemBuilder("target", "testGetForeignSource");
File fsDir = bldr.dir("foreignSource").file("test.xml", fs("test")).file("noreq.xml", fs("noreq")).pop();
File reqDir = bldr.dir("requisitions").file("test.xml", req("test")).file("pending.xml", req("pending")).pop();
FasterFilesystemForeignSourceRepository repo = repo(fsDir, reqDir);
Resource resource = new UrlResource("http://localhost:9162/requisition-test.xml");
Requisition req = repo.importResourceRequisition(resource);
assertNotNull(req);
System.err.println(JaxbUtils.marshal(req));
assertNotNull(req.getNode("4243"));
assertNotNull(req.getNode("4244"));
}
Aggregations