@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 testCreateDmNoBehavior() throws CfmConfigException, SoamConfigException {
        final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
        final MepId mepId3 = MepId.valueOf((short) 3);

        Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
        behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);

        Driver testDriver3 = new DefaultDriver(
                TEST_DRIVER_3, new ArrayList<Driver>(),
                TEST_MFR, TEST_HW_VERSION, TEST_SW_3,
                behaviours, new HashMap<>());

        Device device3 = new DefaultDevice(
                ProviderId.NONE, deviceId3, Device.Type.SWITCH,
                TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN,
                new ChassisId(2),
                DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());

        expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
        replay(deviceService);

        MepEntry mep3 = DefaultMepEntry.builder(mepId3, deviceId3, PortNumber.P0,
                Mep.MepDirection.UP_MEP, MDNAME1, MANAME1)
                .buildEntry();

        expect(mepService.getMep(MDNAME1, MANAME1, mepId3)).andReturn(mep3).anyTimes();
        replay(mepService);

        expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).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();

        try {
            soamManager.createDm(MDNAME1, MANAME1, mepId3, dmCreate1);
            fail("Expecting exception since device does not support behavior");
        } catch (CfmConfigException e) {
            assertEquals("Device netconf:3.2.3.4:830 from MEP :md-1/" +
                    "ma-1-1/3 does not implement SoamDmProgrammable", e.getMessage());
        }
    }