@Override
    public Collection<DelayMeasurementStatHistory> getDmHistoricalStats(
            MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId)
                    throws SoamConfigException, CfmConfigException {
        MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
        if (mep == null || mep.deviceId() == null) {
            throw new CfmConfigException("MEP :"
                    + mdName + "/" + maName + "/" + mepId + " does not exist");
        } else if (deviceService.getDevice(mep.deviceId()) == null) {
            throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
                    + mdName + "/" + maName + "/" + mepId + " does not exist");
        } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
            throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :"
                    + mdName + "/" + maName + "/" + mepId +
                    " does not implement SoamDmProgrammable");
        }
        log.debug("Retrieving History Stats for DM {} in MD {}, MA {}, MEP {} "
                + "on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
        return deviceService.getDevice(mep.deviceId())
            .as(SoamDmProgrammable.class).getDmHistoricalStats(mdName, maName, mepId, dmId);
    }
@Test
    public void testGetDmHistoryStats() throws CfmConfigException, SoamConfigException {
        expect(deviceService.getDevice(DEVICE_ID1)).andReturn(device1).anyTimes();
        replay(deviceService);

        expect(mepService.getMep(MDNAME1, MANAME1, MEPID1)).andReturn(mep1).anyTimes();
        replay(mepService);

        expect(driverService.getDriver(DEVICE_ID1)).andReturn(testDriver).anyTimes();
        replay(driverService);

        Collection<DelayMeasurementStatHistory> dmHistoricalStats =
                soamManager.getDmHistoricalStats(MDNAME1, MANAME1, MEPID1, DMID101);

        assertNotNull(dmHistoricalStats);
        assertEquals(2, dmHistoricalStats.size());
    }