@Override
    public Optional<SoamId> createDm(MdId mdName, MaIdShort maName, MepId mepId,
                                    DelayMeasurementCreate dmNew)
                    throws CfmConfigException, SoamConfigException {
        DeviceId mepDeviceId = cfmMepService.getMep(mdName, maName, mepId).deviceId();
        if (mepDeviceId == null) {
            throw new CfmConfigException("Unable to create DM. MEP :"
                    + mdName + "/" + maName + "/" + mepId + " does not exist");
        } else if (deviceService.getDevice(mepDeviceId) == null) {
            throw new CfmConfigException("Device " + mepDeviceId + " from MEP :"
                    + mdName + "/" + maName + "/" + mepId + " does not exist");
        } else if (!deviceService.getDevice(mepDeviceId).is(SoamDmProgrammable.class)) {
            throw new CfmConfigException("Device " + mepDeviceId + " from MEP :"
                    + mdName + "/" + maName + "/" + mepId +
                    " does not implement SoamDmProgrammable");
        }
        log.debug("Creating new DM in MD {}, MA {}, MEP {} on Device {}",
                mdName, maName, mepId, mepDeviceId);
        return deviceService.getDevice(mepDeviceId)
            .as(SoamDmProgrammable.class).createDm(mdName, maName, mepId, dmNew);
    }
@Test
    public void testCreateDm() 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);

        DelayMeasurementCreate dmCreate1 = DefaultDelayMeasurementCreate
                .builder(DelayMeasurementCreate.DmType.DM1DMTX,
                    DelayMeasurementCreate.Version.Y17312011,
                    MepId.valueOf((short) 11), Mep.Priority.PRIO3)
                .binsPerFdInterval((short) 4)
                .binsPerFdrInterval((short) 5)
                .binsPerIfdvInterval((short) 6)
                .build();

        assertEquals(1000, soamManager.createDm(
                    MDNAME1, MANAME1, MEPID1, dmCreate1).get().value());
    }