OpenNMS API 1.2.9

## org.opennms.netmgt.mock
Class MockDatabase

    java.lang.Object
      org.opennms.netmgt.mock.MockDatabase

All Implemented Interfaces:
  DbConnectionFactory, EventWriter

public class MockDatabase
extends java.lang.Object
implements DbConnectionFactory, EventWriter

In memory database comparable to the postgres database that can be used for unit testing. Can be populated from a MockNetwork

Author:
  brozow

Field Summary
`private org.hsqldb.Server` `m_server`

Constructor Summary
`MockDatabase()`

Method Summary
`void` `acknowledgeNoticesForEvent(Event e)`
`java.sql.Timestamp` `convertEventTimeToTimeStamp(java.lang.String time)`
`int` `countOpenOutages()`
`int` `countOpenOutagesForInterface(MockInterface iface)`
`int` `countOpenOutagesForService(MockService svc)`
`int` `countOutages()`
`int` `countOutages(java.lang.String criteria)`
`int` `countOutagesForInterface(MockInterface iface)`
`int` `countOutagesForInterface(MockInterface iface, java.lang.String criteria)`
`int` `countOutagesForService(MockService svc)`
`int` `countOutagesForService(MockService svc, java.lang.String criteria)`
`int` `countRows(java.lang.String sql)`
`int` `countRows(java.lang.String sql, java.lang.Object[] values)`
`void` `create()`
`void` `createOutage(MockService svc, Event svcLostEvent)`
`void` `createOutage(MockService svc, int eventId, java.sql.Timestamp time)`
`void` `drop()`
`java.util.Collection` `findNoticesForEvent(Event event)`
`java.util.Collection` `getClosedOutages(MockService svc)`
`java.sql.Connection` `getConnection()` Return a new database connection to the database configured in the `opennms-database.xml`.
`char` `getInterfaceStatus(MockInterface iface)`
`java.lang.Integer` `getNextEventId()`
`java.lang.String` `getNextEventIdStatement()`
`private java.lang.Integer` `getNextId(java.lang.String nxtIdStmt)`
`java.lang.String` `getNextNotifIdSql()`
`java.lang.Integer` `getNextOutageId()`
`java.lang.String` `getNextOutageIdStatement()`
`java.util.Collection` `getOpenOutages(MockService svc)`
`java.util.Collection` `getOutages()`
`java.util.Collection` `getOutages(MockService svc)`
`java.util.Collection` `getOutages(java.lang.String criteria, java.lang.Object[] values)`
`java.lang.Integer` `getServiceID(java.lang.String serviceName)`
`java.lang.String` `getServiceName(int serviceId)`
`char` `getServiceStatus(MockService svc)`
`boolean` `hasOpenOutage(MockService svc)`
`void` `populate(MockNetwork network)`
`void` `reparentInterface(java.lang.String ipAddr, int oldNode, int newNode)`
`void` `resolveOutage(MockService svc, Event svcRegainEvent)`
`void` `resolveOutage(MockService svc, int eventId, java.sql.Timestamp timestamp)`
`private boolean` `serviceDefined(java.lang.String svcName)`
`void` `setInterfaceStatus(MockInterface iface, char newStatus)`
`void` `setServiceStatus(MockService svc, char newStatus)`
`void` `startServer()`
`void` `update(java.lang.String sql)`
`void` `update(java.lang.String stmt, java.lang.Object[] values)`
`void` `writeEvent(Event e)`
`void` `writeInterface(MockInterface iface)`
`void` `writeNode(MockNode node)`
`void` `writeService(MockService svc)`
`void` `writeSnmpInterface(MockInterface iface)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_server

    private org.hsqldb.Server m_server

Constructor Detail

### MockDatabase

    public MockDatabase()

Method Detail

### create

    public void create()

### startServer

    public void startServer()

### drop

    public void drop()

### populate

    public void populate(MockNetwork network)

### writeNode

    public void writeNode(MockNode node)

### getConnection

    public java.sql.Connection getConnection()
                                      throws java.sql.SQLException

  Description copied from interface: `DbConnectionFactory`
  Return a new database connection to the database configured in the `opennms-database.xml`. The database connection is not managed by the factory and must be release by the caller by using the `close` method.

  Specified by:
    `getConnection` in interface `DbConnectionFactory`
  Returns:
    a new database connection to the database configured in the `opennms-database.xml`
  Throws:
    `java.sql.SQLException` - Thrown if there is an error opening the connection to the database.

### update

    public void update(java.lang.String sql)

### update

    public void update(java.lang.String stmt,
                       java.lang.Object[] values)

### writeInterface

    public void writeInterface(MockInterface iface)

### writeSnmpInterface

    public void writeSnmpInterface(MockInterface iface)

### writeService

    public void writeService(MockService svc)

### countRows

    public int countRows(java.lang.String sql)

### countRows

    public int countRows(java.lang.String sql,
                         java.lang.Object[] values)

### serviceDefined

    private boolean serviceDefined(java.lang.String svcName)

### getNextOutageIdStatement

    public java.lang.String getNextOutageIdStatement()

### getNextOutageId

    public java.lang.Integer getNextOutageId()

### getNextId

    private java.lang.Integer getNextId(java.lang.String nxtIdStmt)

### getNextEventIdStatement

    public java.lang.String getNextEventIdStatement()

### getNextEventId

    public java.lang.Integer getNextEventId()

### getServiceID

    public java.lang.Integer getServiceID(java.lang.String serviceName)

### getServiceName

    public java.lang.String getServiceName(int serviceId)

### countOutagesForService

    public int countOutagesForService(MockService svc)

### countOpenOutagesForService

    public int countOpenOutagesForService(MockService svc)

### countOutagesForService

    public int countOutagesForService(MockService svc,
                                      java.lang.String criteria)

### createOutage

    public void createOutage(MockService svc,
                             Event svcLostEvent)

### createOutage

    public void createOutage(MockService svc,
                             int eventId,
                             java.sql.Timestamp time)

### resolveOutage

    public void resolveOutage(MockService svc,
                              Event svcRegainEvent)

### resolveOutage

    public void resolveOutage(MockService svc,
                              int eventId,
                              java.sql.Timestamp timestamp)

### convertEventTimeToTimeStamp

    public java.sql.Timestamp convertEventTimeToTimeStamp(java.lang.String time)

### writeEvent

    public void writeEvent(Event e)

  Specified by:
    `writeEvent` in interface `EventWriter`
  Parameters:
    `e` -

### setServiceStatus

    public void setServiceStatus(MockService svc,
                                 char newStatus)

### getServiceStatus

    public char getServiceStatus(MockService svc)

### setInterfaceStatus

    public void setInterfaceStatus(MockInterface iface,
                                   char newStatus)

### getInterfaceStatus

    public char getInterfaceStatus(MockInterface iface)

### countOutages

    public int countOutages()

### countOpenOutages

    public int countOpenOutages()

### countOutages

    public int countOutages(java.lang.String criteria)

### countOutagesForInterface

    public int countOutagesForInterface(MockInterface iface)

### countOpenOutagesForInterface

    public int countOpenOutagesForInterface(MockInterface iface)

### countOutagesForInterface

    public int countOutagesForInterface(MockInterface iface,
                                        java.lang.String criteria)

### hasOpenOutage

    public boolean hasOpenOutage(MockService svc)

### getOutages

    public java.util.Collection getOutages()

### getOutages

    public java.util.Collection getOutages(java.lang.String criteria,
                                           java.lang.Object[] values)

### getOpenOutages

    public java.util.Collection getOpenOutages(MockService svc)

### getOutages

    public java.util.Collection getOutages(MockService svc)

### getClosedOutages

    public java.util.Collection getClosedOutages(MockService svc)

### reparentInterface

    public void reparentInterface(java.lang.String ipAddr,
                                  int oldNode,
                                  int newNode)

  Parameters:
    `ipAddr` -

### getNextNotifIdSql

    public java.lang.String getNextNotifIdSql()

  Returns:

### acknowledgeNoticesForEvent

    public void acknowledgeNoticesForEvent(Event e)

  Parameters:
    `e` -

### findNoticesForEvent

    public java.util.Collection findNoticesForEvent(Event event)

  Parameters:
    `event` -
  Returns:

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.