Buggy code:
public class AtomicDesignInterface { private static AtomicDesignInterface instance ; public static AtomicDesignInterface getInstance ( ) { } private AtomicDesignInterface ( ) { } @ Atomic public void createSpecification ( String specId , String name ) { } private BlendedWorkflow getBlendedWorkflow ( ) { } @ Atomic public void createEntity ( String specId , String entityName , Boolean exists ) { } @ Atomic public void createAttribute ( String specId , String entityName , String attributeName , String attributeType ) { } @ Atomic public void createRelation ( String specId , String entityOneName , String roleNameOne , String cardinalityOne , String entityTwoName , String roleNameTwo , String cardinalityTwo ) { } @ Atomic public void loadDataModel ( String specId , DataModel eDataModel ) { BlendedWorkflow bw = getBlendedWorkflow ( ) ; BWSpecification spec = bw . getSpecById ( specId ) . orElseGet ( ( ) -> bw . createSpecification ( specId , eDataModel . getSpecification ( ) . getName ( ) ) ) ; BWDataModel dataModel = spec . getDataModel ( ) ; Set < String > existingEntities = dataModel . getEntitiesSet ( ) . stream ( ) . map ( ( ent ) -> ent . getName ( ) ) . collect ( Collectors . toSet ( ) ) ; for ( Entity eEnt : eDataModel . getEntities ( ) ) { BWEntity entity = null ; if ( ! ( existingEntities . contains ( eEnt . getName ( ) ) ) ) { entity = dataModel . createEntity ( eEnt . getName ( ) , eEnt . isExists ( ) ) ; } else { existingEntities . remove ( eEnt . getName ( ) ) ; entity = getEntity ( dataModel , eEnt . getName ( ) ) ; } Set < String > existingAttributes = entity . getAttributesSet ( ) . stream ( ) . map ( ( att ) -> att . getName ( ) ) . collect ( Collectors . toSet ( ) ) ; for ( BWAttributeGroup attGroup : entity . getAttributeGroupSet ( ) ) { attGroup . delete ( ) ; } for ( EObject att : eEnt . getAttributes ( ) ) { if ( att instanceof Attribute ) { Attribute eAtt = ( ( Attribute ) ( att ) ) ; if ( ! ( existingAttributes . contains ( eAtt . getName ( ) ) ) ) { entity . createAttribute ( eAtt . getName ( ) , parseAttributeType ( eAtt . getType ( ) ) ) ; } else { existingAttributes . remove ( eAtt . getName ( ) ) ; BWAttribute existAtt = entity . getAttribute ( eAtt . getName ( ) ) ; existAtt . setType ( parseAttributeType ( eAtt . getType ( ) ) ) ; } } else if ( att instanceof AttributeGroup ) { AttributeGroup eAttGroup = ( ( AttributeGroup ) ( att ) ) ; <START_BUG> BWAttributeGroup attGroup = entity . createAttributeGroup ( "TODEFINE" ) ; <END_BUG> for ( Attribute eAtt : eAttGroup . getAttributes ( ) ) { BWAttribute bwAtt = entity . createAttribute ( eAtt . getName ( ) , parseAttributeType ( eAtt . getType ( ) ) ) ; attGroup . addAttribute ( bwAtt ) ; } } } for ( String attName : existingAttributes ) { entity . getAttribute ( attName ) . delete ( ) ; } } for ( String entityName : existingEntities ) { dataModel . getEntity ( entityName ) . get ( ) . delete ( ) ; } for ( BWRelation rel : dataModel . getRelationsSet ( ) ) { rel . delete ( ) ; } for ( Association assoc : eDataModel . getAssociations ( ) ) { BWEntity entityOne = getEntity ( dataModel , assoc . getEntity1 ( ) . getName ( ) ) ; BWEntity entityTwo = getEntity ( dataModel , assoc . getEntity2 ( ) . getName ( ) ) ; entityOne . createRelation ( assoc . getName1 ( ) , parseCardinality ( assoc . getCardinality1 ( ) ) , entityTwo , assoc . getName2 ( ) , parseCardinality ( assoc . getCardinality2 ( ) ) ) ; } } static final String STRING = "String" ; static final String NUMBER = "Number" ; static final String BOOLEAN = "Boolean" ; static final String DATE = "Date" ; static final String ATTRIBUTE_TYPE = ( ( ( ( ( ( ( "(" + ( AtomicDesignInterface . STRING ) ) + "|" ) + ( AtomicDesignInterface . NUMBER ) ) + "|" ) + ( AtomicDesignInterface . BOOLEAN ) ) + "|" ) + ( AtomicDesignInterface . DATE ) ) + ")" ; private AttributeType parseAttributeType ( String type ) { } static final String ONE = "1" ; static final String ZERO_MANY = "\\*" ; static final String ZERO_OR_ONE = "0..1" ; static final String ONE_MANY = "1..\\*" ; static final String CARDINALITY = ( ( ( ( ( ( ( "(" + ( AtomicDesignInterface . ONE ) ) + "|" ) + ( AtomicDesignInterface . ZERO_OR_ONE ) ) + "|" ) + ( AtomicDesignInterface . ZERO_MANY ) ) + "|" ) + ( AtomicDesignInterface . ONE_MANY ) ) + ")" ; private Cardinality parseCardinality ( String cardinality ) { } private BWEntity getEntity ( BWDataModel dataModel , String name ) { } }

Fix:
BWAttributeGroup attGroup = entity . createAttributeGroup ( eAttGroup . getName ( ) ) ;