@Test(timeout=300000) @JUnitTemporaryDatabase @Transactional public void testSaveCategoriesOnUpdateNodeAttributes() throws Exception { final String TEST_CATEGORY = "TEST_CATEGORY"; final String OLD_LABEL = "apknd"; final String NEW_LABEL = "apknd-new"; importFromResource("classpath:/tec_dump.xml.smalltest", true); final Collection<OnmsNode> nodes = m_nodeDao.findByLabel(OLD_LABEL); assertNotNull(nodes); assertEquals(1, nodes.size()); OnmsNode node = nodes.iterator().next(); assertNotNull(node); OnmsNode nodeCopy = new OnmsNode(); nodeCopy.setId(node.getId()); nodeCopy.setLabel(OLD_LABEL); nodeCopy.setLabelSource("U"); assertNotSame(node, nodeCopy); assertEquals(OLD_LABEL, node.getLabel()); assertFalse(node.hasCategory(TEST_CATEGORY)); final NodeCategorySettingPolicy policy = new NodeCategorySettingPolicy(); policy.setCategory(TEST_CATEGORY); policy.setLabel(OLD_LABEL); nodeCopy = policy.apply(nodeCopy); assertTrue(nodeCopy.hasCategory(TEST_CATEGORY)); nodeCopy.setLabel(NEW_LABEL); nodeCopy.setLabelSource("U"); assertFalse(node.getLabel().equals(nodeCopy.getLabel())); m_provisionService.updateNodeAttributes(nodeCopy); m_nodeDao.flush(); final OnmsNode node2 = m_nodeDao.findByLabel(NEW_LABEL).iterator().next(); assertTrue(node2.hasCategory(TEST_CATEGORY)); boolean foundEvent = false; for (Log eventLog : ((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).requestPendingEventsList()) { for (Event event : eventLog.getEvents().getEventCollection()) { if (EventConstants.NODE_LABEL_CHANGED_EVENT_UEI.equals(event.getUei())) { foundEvent = true; } } } assertTrue(String.format("Did not find anticipated %s event", EventConstants.NODE_LABEL_CHANGED_EVENT_UEI), foundEvent); }
public EventForwarder getEventForwarder() { return m_eventForwarder; }
Provisioner implements SpringServiceDaemon { public EventForwarder getEventForwarder() { return m_eventForwarder; } }
Provisioner implements SpringServiceDaemon { public EventForwarder getEventForwarder() { return m_eventForwarder; }  }
Provisioner implements SpringServiceDaemon { public EventForwarder getEventForwarder() { return m_eventForwarder; }  void setProvisionService(ProvisionService provisionService); ProvisionService getProvisionService(); void setScheduledExecutor(ScheduledExecutorService scheduledExecutor); void setLifeCycleRepository(LifeCycleRepository lifeCycleRepository); void setImportSchedule(ImportScheduler schedule); void setImportActivities(CoreImportActivities importActivities); void setTaskCoordinator(DefaultTaskCoordinator taskCoordinator); void setAgentConfigFactory(SnmpAgentConfigFactory agentConfigFactory); ImportScheduler getImportSchedule(); @Override void start(); @Override void destroy(); @Override void afterPropertiesSet(); void doNodeScan(int nodeId); NodeScan createNodeScan(Integer nodeId, String foreignSource, String foreignId); NewSuspectScan createNewSuspectScan(InetAddress ipAddress); ScheduledFuture<?> getScheduledFutureForNode(int nodeId); int getScheduleLength(); ThreadCategory log(); void setEventForwarder(EventForwarder eventForwarder); EventForwarder getEventForwarder(); void doImport(); @EventHandler(uei = EventConstants.RELOAD_IMPORT_UEI) void doImport(final Event event); void doImport(final String url, final boolean rescanExisting); @EventHandler(uei = EventConstants.NODE_ADDED_EVENT_UEI) void handleNodeAddedEvent(Event e); @EventHandler(uei = EventConstants.FORCE_RESCAN_EVENT_UEI) void handleForceRescan(Event e); @EventHandler(uei = EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI) void handleNewSuspectEvent(Event e); @EventHandler(uei = EventConstants.NODE_UPDATED_EVENT_UEI) void handleNodeUpdated(Event e); @EventHandler(uei = EventConstants.NODE_DELETED_EVENT_UEI) void handleNodeDeletedEvent(Event e); @EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI) void handleReloadConfigEvent(Event e); @EventHandler(uei=EventConstants.ADD_INTERFACE_EVENT_UEI) void handleAddInterface(Event event); @EventHandler(uei=EventConstants.ADD_NODE_EVENT_UEI) void handleAddNode(Event event); @EventHandler(uei=EventConstants.CHANGE_SERVICE_EVENT_UEI) void handleChangeService(Event event); @EventHandler(uei=EventConstants.DELETE_INTERFACE_EVENT_UEI) void handleDeleteInterface(Event event); @EventHandler(uei=EventConstants.DELETE_NODE_EVENT_UEI) void handleDeleteNode(Event event); @EventHandler(uei=EventConstants.DELETE_SERVICE_EVENT_UEI) void handleDeleteService(Event event); @EventHandler(uei=EventConstants.UPDATE_SERVER_EVENT_UEI) void handleUpdateServer(Event event); @EventHandler(uei=EventConstants.UPDATE_SERVICE_EVENT_UEI) void handleUpdateService(Event event); String getStats(); }
Provisioner implements SpringServiceDaemon { public EventForwarder getEventForwarder() { return m_eventForwarder; }  void setProvisionService(ProvisionService provisionService); ProvisionService getProvisionService(); void setScheduledExecutor(ScheduledExecutorService scheduledExecutor); void setLifeCycleRepository(LifeCycleRepository lifeCycleRepository); void setImportSchedule(ImportScheduler schedule); void setImportActivities(CoreImportActivities importActivities); void setTaskCoordinator(DefaultTaskCoordinator taskCoordinator); void setAgentConfigFactory(SnmpAgentConfigFactory agentConfigFactory); ImportScheduler getImportSchedule(); @Override void start(); @Override void destroy(); @Override void afterPropertiesSet(); void doNodeScan(int nodeId); NodeScan createNodeScan(Integer nodeId, String foreignSource, String foreignId); NewSuspectScan createNewSuspectScan(InetAddress ipAddress); ScheduledFuture<?> getScheduledFutureForNode(int nodeId); int getScheduleLength(); ThreadCategory log(); void setEventForwarder(EventForwarder eventForwarder); EventForwarder getEventForwarder(); void doImport(); @EventHandler(uei = EventConstants.RELOAD_IMPORT_UEI) void doImport(final Event event); void doImport(final String url, final boolean rescanExisting); @EventHandler(uei = EventConstants.NODE_ADDED_EVENT_UEI) void handleNodeAddedEvent(Event e); @EventHandler(uei = EventConstants.FORCE_RESCAN_EVENT_UEI) void handleForceRescan(Event e); @EventHandler(uei = EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI) void handleNewSuspectEvent(Event e); @EventHandler(uei = EventConstants.NODE_UPDATED_EVENT_UEI) void handleNodeUpdated(Event e); @EventHandler(uei = EventConstants.NODE_DELETED_EVENT_UEI) void handleNodeDeletedEvent(Event e); @EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI) void handleReloadConfigEvent(Event e); @EventHandler(uei=EventConstants.ADD_INTERFACE_EVENT_UEI) void handleAddInterface(Event event); @EventHandler(uei=EventConstants.ADD_NODE_EVENT_UEI) void handleAddNode(Event event); @EventHandler(uei=EventConstants.CHANGE_SERVICE_EVENT_UEI) void handleChangeService(Event event); @EventHandler(uei=EventConstants.DELETE_INTERFACE_EVENT_UEI) void handleDeleteInterface(Event event); @EventHandler(uei=EventConstants.DELETE_NODE_EVENT_UEI) void handleDeleteNode(Event event); @EventHandler(uei=EventConstants.DELETE_SERVICE_EVENT_UEI) void handleDeleteService(Event event); @EventHandler(uei=EventConstants.UPDATE_SERVER_EVENT_UEI) void handleUpdateServer(Event event); @EventHandler(uei=EventConstants.UPDATE_SERVICE_EVENT_UEI) void handleUpdateService(Event event); String getStats(); static final String NAME; }