@@ -823,6 +823,162 @@ describe('features/copy-paste/ModdleCopy', function() {
823823 expect ( newGroup . categoryValueRef . $parent ) . to . equal ( newCategory ) ;
824824 } ) ) ;
825825
826+
827+ describe . only ( 'default events' , function ( ) {
828+
829+ describe ( 'allowed references' , function ( ) {
830+
831+ it ( 'should copy error reference' , inject ( function ( moddle , moddleCopy ) {
832+
833+ // given
834+ var boundaryEvent = moddle . create ( 'bpmn:BoundaryEvent' ) ,
835+ errorEventDefinition = moddle . create ( 'bpmn:ErrorEventDefinition' ) ;
836+
837+ errorEventDefinition . $parent = boundaryEvent ;
838+
839+ boundaryEvent . eventDefinitions = [ errorEventDefinition ] ;
840+
841+ var error = moddle . create ( 'bpmn:Error' ) ;
842+
843+ errorEventDefinition . errorRef = error ;
844+
845+ // when
846+ var boundaryEventCopy = moddleCopy . copyElement ( boundaryEvent , moddle . create ( 'bpmn:BoundaryEvent' ) ) ;
847+
848+ // then
849+ expect ( boundaryEventCopy . eventDefinitions ) . to . have . length ( 1 ) ;
850+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] ) . not . to . equal ( errorEventDefinition ) ;
851+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . $type ) . to . equal ( 'bpmn:ErrorEventDefinition' ) ;
852+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . errorRef ) . to . exist ;
853+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . errorRef ) . to . equal ( error ) ;
854+ } ) ) ;
855+
856+
857+ it ( 'should copy escalation reference' , inject ( function ( moddle , moddleCopy ) {
858+
859+ // given
860+ var boundaryEvent = moddle . create ( 'bpmn:BoundaryEvent' ) ,
861+ escalationEventDefinition = moddle . create ( 'bpmn:EscalationEventDefinition' ) ;
862+
863+ escalationEventDefinition . $parent = boundaryEvent ;
864+
865+ boundaryEvent . eventDefinitions = [ escalationEventDefinition ] ;
866+
867+ var error = moddle . create ( 'bpmn:Escalation' ) ;
868+
869+ escalationEventDefinition . escalationRef = error ;
870+
871+ // when
872+ var boundaryEventCopy = moddleCopy . copyElement ( boundaryEvent , moddle . create ( 'bpmn:BoundaryEvent' ) ) ;
873+
874+ // then
875+ expect ( boundaryEventCopy . eventDefinitions ) . to . have . length ( 1 ) ;
876+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] ) . not . to . equal ( escalationEventDefinition ) ;
877+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . $type ) . to . equal ( 'bpmn:EscalationEventDefinition' ) ;
878+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . escalationRef ) . to . exist ;
879+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . escalationRef ) . to . equal ( error ) ;
880+ } ) ) ;
881+
882+
883+ it ( 'should copy message reference (event)' , inject ( function ( moddle , moddleCopy ) {
884+
885+ // given
886+ var boundaryEvent = moddle . create ( 'bpmn:BoundaryEvent' ) ,
887+ messageEventDefinition = moddle . create ( 'bpmn:MessageEventDefinition' ) ;
888+
889+ messageEventDefinition . $parent = boundaryEvent ;
890+
891+ boundaryEvent . eventDefinitions = [ messageEventDefinition ] ;
892+
893+ var message = moddle . create ( 'bpmn:Message' ) ;
894+
895+ messageEventDefinition . messageRef = message ;
896+
897+ // when
898+ var boundaryEventCopy = moddleCopy . copyElement ( boundaryEvent , moddle . create ( 'bpmn:BoundaryEvent' ) ) ;
899+
900+ // then
901+ expect ( boundaryEventCopy . eventDefinitions ) . to . have . length ( 1 ) ;
902+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] ) . not . to . equal ( messageEventDefinition ) ;
903+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . $type ) . to . equal ( 'bpmn:MessageEventDefinition' ) ;
904+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . messageRef ) . to . exist ;
905+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . messageRef ) . to . equal ( message ) ;
906+ } ) ) ;
907+
908+
909+ it ( 'should copy message reference (receive task)' , inject ( function ( moddle , moddleCopy ) {
910+
911+ // given
912+ var receiveTask = moddle . create ( 'bpmn:ReceiveTask' ) ;
913+
914+ var message = moddle . create ( 'bpmn:Message' ) ;
915+
916+ receiveTask . messageRef = message ;
917+
918+ // when
919+ var receiveTaskCopy = moddleCopy . copyElement ( receiveTask , moddle . create ( 'bpmn:ReceiveTask' ) ) ;
920+
921+ // then
922+ expect ( receiveTaskCopy . messageRef ) . to . exist ;
923+ expect ( receiveTaskCopy . messageRef ) . to . equal ( message ) ;
924+ } ) ) ;
925+
926+
927+ it ( 'should copy signal reference' , inject ( function ( moddle , moddleCopy ) {
928+
929+ // given
930+ var boundaryEvent = moddle . create ( 'bpmn:BoundaryEvent' ) ,
931+ signalEventDefinition = moddle . create ( 'bpmn:SignalEventDefinition' ) ;
932+
933+ signalEventDefinition . $parent = boundaryEvent ;
934+
935+ boundaryEvent . eventDefinitions = [ signalEventDefinition ] ;
936+
937+ var signal = moddle . create ( 'bpmn:Signal' ) ;
938+
939+ signalEventDefinition . signalRef = signal ;
940+
941+ // when
942+ var boundaryEventCopy = moddleCopy . copyElement ( boundaryEvent , moddle . create ( 'bpmn:BoundaryEvent' ) ) ;
943+
944+ // then
945+ expect ( boundaryEventCopy . eventDefinitions ) . to . have . length ( 1 ) ;
946+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] ) . not . to . equal ( signalEventDefinition ) ;
947+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . $type ) . to . equal ( 'bpmn:SignalEventDefinition' ) ;
948+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . signalRef ) . to . exist ;
949+ expect ( boundaryEventCopy . eventDefinitions [ 0 ] . signalRef ) . to . equal ( signal ) ;
950+ } ) ) ;
951+
952+ } ) ;
953+
954+
955+ describe ( 'disallowed properties' , function ( ) {
956+
957+ it ( 'should NOT copy incoming and outgoing' , inject ( function ( moddle , moddleCopy ) {
958+
959+ // given
960+ var incoming = moddle . create ( 'bpmn:SequenceFlow' ) ,
961+ outgoing = moddle . create ( 'bpmn:SequenceFlow' ) ,
962+ task = moddle . create ( 'bpmn:Task' , {
963+ incoming : [ incoming ] ,
964+ outgoing : [ outgoing ]
965+ } ) ;
966+
967+ expect ( task . get ( 'incoming' ) ) . to . have . length ( 1 ) ;
968+ expect ( task . get ( 'outgoing' ) ) . to . have . length ( 1 ) ;
969+
970+ // when
971+ var taskCopy = moddleCopy . copyElement ( task , moddle . create ( 'bpmn:Task' ) ) ;
972+
973+ // then
974+ expect ( taskCopy . get ( 'incoming' ) ) . to . have . length ( 0 ) ;
975+ expect ( taskCopy . get ( 'outgoing' ) ) . to . have . length ( 0 ) ;
976+ } ) ) ;
977+
978+ } ) ;
979+
980+ } ) ;
981+
826982 } ) ;
827983
828984
0 commit comments