use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class DroolsTicketerServiceLayerTest method setUp.
@Before
public void setUp() throws Exception {
m_eventIpcManager = new MockEventIpcManager();
EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
MockLogAppender.setupLogging();
ResourceLoader loader = new DefaultResourceLoader();
Resource resource = loader.getResource("classpath:/drools-ticketer-rules.drl");
m_easyMockUtils = new EasyMockUtils();
m_configDao = m_easyMockUtils.createMock(DroolsTicketerConfigDao.class);
EasyMock.expect(m_configDao.getRulesFile()).andReturn(resource.getFile()).times(1);
EasyMock.replay(m_configDao);
m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
m_droolsTicketerServiceLayer = new DroolsTicketerServiceLayer(m_configDao);
m_droolsTicketerServiceLayer.setAlarmDao(m_alarmDao);
m_droolsTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
EasyMock.reset(m_configDao);
m_alarm = new OnmsAlarm();
m_alarm.setId(1);
m_alarm.setLogMsg("Test Logmsg");
m_alarm.setDescription("Test Description");
m_alarm.setUei("uei.opennms.org/nodes/nodeDown");
m_ticket = new Ticket();
m_ticket.setId("4");
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class QuickBaseTicketerPluginTest method testSave.
public void testSave() {
Ticket ticket = new Ticket();
ticket.setState(Ticket.State.OPEN);
ticket.setSummary("This is the summary");
ticket.setDetails("These are the details");
m_ticketer.saveOrUpdate(ticket);
assertNotNull(ticket.getId());
Ticket newTicket = m_ticketer.get(ticket.getId());
assertNotNull(newTicket);
assertTicketEquals(ticket, newTicket);
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class QuickBaseTicketerPlugin method get.
public Ticket get(String ticketId) {
try {
Properties props = getProperties();
MyQuickBaseClient qdb = createClient(getUserName(props), getPassword(props), getUrl(props));
String dbId = qdb.findDbByName(getApplicationName(props));
HashMap<String, String> record = qdb.getRecordInfo(dbId, ticketId);
Ticket ticket = new Ticket();
ticket.setId(ticketId);
ticket.setModificationTimestamp(record.get(getModificationTimeStampFile(props)));
ticket.setSummary(record.get(getSummaryField(props)));
ticket.setDetails(record.get(getDetailsField(props)));
ticket.setState(getTicketStateValue(record.get(getStateField(props)), props));
return ticket;
} catch (Throwable e) {
throw new DataRetrievalFailureException("Failed to commit QuickBase transaction: " + e.getMessage(), e);
}
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class QuickBaseTicketerPluginTest method testUpdate.
public void testUpdate() throws Exception {
String summary = "A Ticket at " + new Date();
Ticket ticket = new Ticket();
ticket.setState(Ticket.State.OPEN);
ticket.setSummary(summary);
ticket.setDetails("Ticket details for ticket: " + new Date());
m_ticketer.saveOrUpdate(ticket);
assertNotNull(ticket.getId());
Ticket newTicket = m_ticketer.get(ticket.getId());
assertNotNull(newTicket);
assertTicketEquals(ticket, newTicket);
newTicket.setState(Ticket.State.CANCELLED);
newTicket.setDetails("These details have changed");
System.err.println("TicketId = " + newTicket.getId());
m_ticketer.saveOrUpdate(newTicket);
Thread.sleep(500);
Ticket newerTicket = m_ticketer.get(newTicket.getId());
assertTicketEquals(newTicket, newerTicket);
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class RtTicketerPluginTest method setUp.
@Override
protected void setUp() throws Exception {
final String testHome = System.getProperty("user.home") + File.separatorChar + ".opennms" + File.separatorChar + "test-home";
final File testProp = new File(testHome + File.separatorChar + "etc" + File.separatorChar + "rt.properties");
if (testProp.exists()) {
LOG.debug("{} exists, using it instead of src/test/opennms-home", testHome);
System.setProperty("opennms.home", testHome);
} else {
System.setProperty("opennms.home", "src" + File.separatorChar + "test" + File.separatorChar + "opennms-home");
}
m_ticketer = new RtTicketerPlugin();
m_ticket = new Ticket();
m_ticket.setState(Ticket.State.OPEN);
m_ticket.setSummary("Ticket Summary for ticket: " + new Date());
m_ticket.setDetails("First Article for ticket: " + new Date());
m_ticket.setUser("root@localhost");
}
Aggregations