@Override
    public boolean createMaintenanceAssociation(MdId mdName, MaintenanceAssociation newMa)
            throws CfmConfigException {
        log.info("Updating MD {} in distributed store by adding new MA {}", mdName, newMa.maId());
        MaintenanceDomain.MdBuilder builder = DefaultMaintenanceDomain
                .builder(store.getMaintenanceDomain(mdName)
                .orElseThrow(() -> new IllegalArgumentException("Unknown MD: " + mdName)));

        boolean replaced = false;
        //Check the MA is present
        if (builder.checkMaExists(newMa.maId())) {
            builder = builder.deleteFromMaList(newMa.maId());
            replaced = true;
        }

        builder.addToMaList(newMa);
        store.createUpdateMaintenanceDomain(builder.build());
        return replaced;
    }
@Test
    public void testCreateMaintenanceAssociation() throws CfmConfigException {
        MaintenanceAssociation maTest41 = DefaultMaintenanceAssociation
                .builder(MaIdCharStr.asMaId("test-ma-1-4"), 9)
                .ccmInterval(MaintenanceAssociation.CcmInterval.INTERVAL_1S)
                .maNumericId((short) 4)
                .addToRemoteMepIdList(MepId.valueOf((short) 401))
                .addToRemoteMepIdList(MepId.valueOf((short) 402))
                .addToComponentList(
                        DefaultComponent.builder(4)
                                .tagType(Component.TagType.VLAN_STAG)
                                .build())
                .build();

        //Should return false, as this MA did not exist before
        assertFalse(service.createMaintenanceAssociation(
                            MdIdCharStr.asMdId("test-md-1"), maTest41));
        assertEquals(3, service.getAllMaintenanceAssociation(
                                MdIdCharStr.asMdId("test-md-1")).size());

        //Now try with an invalid mdName
        try {
            service.createMaintenanceAssociation(
                    MdIdCharStr.asMdId("test-md-2"), maTest41);
        } catch (IllegalArgumentException e) {
            assertEquals("Unknown MD: test-md-2", e.getMessage());
        }

        //Now try replacing an MA with some new values or Remote MEP
        MaintenanceAssociation maTest11 = DefaultMaintenanceAssociation
                .builder(MaIdCharStr.asMaId("test-ma-1-1"), 9)
                .ccmInterval(MaintenanceAssociation.CcmInterval.INTERVAL_10MIN)
                .maNumericId((short) 1)
                .addToRemoteMepIdList(MepId.valueOf((short) 111)) //Changed
                .addToRemoteMepIdList(MepId.valueOf((short) 112)) //Changed
                .addToComponentList(
                        DefaultComponent.builder(1)
                                .tagType(Component.TagType.VLAN_CTAG)
                                .build())
                .build();

        //Should return true, as this MA did exist before
        assertTrue(service.createMaintenanceAssociation(
                MdIdCharStr.asMdId("test-md-1"), maTest11));
        assertEquals(3, service.getAllMaintenanceAssociation(
                MdIdCharStr.asMdId("test-md-1")).size());
    }