@Override
    public MepEntry getMep(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException {
        MepKeyId key = new MepKeyId(mdName, maName, mepId);

        //Will throw IllegalArgumentException if ma does not exist
        cfmMdService.getMaintenanceAssociation(mdName, maName);

        Optional<Mep> mepOptional = mepStore.getMep(key);
        if (mepOptional.isPresent()) {
            Mep mep = mepOptional.get();
            DeviceId mepDeviceId = mep.deviceId();
            if (deviceService.getDevice(mepDeviceId) == null) {
                throw new CfmConfigException("Device not found " + mepDeviceId);
            } else if (!deviceService.getDevice(mepDeviceId).is(CfmMepProgrammable.class)) {
                throw new CfmConfigException("Device " + mepDeviceId +
                        " does not support CfmMepProgrammable behaviour.");
            }

            log.debug("Retrieving MEP reults for Mep {} in MD {}, MA {} on Device {}",
                    mep.mepId(), mdName, maName, mepDeviceId);

            return deviceService.getDevice(mepDeviceId)
                    .as(CfmMepProgrammable.class).getMep(mdName, maName, mepId);
        } else {
            return null;
        }
    }
@Test
    public void testGetMepMissing() {

        expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1))
                .andReturn(Optional.ofNullable(ma1))
                .anyTimes();
        replay(mdService);

        expect(deviceService.getDevice(DEVICE_ID1)).andReturn(null).anyTimes();
        replay(deviceService);

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

        try {
            mepManager.getMep(MDNAME1, MANAME1, MEPID1);
            fail("Expecting CfmConfigException because device does not exist");
        } catch (CfmConfigException e) {
            assertEquals("Device not found netconf:1.2.3.4:830", e.getMessage());
        }
    }