Search in sources :

Example 6 with ScanReport

use of org.opennms.netmgt.model.ScanReport in project opennms by OpenNMS.

the class ScanReportTest method testSerialization.

/**
 * Test the JAXB marshaling of the {@link ScanReport} class.
 */
@Test
public void testSerialization() throws Exception {
    ScanReport report = new ScanReport();
    report.addProperty("customer-account-number", "12345");
    report.addProperty("customer-name", "Zombo.com");
    report.addProperty("reference-id", "ABZ135");
    report.addProperty("time-zone", "-5:00");
    report.setLocale("en-US");
    report.setLocation("RDU");
    report.setTimestamp(new Date());
    report.setLog(new ScanReportLog(report.getId(), "Hey, a log!"));
    for (int i = 0; i < 5; i++) {
        PollStatus status = PollStatus.get(PollStatus.SERVICE_AVAILABLE, "Anything is possible", 4.5d);
        status.setProperty("whatever", 2.0);
        report.addPollResult(new ScanReportPollResult("Foo", 1, "zombonode", 1, "1.2.3.4", status));
    }
    String reportString = JaxbUtils.marshal(report);
    LOG.debug("Report string: \n " + reportString);
    assertTrue(reportString.contains("<key>customer-account-number</key>"));
    assertTrue(reportString.contains("<value>12345</value>"));
    assertTrue(reportString.contains("<key>customer-name</key>"));
    assertTrue(reportString.contains("<value>Zombo.com</value>"));
    assertTrue(reportString.contains("response-time=\"4.5\""));
    // object is not serialized as JAXB/JSON, only to the database
    assertFalse(reportString.contains("a log!"));
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) ScanReportLog(org.opennms.netmgt.model.ScanReportLog) ScanReport(org.opennms.netmgt.model.ScanReport) ScanReportPollResult(org.opennms.netmgt.model.ScanReportPollResult) Date(java.util.Date) Test(org.junit.Test)

Example 7 with ScanReport

use of org.opennms.netmgt.model.ScanReport in project opennms by OpenNMS.

the class CriteriaBuilderSearchVisitorIT method testScanReportTwoConditionsWithIsNotNull.

@Test
public void testScanReportTwoConditionsWithIsNotNull() {
    CriteriaBuilder builder = new ScanReportRestService().getCriteriaBuilder(null);
    CriteriaBuilderSearchVisitor<ScanReport, ScanReport> visitor = new CriteriaBuilderSearchVisitor<>(builder, ScanReport.class);
    visitor.visit(new PrimitiveSearchCondition<ScanReport>("applications", CriteriaBuilderSearchVisitor.NULL_VALUE, String.class, ConditionType.NOT_EQUALS, new ScanReport()));
    visitor.visit(new PrimitiveSearchCondition<ScanReport>("timestamp", new Date(), Date.class, ConditionType.LESS_OR_EQUALS, new ScanReport()));
    Criteria criteria = visitor.getQuery().toCriteria();
    System.out.println(criteria.toString());
    m_dao.countMatching(criteria);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) ScanReport(org.opennms.netmgt.model.ScanReport) Criteria(org.opennms.core.criteria.Criteria) Date(java.util.Date) ScanReportRestService(org.opennms.web.rest.v2.ScanReportRestService) Test(org.junit.Test)

Example 8 with ScanReport

use of org.opennms.netmgt.model.ScanReport in project opennms by OpenNMS.

the class CriteriaBuilderSearchVisitorIT method testScanReportTwoConditionsWithIsNull.

@Test
public void testScanReportTwoConditionsWithIsNull() {
    CriteriaBuilder builder = new ScanReportRestService().getCriteriaBuilder(null);
    CriteriaBuilderSearchVisitor<ScanReport, ScanReport> visitor = new CriteriaBuilderSearchVisitor<>(builder, ScanReport.class);
    visitor.visit(new PrimitiveSearchCondition<ScanReport>("applications", CriteriaBuilderSearchVisitor.NULL_VALUE, String.class, ConditionType.EQUALS, new ScanReport()));
    visitor.visit(new PrimitiveSearchCondition<ScanReport>("timestamp", new Date(), Date.class, ConditionType.LESS_OR_EQUALS, new ScanReport()));
    Criteria criteria = visitor.getQuery().toCriteria();
    System.out.println(criteria.toString());
    m_dao.countMatching(criteria);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) ScanReport(org.opennms.netmgt.model.ScanReport) Criteria(org.opennms.core.criteria.Criteria) Date(java.util.Date) ScanReportRestService(org.opennms.web.rest.v2.ScanReportRestService) Test(org.junit.Test)

Aggregations

ScanReport (org.opennms.netmgt.model.ScanReport)8 Date (java.util.Date)6 Test (org.junit.Test)6 Criteria (org.opennms.core.criteria.Criteria)4 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)4 ScanReportRestService (org.opennms.web.rest.v2.ScanReportRestService)4 ScanReportPollResult (org.opennms.netmgt.model.ScanReportPollResult)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ScanReportLog (org.opennms.netmgt.model.ScanReportLog)2 PollStatus (org.opennms.netmgt.poller.PollStatus)2 InetAddress (java.net.InetAddress)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1