Search in sources :

Example 11 with Requisition

use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.

the class CachingForeignSourceRepositoryTest method createRequisition.

private Requisition createRequisition() throws Exception {
    Requisition r = m_foreignSourceRepository.importResourceRequisition(new ClassPathResource("/requisition-test.xml"));
    m_foreignSourceRepository.save(r);
    m_foreignSourceRepository.flush();
    return r;
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 12 with Requisition

use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.

the class CachingForeignSourceRepositoryTest method testGetRequisition.

@Test
public void testGetRequisition() throws Exception {
    Requisition requisition = createRequisition();
    ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
    assertRequisitionsMatch("requisitions must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
    assertRequisitionsMatch("foreign source is the 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 13 with Requisition

use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.

the class FastFilesystemForeignSourceRepositoryTest method testGetRequisition.

@Test
public void testGetRequisition() throws Exception {
    Requisition requisition = createRequisition();
    ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
    assertRequisitionsMatch("requisitions must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
    assertRequisitionsMatch("foreign source is the 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 14 with Requisition

use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.

the class RequisitionFileUtils method getLatestPendingOrSnapshotRequisition.

public static Requisition getLatestPendingOrSnapshotRequisition(final ForeignSourceRepository foreignSourceRepository, final String foreignSource) {
    Requisition newest = foreignSourceRepository.getRequisition(foreignSource);
    for (final File snapshotFile : findSnapshots(foreignSourceRepository, foreignSource)) {
        if (newest == null || isNewer(snapshotFile, newest.getDate())) {
            newest = JaxbUtils.unmarshal(Requisition.class, snapshotFile);
            newest.setResource(new FileSystemResource(snapshotFile));
        }
    }
    return newest;
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition)

Example 15 with Requisition

use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.

the class QueueingForeignSourceRepositoryTest method createRequisition.

private Requisition createRequisition() throws Exception {
    Requisition r = m_foreignSourceRepository.importResourceRequisition(new ClassPathResource("/requisition-test.xml"));
    m_foreignSourceRepository.save(r);
    m_foreignSourceRepository.flush();
    return r;
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)70 Test (org.junit.Test)31 RequisitionNode (org.opennms.netmgt.provision.persist.requisition.RequisitionNode)16 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)11 RequisitionInterface (org.opennms.netmgt.provision.persist.requisition.RequisitionInterface)11 UrlResource (org.springframework.core.io.UrlResource)10 File (java.io.File)9 OnmsNodeRequisition (org.opennms.netmgt.provision.persist.OnmsNodeRequisition)8 Resource (org.springframework.core.io.Resource)8 IOException (java.io.IOException)6 RequisitionCategory (org.opennms.netmgt.provision.persist.requisition.RequisitionCategory)6 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)5 InetAddress (java.net.InetAddress)4 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStream (java.io.InputStream)3 RemoteException (java.rmi.RemoteException)3 Date (java.util.Date)3