Search in sources :

Example 1 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class DroolsTicketerServiceLayerTest method setUp.

@Before
public void setUp() throws Exception {
    m_eventIpcManager = new MockEventIpcManager();
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    MockLogAppender.setupLogging();
    ResourceLoader loader = new DefaultResourceLoader();
    Resource resource = loader.getResource("classpath:/drools-ticketer-rules.drl");
    m_easyMockUtils = new EasyMockUtils();
    m_configDao = m_easyMockUtils.createMock(DroolsTicketerConfigDao.class);
    EasyMock.expect(m_configDao.getRulesFile()).andReturn(resource.getFile()).times(1);
    EasyMock.replay(m_configDao);
    m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
    m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
    m_droolsTicketerServiceLayer = new DroolsTicketerServiceLayer(m_configDao);
    m_droolsTicketerServiceLayer.setAlarmDao(m_alarmDao);
    m_droolsTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
    EasyMock.reset(m_configDao);
    m_alarm = new OnmsAlarm();
    m_alarm.setId(1);
    m_alarm.setLogMsg("Test Logmsg");
    m_alarm.setDescription("Test Description");
    m_alarm.setUei("uei.opennms.org/nodes/nodeDown");
    m_ticket = new Ticket();
    m_ticket.setId("4");
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Ticket(org.opennms.api.integration.ticketing.Ticket) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Resource(org.springframework.core.io.Resource) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Plugin(org.opennms.api.integration.ticketing.Plugin) Before(org.junit.Before)

Example 2 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class QuickBaseTicketerPluginTest method testSave.

public void testSave() {
    Ticket ticket = new Ticket();
    ticket.setState(Ticket.State.OPEN);
    ticket.setSummary("This is the summary");
    ticket.setDetails("These are the details");
    m_ticketer.saveOrUpdate(ticket);
    assertNotNull(ticket.getId());
    Ticket newTicket = m_ticketer.get(ticket.getId());
    assertNotNull(newTicket);
    assertTicketEquals(ticket, newTicket);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket)

Example 3 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class QuickBaseTicketerPlugin method get.

public Ticket get(String ticketId) {
    try {
        Properties props = getProperties();
        MyQuickBaseClient qdb = createClient(getUserName(props), getPassword(props), getUrl(props));
        String dbId = qdb.findDbByName(getApplicationName(props));
        HashMap<String, String> record = qdb.getRecordInfo(dbId, ticketId);
        Ticket ticket = new Ticket();
        ticket.setId(ticketId);
        ticket.setModificationTimestamp(record.get(getModificationTimeStampFile(props)));
        ticket.setSummary(record.get(getSummaryField(props)));
        ticket.setDetails(record.get(getDetailsField(props)));
        ticket.setState(getTicketStateValue(record.get(getStateField(props)), props));
        return ticket;
    } catch (Throwable e) {
        throw new DataRetrievalFailureException("Failed to commit QuickBase transaction: " + e.getMessage(), e);
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) Properties(java.util.Properties)

Example 4 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class QuickBaseTicketerPluginTest method testUpdate.

public void testUpdate() throws Exception {
    String summary = "A Ticket at " + new Date();
    Ticket ticket = new Ticket();
    ticket.setState(Ticket.State.OPEN);
    ticket.setSummary(summary);
    ticket.setDetails("Ticket details for ticket: " + new Date());
    m_ticketer.saveOrUpdate(ticket);
    assertNotNull(ticket.getId());
    Ticket newTicket = m_ticketer.get(ticket.getId());
    assertNotNull(newTicket);
    assertTicketEquals(ticket, newTicket);
    newTicket.setState(Ticket.State.CANCELLED);
    newTicket.setDetails("These details have changed");
    System.err.println("TicketId = " + newTicket.getId());
    m_ticketer.saveOrUpdate(newTicket);
    Thread.sleep(500);
    Ticket newerTicket = m_ticketer.get(newTicket.getId());
    assertTicketEquals(newTicket, newerTicket);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) Date(java.util.Date)

Example 5 with Ticket

use of org.opennms.api.integration.ticketing.Ticket in project opennms by OpenNMS.

the class RtTicketerPluginTest method setUp.

@Override
protected void setUp() throws Exception {
    final String testHome = System.getProperty("user.home") + File.separatorChar + ".opennms" + File.separatorChar + "test-home";
    final File testProp = new File(testHome + File.separatorChar + "etc" + File.separatorChar + "rt.properties");
    if (testProp.exists()) {
        LOG.debug("{} exists, using it instead of src/test/opennms-home", testHome);
        System.setProperty("opennms.home", testHome);
    } else {
        System.setProperty("opennms.home", "src" + File.separatorChar + "test" + File.separatorChar + "opennms-home");
    }
    m_ticketer = new RtTicketerPlugin();
    m_ticket = new Ticket();
    m_ticket.setState(Ticket.State.OPEN);
    m_ticket.setSummary("Ticket Summary for ticket: " + new Date());
    m_ticket.setDetails("First Article for ticket: " + new Date());
    m_ticket.setUser("root@localhost");
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) File(java.io.File) Date(java.util.Date)

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