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!"));
}
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);
}
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);
}
Aggregations