Search in sources :

Example 1 with MockMessageConsumerManager

use of org.opennms.core.ipc.sink.mock.MockMessageConsumerManager in project opennms by OpenNMS.

the class TrapdConfigReloadIT method addServicesOnStartup.

@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    final RestClient client;
    try {
        client = mock(RestClient.class);
        when(client.getSnmpV3Users()).thenReturn("<?xml version='1.0'?>" + "<trapd-configuration xmlns='http://xmlns.opennms.org/xsd/config/trapd' snmp-trap-address='127.0.0.1' snmp-trap-port='10500' new-suspect-on-trap='true'>" + "     <snmpv3-user security-name='opennms' security-level='0' auth-protocol='MD5' auth-passphrase='0p3nNMSv3' privacy-protocol='DES' privacy-passphrase='0p3nNMSv3' />" + "</trapd-configuration>");
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
    // add mocked services to osgi mocked container (Felix Connect)
    services.put(RestClient.class.getName(), asService(client, null, null));
    services.put(MessageConsumerManager.class.getName(), asService(new MockMessageConsumerManager(), null, null));
    services.put(MessageDispatcherFactory.class.getName(), asService(new MockMessageDispatcherFactory<>(), null, null));
    services.put(DistPollerDao.class.getName(), asService(distPollerDao, null, null));
}
Also used : DistPollerDao(org.opennms.netmgt.dao.api.DistPollerDao) MockMessageDispatcherFactory(org.opennms.core.ipc.sink.mock.MockMessageDispatcherFactory) RestClient(org.opennms.minion.core.api.RestClient) MockMessageConsumerManager(org.opennms.core.ipc.sink.mock.MockMessageConsumerManager) MessageDispatcherFactory(org.opennms.core.ipc.sink.api.MessageDispatcherFactory) MockMessageDispatcherFactory(org.opennms.core.ipc.sink.mock.MockMessageDispatcherFactory) MockMessageConsumerManager(org.opennms.core.ipc.sink.mock.MockMessageConsumerManager) MessageConsumerManager(org.opennms.core.ipc.sink.api.MessageConsumerManager)

Example 2 with MockMessageConsumerManager

use of org.opennms.core.ipc.sink.mock.MockMessageConsumerManager in project opennms by OpenNMS.

the class TrapdSinkPatternWiringIT method addServicesOnStartup.

@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    final MessageDispatcherFactory mockMessageDispatcherFactory = mock(MessageDispatcherFactory.class);
    when(mockMessageDispatcherFactory.createAsyncDispatcher(Mockito.any(TrapSinkModule.class))).thenAnswer(invocation -> {
        messageProcessedLatch.countDown();
        return mock(MessageProducer.class);
    });
    // add mocked services to osgi mocked container (Felix Connect)
    services.put(MessageConsumerManager.class.getName(), asService(new MockMessageConsumerManager(), null, null));
    services.put(MessageDispatcherFactory.class.getName(), asService(mockMessageDispatcherFactory, null, null));
    services.put(RestClient.class.getName(), asService(mock(RestClient.class), null, null));
    services.put(DistPollerDao.class.getName(), asService(distPollerDao, null, null));
}
Also used : DistPollerDao(org.opennms.netmgt.dao.api.DistPollerDao) RestClient(org.opennms.minion.core.api.RestClient) MockMessageConsumerManager(org.opennms.core.ipc.sink.mock.MockMessageConsumerManager) MessageDispatcherFactory(org.opennms.core.ipc.sink.api.MessageDispatcherFactory) MessageConsumerManager(org.opennms.core.ipc.sink.api.MessageConsumerManager) MockMessageConsumerManager(org.opennms.core.ipc.sink.mock.MockMessageConsumerManager)

Aggregations

MessageConsumerManager (org.opennms.core.ipc.sink.api.MessageConsumerManager)2 MessageDispatcherFactory (org.opennms.core.ipc.sink.api.MessageDispatcherFactory)2 MockMessageConsumerManager (org.opennms.core.ipc.sink.mock.MockMessageConsumerManager)2 RestClient (org.opennms.minion.core.api.RestClient)2 DistPollerDao (org.opennms.netmgt.dao.api.DistPollerDao)2 MockMessageDispatcherFactory (org.opennms.core.ipc.sink.mock.MockMessageDispatcherFactory)1