use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FasterFilesystemForeignSourceRepositoryTest method testGetForeignSource.
@Test
public void testGetForeignSource() 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").file("pending.xml").pop();
FasterFilesystemForeignSourceRepository repo = repo(fsDir, reqDir);
ForeignSource testFS = repo.getForeignSource("test");
assertEquals("test", testFS.getName());
assertEquals(Duration.standardDays(1), testFS.getScanInterval());
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FasterFilesystemForeignSourceRepositoryTest method testGetForeignSources.
@Test
public void testGetForeignSources() throws Exception {
FileSystemBuilder bldr = new FileSystemBuilder("target", "testGetForeignSources");
File fsDir = bldr.dir("foreignSource").file("test.xml", fs("test")).pop();
File reqDir = bldr.dir("requisitions").file("test.xml").file("pending.xml").pop();
FasterFilesystemForeignSourceRepository repo = repo(fsDir, reqDir);
Set<ForeignSource> foreignSources = repo.getForeignSources();
assertEquals(1, foreignSources.size());
ForeignSource testFS = foreignSources.iterator().next();
assertEquals("test", testFS.getName());
assertEquals(Duration.standardDays(1), testFS.getScanInterval());
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class MockForeignSourceRepositoryTest method createForeignSource.
private ForeignSource createForeignSource(String foreignSource) throws Exception {
ForeignSource fs = new ForeignSource(foreignSource);
fs.addDetector(new PluginConfig("HTTP", "org.opennms.netmgt.provision.detector.simple.HttpDetector"));
fs.addPolicy(new PluginConfig("all-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.InclusiveInterfacePolicy"));
m_foreignSourceRepository.save(fs);
m_foreignSourceRepository.flush();
return fs;
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class MockForeignSourceRepositoryTest method testGetRequisition.
@Test
public void testGetRequisition() throws Exception {
Requisition requisition = createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
assertRequisitionsMatch("foreign sources must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
assertRequisitionsMatch("foreign source is expected one", requisition, m_foreignSourceRepository.getRequisition(foreignSource));
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class CachingForeignSourceRepositoryTest method testForeignSource.
@Test
public void testForeignSource() throws Exception {
createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
Set<ForeignSource> foreignSources = m_foreignSourceRepository.getForeignSources();
String names = "", separator = "";
for (ForeignSource fs : foreignSources) {
names += (separator + "\"" + fs.getName() + "\"");
separator = ", ";
}
assertEquals("number of foreign sources must be 1: " + names, 1, foreignSources.size());
assertEquals("getAll() foreign source name must match", m_defaultForeignSourceName, foreignSources.iterator().next().getName());
// check that the foreign source matches
final ForeignSource newForeignSource = m_foreignSourceRepository.getForeignSource(m_defaultForeignSourceName);
assertEquals(foreignSource.getName(), newForeignSource.getName());
assertEquals(foreignSource.getDateStampAsDate(), newForeignSource.getDateStampAsDate());
assertEquals(foreignSource.getDetectorNames(), newForeignSource.getDetectorNames());
assertEquals(foreignSource.getScanInterval(), newForeignSource.getScanInterval());
}
Aggregations