Search in sources :

Example 61 with ForeignSource

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());
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) File(java.io.File) Test(org.junit.Test)

Example 62 with ForeignSource

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());
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) File(java.io.File) Test(org.junit.Test)

Example 63 with ForeignSource

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;
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)

Example 64 with ForeignSource

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));
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 65 with 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());
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Test(org.junit.Test)

Aggregations

ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)72 PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)31 Test (org.junit.Test)23 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)11 Before (org.junit.Before)10 MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)9 ArrayList (java.util.ArrayList)8 Path (javax.ws.rs.Path)8 Transactional (org.springframework.transaction.annotation.Transactional)8 TreeSet (java.util.TreeSet)6 File (java.io.File)4 DELETE (javax.ws.rs.DELETE)4 Date (java.util.Date)3 Consumes (javax.ws.rs.Consumes)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 DateTime (org.joda.time.DateTime)2 Duration (org.joda.time.Duration)2