@Override public void run() { try { OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(); snmpIface.setIfIndex(m_ifIndex); snmpIface.setIfName(m_ifName); m_upsertService.upsert(m_nodeId, snmpIface, 1000); } catch (Throwable t) { t.printStackTrace(); m_throwable.set(t); } }
@Test @JUnitTemporaryDatabase public void testInsert() { String newIfName = "newIf0"; assertEquals(0, countIfs(m_populator.getNode1().getId(), 1001, newIfName)); // add non existent snmpiface OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(); snmpIface.setNode(m_populator.getNode1()); snmpIface.setIfIndex(1001); snmpIface.setIfName(newIfName); m_upsertService.upsert(m_populator.getNode1().getId() /* nodeid */, snmpIface, 0); assertEquals(1, countIfs(m_populator.getNode1().getId(), 1001, newIfName)); }
@Test @JUnitTemporaryDatabase public void testUpdate() { String oldIfName = "eth0"; String newIfName = "newIf0"; assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, oldIfName)); assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, newIfName)); // add non existent snmpiface OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(); snmpIface.setIfIndex(2); snmpIface.setIfName(newIfName); m_upsertService.upsert(m_populator.getNode1().getId(), snmpIface, 0); assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, oldIfName)); assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, newIfName)); }