Search in sources :

Example 1 with CreateSHSIMPINCResponseType

use of com.ibm.maximo.CreateSHSIMPINCResponseType in project opennms by OpenNMS.

the class TsrmMockTest method testSaveWithMock.

@Test
public void testSaveWithMock() throws PluginException {
    CreateSHSIMPINCType createIncidentType = new CreateSHSIMPINCType();
    CreateSHSIMPINCResponseType incidentResponse = new CreateSHSIMPINCResponseType();
    INCIDENTMboKeySetType incidentMboKeyType = new INCIDENTMboKeySetType();
    INCIDENTKeyType incidentKey = new INCIDENTKeyType();
    MXStringType incidentId = new MXStringType();
    incidentId.setValue(INCIDENT_ID);
    incidentKey.setTICKETID(incidentId);
    incidentResponse.setINCIDENTMboKeySet(incidentMboKeyType);
    incidentMboKeyType.getINCIDENT().add(incidentKey);
    when(port.createSHSIMPINC(argThat(new CreateIncidentArg()))).thenReturn(incidentResponse);
    port.createSHSIMPINC(createIncidentType);
    Ticket ticket = new Ticket();
    m_ticketer.saveOrUpdate(ticket);
    verify(port).createSHSIMPINC(createIncidentType);
    assertEquals(ticket.getId(), INCIDENT_ID);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) CreateSHSIMPINCType(com.ibm.maximo.CreateSHSIMPINCType) INCIDENTMboKeySetType(com.ibm.maximo.INCIDENTMboKeySetType) INCIDENTKeyType(com.ibm.maximo.INCIDENTKeyType) CreateSHSIMPINCResponseType(com.ibm.maximo.CreateSHSIMPINCResponseType) MXStringType(com.ibm.maximo.MXStringType) Test(org.junit.Test)

Example 2 with CreateSHSIMPINCResponseType

use of com.ibm.maximo.CreateSHSIMPINCResponseType in project opennms by OpenNMS.

the class TsrmTicketerPlugin method saveOrUpdate.

@Override
public void saveOrUpdate(Ticket ticket) throws PluginException {
    LOG.debug("saveOrUpdate called with ticket: {}", ticket);
    String ticketId = ticket.getId();
    if (StringUtils.isEmpty(ticketId)) {
        SHSIMPINCINCIDENTType incident = new SHSIMPINCINCIDENTType();
        updateIncidentWithTicket(incident, ticket);
        SHSIMPINCSetType incSetType = new SHSIMPINCSetType();
        List<SHSIMPINCINCIDENTType> incidentList = incSetType.getINCIDENT();
        incidentList.add(incident);
        CreateSHSIMPINCType createIncidentType = new CreateSHSIMPINCType();
        createIncidentType.setSHSIMPINCSet(incSetType);
        CreateSHSIMPINCResponseType response = port.createSHSIMPINC(createIncidentType);
        if (response != null) {
            List<INCIDENTKeyType> incidentKeyList = response.getINCIDENTMboKeySet().getINCIDENT();
            if (!CollectionUtils.isEmpty(incidentKeyList)) {
                // Response will only have one element in the list
                INCIDENTKeyType incidentKey = incidentKeyList.get(0);
                ticket.setId(incidentKey.getTICKETID().getValue());
            }
        }
    } else {
        SHSIMPINCQueryType queryType = new SHSIMPINCQueryType();
        SHSIMPINCQueryType.INCIDENT incidentQuery = new SHSIMPINCQueryType.INCIDENT();
        List<MXStringQueryType> ticketList = incidentQuery.getTICKETID();
        MXStringQueryType ticketQuery = new MXStringQueryType();
        ticketQuery.setValue(ticketId);
        ticketList.add(ticketQuery);
        queryType.setINCIDENT(incidentQuery);
        QuerySHSIMPINCType queryIncident = new QuerySHSIMPINCType();
        queryIncident.setSHSIMPINCQuery(queryType);
        QuerySHSIMPINCResponseType response = port.querySHSIMPINC(queryIncident);
        if (!CollectionUtils.isEmpty(response.getSHSIMPINCSet().getINCIDENT())) {
            // Response will only have one element in the list
            SHSIMPINCINCIDENTType incident = response.getSHSIMPINCSet().getINCIDENT().get(0);
            updateIncidentWithTicket(incident, ticket);
            UpdateSHSIMPINCType updateIncident = new UpdateSHSIMPINCType();
            SHSIMPINCSetType updateIncidentType = new SHSIMPINCSetType();
            updateIncidentType.getINCIDENT().add(incident);
            updateIncident.setSHSIMPINCSet(updateIncidentType);
            port.updateSHSIMPINC(updateIncident);
        }
    }
}
Also used : QuerySHSIMPINCResponseType(com.ibm.maximo.QuerySHSIMPINCResponseType) SHSIMPINCSetType(com.ibm.maximo.SHSIMPINCSetType) MXStringQueryType(com.ibm.maximo.MXStringQueryType) UpdateSHSIMPINCType(com.ibm.maximo.UpdateSHSIMPINCType) CreateSHSIMPINCResponseType(com.ibm.maximo.CreateSHSIMPINCResponseType) QuerySHSIMPINCType(com.ibm.maximo.QuerySHSIMPINCType) CreateSHSIMPINCType(com.ibm.maximo.CreateSHSIMPINCType) SHSIMPINCQueryType(com.ibm.maximo.SHSIMPINCQueryType) INCIDENTKeyType(com.ibm.maximo.INCIDENTKeyType) SHSIMPINCINCIDENTType(com.ibm.maximo.SHSIMPINCINCIDENTType)

Aggregations

CreateSHSIMPINCResponseType (com.ibm.maximo.CreateSHSIMPINCResponseType)2 CreateSHSIMPINCType (com.ibm.maximo.CreateSHSIMPINCType)2 INCIDENTKeyType (com.ibm.maximo.INCIDENTKeyType)2 INCIDENTMboKeySetType (com.ibm.maximo.INCIDENTMboKeySetType)1 MXStringQueryType (com.ibm.maximo.MXStringQueryType)1 MXStringType (com.ibm.maximo.MXStringType)1 QuerySHSIMPINCResponseType (com.ibm.maximo.QuerySHSIMPINCResponseType)1 QuerySHSIMPINCType (com.ibm.maximo.QuerySHSIMPINCType)1 SHSIMPINCINCIDENTType (com.ibm.maximo.SHSIMPINCINCIDENTType)1 SHSIMPINCQueryType (com.ibm.maximo.SHSIMPINCQueryType)1 SHSIMPINCSetType (com.ibm.maximo.SHSIMPINCSetType)1 UpdateSHSIMPINCType (com.ibm.maximo.UpdateSHSIMPINCType)1 Test (org.junit.Test)1 Ticket (org.opennms.api.integration.ticketing.Ticket)1