Search in sources :

Example 41 with Ticket

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);
}
Also used : QuerySHSIMPINCResponseType(com.ibm.maximo.QuerySHSIMPINCResponseType) Ticket(org.opennms.api.integration.ticketing.Ticket) SHSIMPINCSetType(com.ibm.maximo.SHSIMPINCSetType) QuerySHSIMPINCType(com.ibm.maximo.QuerySHSIMPINCType) MXStringType(com.ibm.maximo.MXStringType) SHSIMPINCINCIDENTType(com.ibm.maximo.SHSIMPINCINCIDENTType) Test(org.junit.Test)

Example 42 with Ticket

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"));
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 43 with Ticket

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");
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 44 with Ticket

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;
    });
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket)

Example 45 with Ticket

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;
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) PluginException(org.opennms.api.integration.ticketing.PluginException)

Aggregations

Ticket (org.opennms.api.integration.ticketing.Ticket)46 PluginException (org.opennms.api.integration.ticketing.PluginException)15 Date (java.util.Date)9 Test (org.junit.Test)7 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)4 MXStringType (com.ibm.maximo.MXStringType)3 Properties (java.util.Properties)3 Plugin (org.opennms.api.integration.ticketing.Plugin)3 DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)3 BasicIssue (com.atlassian.jira.rest.client.api.domain.BasicIssue)2 Issue (com.atlassian.jira.rest.client.api.domain.Issue)2 QuerySHSIMPINCResponseType (com.ibm.maximo.QuerySHSIMPINCResponseType)2 QuerySHSIMPINCType (com.ibm.maximo.QuerySHSIMPINCType)2 SHSIMPINCINCIDENTType (com.ibm.maximo.SHSIMPINCINCIDENTType)2 File (java.io.File)2 IOException (java.io.IOException)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Ignore (org.junit.Ignore)2