public boolean isRequisitioned(OnmsMonitoredService monSvc) {
    String foreignSource = monSvc.getIpInterface().getNode().getForeignSource();
    String foreignId = monSvc.getIpInterface().getNode().getForeignId();

    // is this a discovered node
    if (foreignSource == null) return false;

    OnmsNode reqNode = getRequisitionedNode(foreignSource, foreignId);
    if (reqNode == null) {
      // this is no requisition node?
      LogUtils.errorf(
          "No requistion exists for node with foreignSource %s and foreignId %s.  Treating node as unrequistioned",
          foreignSource, foreignId);
      return false;
    }

    OnmsIpInterface reqIp = reqNode.getIpInterfaceByIpAddress(monSvc.getIpAddress());
    if (reqIp == null) {
      // there is no matching requistion ip so the interface was discovered
      return false;
    }

    OnmsMonitoredService reqSvc = reqIp.getMonitoredServiceByServiceType(monSvc.getServiceName());

    // if we found the service then its a requistion service
    return reqSvc != null;
  }
  @Test
  @Transactional
  public void testLazy() {
    final List<OnmsMonitoredService> allSvcs = m_monitoredServiceDao.findAll();
    assertTrue(allSvcs.size() > 1);

    final OnmsMonitoredService svc = allSvcs.iterator().next();
    assertEquals(addr("192.168.1.1"), svc.getIpAddress());
    assertEquals(1, svc.getIfIndex().intValue());
    assertEquals(m_databasePopulator.getNode1().getId(), svc.getIpInterface().getNode().getId());
    assertEquals("M", svc.getIpInterface().getIsManaged());
  }
  private boolean shouldDelete(final OnmsMonitoredService monSvc) {
    String foreignSource = monSvc.getIpInterface().getNode().getForeignSource();

    // only delete services that are on discovered nodes if discovery is enabled
    // meaning provisiond is managing discovered nodes rather than capsd
    if (foreignSource == null) return isDiscoveryEnabled();

    // if we enable deletion of requisitioned entities then we can delete this
    if (isRequisitionedEntityDeletionEnabled()) return true;

    // otherwise only delete if it is not requistioned
    return !isRequisitioned(monSvc);
  }