use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class RemedyTicketerPluginTest method setUp.
@Override
protected void setUp() throws Exception {
System.setProperty("opennms.home", "src" + File.separatorChar + "test" + File.separatorChar + "opennms-home");
m_ticketer = new RemedyTicketerPlugin();
m_ticket = new Ticket();
m_ticket.setState(Ticket.State.OPEN);
m_ticket.setSummary("Test OpenNMS Integration");
m_ticket.setDetails("Created by Axis java client. Date: " + new Date());
m_ticket.setUser("antonio@opennms.it");
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class RemedyTicketerPluginTest method testSaveAndGet.
public void testSaveAndGet() {
try {
m_ticketer.saveOrUpdate(m_ticket);
m_ticketId = m_ticket.getId();
Ticket ticket = m_ticketer.get(m_ticketId);
assertEquals(m_ticketId, ticket.getId());
assertEquals(State.OPEN, ticket.getState());
} catch (PluginException e) {
e.printStackTrace();
}
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class Otrs31TicketerPlugin method update.
private void update(Ticket ticketToUpdate) throws PluginException {
Ticket currentTicket = get(ticketToUpdate.getId());
LOG.debug("updating existing ticket : {}", currentTicket.getId());
if (currentTicket.getState() != ticketToUpdate.getState()) {
OTRSTicketUpdateTicket ticketUpdate = new OTRSTicketUpdateTicket();
ticketUpdate.setStateID(openNMSToOTRSState(ticketToUpdate.getState()));
OTRSArticle articleUpdate = new OTRSArticle();
// TODO Figure out why we can't set ArticleFrom without an error from OTRS
// otrsArticle.setFrom(m_configDao.getArticleFrom());
articleUpdate.setSubject(m_configDao.getArticleUpdateSubject());
// All OTRS article fields from defaults
articleUpdate.setArticleType(m_configDao.getArticleType());
articleUpdate.setSenderType(m_configDao.getArticleSenderType());
articleUpdate.setContentType(m_configDao.getArticleContentType());
articleUpdate.setHistoryType(m_configDao.getArticleHistoryType());
articleUpdate.setHistoryComment(m_configDao.getArticleHistoryComment());
switch(ticketToUpdate.getState()) {
case OPEN:
// ticket is new
articleUpdate.setBody(m_configDao.getTicketOpenedMessage());
break;
case CANCELLED:
// not sure how often we see this
articleUpdate.setBody(m_configDao.getTicketCancelledMessage());
break;
case CLOSED:
// closed successful
articleUpdate.setBody(m_configDao.getTicketClosedMessage());
break;
default:
LOG.debug("No valid OpenNMS state on ticket");
articleUpdate.setBody(m_configDao.getTicketUpdatedMessage());
}
TicketUpdate update = new TicketUpdate();
update.setUserLogin(m_configDao.getUserName());
update.setPassword(m_configDao.getPassword());
update.setTicketID(new BigInteger(currentTicket.getId()));
update.setTicket(ticketUpdate);
update.setArticle(articleUpdate);
m_ticketConnector.ticketUpdate(update);
} else {
// There is no else at the moment
// Tickets are _only_ updated with new state
}
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class Otrs31TicketerPluginTest method testOpenAndClose.
@Test
public void testOpenAndClose() throws PluginException {
Ticket ticket = new Ticket();
ticket.setState(Ticket.State.OPEN);
ticket.setSummary("Testing Open and Close Summary: " + new Date());
ticket.setDetails("Testing Open and Close Detail: " + new Date());
//ticket.setUser(DEFAULT_USER);
otrsPlugin.saveOrUpdate(ticket);
Ticket initialOtrsTicket = otrsPlugin.get(ticket.getId());
assertTicketEquals(ticket, initialOtrsTicket);
ticket.setState(Ticket.State.CLOSED);
otrsPlugin.saveOrUpdate(ticket);
Ticket closedOtrsTicket = otrsPlugin.get(ticket.getId());
assertTicketEquals(ticket, closedOtrsTicket);
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class Otrs31TicketerPluginTest method testRemoveMarkup.
@Test
public void testRemoveMarkup() throws PluginException {
Ticket ticket = new Ticket();
ticket.setState(Ticket.State.OPEN);
ticket.setSummary(SUMMARY_MARKUP);
ticket.setDetails("Testing Markup Removal from title: " + new Date());
//ticket.setUser(DEFAULT_USER);
otrsPlugin.saveOrUpdate(ticket);
Ticket initialOtrsTicket = otrsPlugin.get(ticket.getId());
assertEquals(initialOtrsTicket.getSummary(), SUMMARY_NO_MARKUP);
ticket.setState(Ticket.State.CLOSED);
otrsPlugin.saveOrUpdate(ticket);
}
Aggregations