use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class TsrmMockTest method testGetWithMock.
@Test
public void testGetWithMock() throws PluginException {
QuerySHSIMPINCType queryIncident = new QuerySHSIMPINCType();
QuerySHSIMPINCResponseType queryResponse = new QuerySHSIMPINCResponseType();
SHSIMPINCSetType queryType = new SHSIMPINCSetType();
SHSIMPINCINCIDENTType queryIncidentType = new SHSIMPINCINCIDENTType();
MXStringType incidentId = new MXStringType();
incidentId.setValue(INCIDENT_ID);
queryIncidentType.setTICKETID(incidentId);
queryType.getINCIDENT().add(queryIncidentType);
queryResponse.setSHSIMPINCSet(queryType);
when(port.querySHSIMPINC(argThat(new QueryIncidentArg()))).thenReturn(queryResponse);
port.querySHSIMPINC(queryIncident);
Ticket ticket = m_ticketer.get(INCIDENT_ID);
verify(port).querySHSIMPINC(queryIncident);
assertEquals(ticket.getId(), INCIDENT_ID);
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class TsrmTicketerPluginTest method testForValidatingSaveAndUpdatedTicket.
@Test
@Ignore
public void testForValidatingSaveAndUpdatedTicket() throws PluginException {
Ticket ticket = new Ticket();
ticket.addAttribute("location", "OPENNMS");
ticket.setDetails("OpenNMS Description");
ticket.addAttribute("classStructureId", "1012");
// When creating NOC_EU as owner group, updating INCIDENT doesn't work
// ticket.addAttribute("ownergroup", "NOC_EU");
ticket.addAttribute("siteId", "SHSEU");
ticket.addAttribute("source", "OpenNMS");
ticket.addAttribute("classId", "INCIDENT");
ticket.setUser("openNMS");
ticket.setSummary("openNMS summary");
ticket.setState(Ticket.State.OPEN);
ticket.addAttribute("shsReasonForOutage", "failure");
ticket.addAttribute("shsRoomNumber", "Room 21");
tsrmTicket.saveOrUpdate(ticket);
assertNotNull(ticket.getId());
Ticket newTicket = tsrmTicket.get(ticket.getId());
newTicket.setState(Ticket.State.CLOSED);
newTicket.setSummary("new openNMS summary");
newTicket.setDetails("new OpenNMS Description");
newTicket.setUser("oNMS");
tsrmTicket.saveOrUpdate(newTicket);
Ticket newerTicket = tsrmTicket.get(newTicket.getId());
// When retrieving state, comes as NEW
// assertEquals(newTicket.getState(), newerTicket.getState());
assertEquals(newTicket.getSummary(), newerTicket.getSummary());
assertEquals(newTicket.getDetails(), newerTicket.getDetails());
assertEquals(newTicket.getUser(), newerTicket.getUser());
assertEquals(ticket.getAttribute("siteId"), newerTicket.getAttribute("siteId"));
assertEquals(ticket.getAttribute("source"), newerTicket.getAttribute("source"));
assertEquals(ticket.getAttribute("location"), newerTicket.getAttribute("location"));
assertEquals(ticket.getAttribute("shsRoomNumber"), newerTicket.getAttribute("shsRoomNumber"));
assertEquals(ticket.getAttribute("shsReasonForOutage"), newerTicket.getAttribute("shsReasonForOutage"));
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class RtTicketerPluginTest method testSaveAndGet.
public void testSaveAndGet() {
try {
m_ticketer.saveOrUpdate(m_ticket);
Ticket retrievedTicket = m_ticketer.get(m_ticket.getId());
assertTicketEquals(m_ticket, retrievedTicket);
} catch (final PluginException e) {
e.printStackTrace();
fail("Something failed in the ticketer plugin");
}
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class DroolsTicketerServiceLayerTest method expectNewTicket.
private void expectNewTicket() throws PluginException {
m_ticketerPlugin.saveOrUpdate(EasyMock.isA(Ticket.class));
EasyMock.expectLastCall().andAnswer(() -> {
Ticket ticket = (Ticket) EasyMock.getCurrentArguments()[0];
assertNull(ticket.getId());
ticket.setId("7");
// Verify the properties as generated by the Drools engine
assertEquals("Not Test Logmsg", ticket.getSummary());
assertEquals("Not Test Description", ticket.getDetails());
assertEquals("Jesse", ticket.getUser());
assertEquals(ImmutableMap.of("custom-key", "custom-value"), ticket.getAttributes());
return null;
});
}
use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.
the class DefaultTicketerServiceLayer method setTicketState.
private void setTicketState(String ticketId, State state) throws PluginException {
try {
Ticket ticket = m_ticketerPlugin.get(ticketId);
ticket.setState(state);
m_ticketerPlugin.saveOrUpdate(ticket);
} catch (PluginException e) {
LOG.error("Unable to set ticket state");
throw e;
}
}
Aggregations