use of com.ibm.maximo.SHSIMPINCSetType 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 com.ibm.maximo.SHSIMPINCSetType 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);
}
}
}
Aggregations