Skip to main content
summaryrefslogtreecommitdiffstats
blob: e8f384d6ec38590892deca39c6fd21b8cb810e4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
/*****************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  CEA LIST - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.diagram.stereotypeproperty;

import java.util.ArrayList;

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.draw2d.ui.text.TextFlowEx;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPart;
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.figure.node.AutomaticCompartmentLayoutManager;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.EditingFlowPage;
import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.StereotypePropertiesCompartment;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.junit.Before;
import org.junit.Test;

/**
 * the purpose of this class is to test the layout
 *
 */
public class TestLayoutWithStereotype extends AbstractPapyrusTestCase {

	protected static final String ST_LEFT = String.valueOf("\u00AB");

	protected static final String ST_RIGHT = String.valueOf("\u00BB");
	
	private static final String TEST_PROFILE_STEREOTYPE1 = "testProfile::Stereotype1";

	@Test
	public void testLayoutStereotypeApplicationOnClass() {
		testToCreateANode(UMLElementTypes.Class_2008);

	}
	@Test
	public void testLayoutStereotypeApplicationOnPackage() {
		//testToCreateAPackage(UMLElementTypes.Package_2007);

	}

	/**
	 * Test to create a node.
	 * 
	 * @param type
	 *        the type
	 */
	public void testToCreateANode(IElementType type) {

		//VARIABLES
		org.eclipse.uml2.uml.Class class1=null;
		//stereotype that is applied on class1
		Stereotype stereotypeTest=null;
		//view of the class
		View NotationClass1=null;
		ClassifierFigure class1figure=null;
		//editpart of class1
		GraphicalEditPart classEditPart=null;
		//compartment of stereotype
		View appliedStereotypeCompartmentNotation = null;
		//compartment Shape
		View  shapeCompartmentView=null;
		//the view of the applied stereotype property
		View stereotypePropertyView=null;
		GraphicalEditPart stereotypeCompartmentEdipart=null;
		GraphicalEditPart stereotypePropertyEdipart=null;


		//CREATION
		assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);

		assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
		//1 element element due to the reference to the profile
		assertTrue(CREATION + INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size() == 1);


		{//execution of the command
			CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
			Command command = getDiagramEditPart().getCommand(requestcreation);
			assertNotNull(CREATION + COMMAND_NULL, command);
			assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
			assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
			diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
			assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
		}



		//get the created Class
		class1 = (org.eclipse.uml2.uml.Class)((org.eclipse.uml2.uml.Package)getRootSemanticModel()).getPackagedElement("Class1");
		assertNotNull("created class must be not null", class1 );
		//look for the editpart that the class
		classEditPart = (ClassEditPart)getDiagramEditPart().getChildren().get(0);
		//test if stereotype can be applied
		assertTrue("stereotype1 must be applicable on class1", class1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);


		//look for the applied stereotype compartment
		NotationClass1=classEditPart.getNotationView();
		{//execution of the command
			SetBoundsCommand resizeCommand = new SetBoundsCommand(diagramEditor.getEditingDomain(),
				"resize",
				new EObjectAdapter((View) NotationClass1),
				new Rectangle(0, 0, 200, 200) );

			assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, resizeCommand.canExecute() == true);
			diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy( resizeCommand));
		}
		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)classEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			class1figure=((ClassifierFigure)nodePlate.getChildren().get(0));
			class1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",class1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
			class1figure.getLayoutManager().layout(class1figure);
			assertTrue("The figure of the Class has not the good X coordinate",class1figure.getBounds().x==0);
			assertTrue("The figure of the Class has not the good Y coordinate",class1figure.getBounds().y==0);
			assertTrue("The figure of the Class has not the good width coordinate",class1figure.getBounds().width==200);
			assertTrue("The figure of the Class has not the good height coordinate",class1figure.getBounds().height==200);

			// At this moment the class figure must contain 4 sub-figures 1label+ 3compartments
			assertTrue("The number of figure children must be equal to 4",class1figure.getChildren().size()==4);

			//wrappinglabel for name
			assertTrue("The sub figure [0] is not a wrapping label",class1figure.getChildren().get(0) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)class1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));

			assertTrue("The sub figure [0] is not a compartment",class1figure.getChildren().get(1) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)class1figure.getChildren().get(1);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);

			// compartment for attribute
			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==20);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==59);


			//compartment for operation
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",class1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)class1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==80);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==59);


			// compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",class1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)class1figure.getChildren().get(3);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==140);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==59);

		}

		{// execution of the application of the stereotype
			ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
			stereotypeslist.add(class1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
			ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)classEditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
			diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
			assertTrue("No applied stereotype found on the element ", class1.getAppliedStereotypes().size() != 0);
		}



		for(int i = 0; i < NotationClass1.getTransientChildren().size(); i++) {
			View view = (View) NotationClass1.getTransientChildren().get(i);
			if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
				appliedStereotypeCompartmentNotation = view;
			}
			if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
				shapeCompartmentView= view;
			}
		}
		// the mechanism of stereotype display is running.
		//the thread is synchronous
		assertTrue( "No stereotype Compartment found in the notation", appliedStereotypeCompartmentNotation != null);
		assertTrue( "No stereotype  shape Compartment found in the notation", shapeCompartmentView != null);

		//now display stereotypes
		stereotypeTest=class1.getAppliedStereotypes().get(0);

		{//display stereotype1
			RecordingCommand displayStereotypeCommand= AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(diagramEditor.getEditingDomain(), NotationClass1,stereotypeTest.getQualifiedName() , UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);

			diagramEditor.getEditingDomain().getCommandStack().execute(displayStereotypeCommand);
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)classEditPart.getFigure()).getChildren().get(0);

			//get the label
			org.eclipse.draw2d.Label stereotypeLabel=((ClassifierFigure)nodePlate.getChildren().get(0)).getStereotypesLabel();
			assertTrue( "stereotype label must be not null" ,stereotypeLabel!=null);
			assertTrue( "text of stereotype label be equals to "+ST_LEFT+"stereotype1"+ST_RIGHT ,stereotypeLabel.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));
			}

		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)classEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			class1figure=((ClassifierFigure)nodePlate.getChildren().get(0));
			class1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",class1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
			class1figure.getLayoutManager().layout(class1figure);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good X coordinate",class1figure.getBounds().x==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good Y coordinate",class1figure.getBounds().y==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good width coordinate",class1figure.getBounds().width==200);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good height coordinate",class1figure.getBounds().height==200);

			// At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ 3compartments
			assertTrue("The number of children «stereotype1»Class1 is not equals to 6",class1figure.getChildren().size()==5);


			//wrappingLabel for stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",class1figure.getChildren().get(0) instanceof Label);
			Label stereotypelabelClass=(Label)class1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
			assertTrue("The label of the Class does not display "+ST_LEFT+"stereotype1"+ST_RIGHT,stereotypelabelClass.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));


			//wrappingLabel for name
			assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",class1figure.getChildren().get(1) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)class1figure.getChildren().get(1);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));

			// compartment for property of stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure stereotypePropertiesClass=(RectangleFigure)class1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",stereotypePropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);


			assertTrue("The compartment attribute of the Class has not the good X coordinate",stereotypePropertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",stereotypePropertiesClass.getBounds().y==36);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",stereotypePropertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",stereotypePropertiesClass.getBounds().height==54);


			// compartment attribute
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)class1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);


			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==36);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==54);


			//compartment for operation
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)class1figure.getChildren().get(3);
			assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==91);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==54);

			//compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",class1figure.getChildren().get(4) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)class1figure.getChildren().get(4);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==146);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==54);

		}






		{//test display of property of stereotype in compartment 
			RecordingCommand displayPropertyStereotypeCommand= AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(diagramEditor.getEditingDomain(), NotationClass1,stereotypeTest.getQualifiedName()+".testInt");
			diagramEditor.getEditingDomain().getCommandStack().execute(displayPropertyStereotypeCommand);

			//the compartment must be visible
			assertTrue( "the compartment must be visible", appliedStereotypeCompartmentNotation.isVisible()==true);
			//look for view that represents the property of the applied stereotype
			stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
			assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
			//look for the editpart that represents the property of applied stereotype
			stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
			stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
			assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
			assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
			EditingFlowPage textarea=(EditingFlowPage)stereotypePropertyEdipart.getFigure();
			assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)textarea.getChildren().get(0)).getText().equals("testInt=0"));
		}

		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)classEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			class1figure=((ClassifierFigure)nodePlate.getChildren().get(0));
			class1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",class1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
			class1figure.getLayoutManager().layout(class1figure);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good X coordinate",class1figure.getBounds().x==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good Y coordinate",class1figure.getBounds().y==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good width coordinate",class1figure.getBounds().width==200);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good height coordinate",class1figure.getBounds().height==200);

			// At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ compartment of stereotypes+ 3compartments
			assertTrue("The number of children «stereotype1»Class1 is not equals to 6",class1figure.getChildren().size()==6);


			//label for stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",class1figure.getChildren().get(0) instanceof Label);
			Label stereotypelabelClass=(Label)class1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
			assertTrue("The label of the Class does not display "+ST_LEFT+"stereotype1"+ST_RIGHT,stereotypelabelClass.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));


			//wrappingLabel for name
			assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",class1figure.getChildren().get(1) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)class1figure.getChildren().get(1);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));


			// compartment for property of stereotypes
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(2) instanceof StereotypePropertiesCompartment);
			StereotypePropertiesCompartment sterotypesPropertiesClass=(StereotypePropertiesCompartment)class1figure.getChildren().get(2);
			
			assertTrue("the stereotype properties compartment does not conent the compartment for a stereotype",sterotypesPropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			ResizableCompartmentFigure compartmentFigure=(ResizableCompartmentFigure) sterotypesPropertiesClass.getChildren().get(0);
			assertTrue("The content of the sterotype properties compartment is not an EditingFlowPage",compartmentFigure.getContentPane().getChildren().get(0) instanceof EditingFlowPage);
			EditingFlowPage stereotypeProperty= (EditingFlowPage)compartmentFigure.getContentPane().getChildren().get(0);
			assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)stereotypeProperty.getChildren().get(0)).getText().equals("testInt=0"));
	
			assertTrue("The compartment property of stereotypes of the Class has not the good X coordinate",sterotypesPropertiesClass.getBounds().x==1);
			assertTrue("The compartment property of stereotypes of the Class has not the good Y coordinate",sterotypesPropertiesClass.getBounds().y==36);
			assertTrue("The compartment property of stereotypes of the Class has not the good width coordinate",sterotypesPropertiesClass.getBounds().width==200);
			assertTrue("The compartment property of stereotypes of the Class has not the good height coordinate",sterotypesPropertiesClass.getBounds().height==51);
			
			//compartment for attribute
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)class1figure.getChildren().get(3);
			assertTrue("The sub figure [2] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			
			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==88);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==37);


			//compartment for operation
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",class1figure.getChildren().get(4) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)class1figure.getChildren().get(4);
			assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==126);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==37);

			//compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",class1figure.getChildren().get(5) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)class1figure.getChildren().get(5);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==164);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==37);

		}
	}

	/**
	 * Test to create a node.
	 * 
	 * @param type
	 *        the type
	 */
	public void testToCreateAPackage(IElementType type) {

		//VARIABLES
		org.eclipse.uml2.uml.Package package1=null;
		//stereotype that is applied on class1
		Stereotype stereotypeTest=null;
		//view of the class
		View NotationPackage1=null;
		PackageFigure package1figure=null;
		//editpart of class1
		GraphicalEditPart packageEditPart=null;
		//compartment of stereotype
		View appliedStereotypeCompartmentNotation = null;
		//compartment Shape
		View  shapeCompartmentView=null;
		//the view of the applied stereotype property
		View stereotypePropertyView=null;
		GraphicalEditPart stereotypeCompartmentEdipart=null;
		GraphicalEditPart stereotypePropertyEdipart=null;


		//CREATION
		assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);

		assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
		//1 element element due to the reference to the profile
		assertTrue(CREATION + INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size() == 1);


		{//execution of the command
			CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
			Command command = getDiagramEditPart().getCommand(requestcreation);
			assertNotNull(CREATION + COMMAND_NULL, command);
			assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
			assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
			diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
			assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
		}



		//get the created Class
		package1 = (org.eclipse.uml2.uml.Package)((org.eclipse.uml2.uml.Package)getRootSemanticModel()).getPackagedElement("Package1");
		assertNotNull("created class must be not null", package1 );
		//look for the editpart that the class
		packageEditPart = (PackageEditPart)getDiagramEditPart().getChildren().get(0);
		//test if stereotype can be applied
		assertTrue("stereotype1 must be applicable on class1", package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);


		//look for the applied stereotype compartment
		NotationPackage1=packageEditPart.getNotationView();
		{//execution of the command
			SetBoundsCommand resizeCommand = new SetBoundsCommand(diagramEditor.getEditingDomain(),
				"resize",
				new EObjectAdapter((View) NotationPackage1),
				new Rectangle(0, 0, 200, 200) );

			assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, resizeCommand.canExecute() == true);
			diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy( resizeCommand));
		}
		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			package1figure=((PackageFigure)nodePlate.getChildren().get(0));
			package1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of package1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof Package);
			package1figure.getLayoutManager().layout(package1figure);
			assertTrue("The figure of the Class has not the good X coordinate",package1figure.getBounds().x==0);
			assertTrue("The figure of the Class has not the good Y coordinate",package1figure.getBounds().y==0);
			assertTrue("The figure of the Class has not the good width coordinate",package1figure.getBounds().width==200);
			assertTrue("The figure of the Class has not the good height coordinate",package1figure.getBounds().height==200);

			// At this moment the class figure must contain 4 sub-figures 1label+ 3compartments
			assertTrue("The number of figure children must be equal to 4",package1figure.getChildren().size()==4);

			//wrappinglabel for name
			assertTrue("The sub figure [0] is not a wrapping label",package1figure.getChildren().get(0) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));

			assertTrue("The sub figure [0] is not a compartment",package1figure.getChildren().get(1) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(1);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);

			// compartment for attribute
			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==20);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==59);


			//compartment for operation
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==80);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==59);


			// compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(3);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==140);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==59);

		}

		{// execution of the application of the stereotype
			ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
			stereotypeslist.add(package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
			ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)packageEditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
			diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
			assertTrue("No applied stereotype found on the element ", package1.getAppliedStereotypes().size() != 0);
		}



		for(int i = 0; i < NotationPackage1.getTransientChildren().size(); i++) {
			View view = (View) NotationPackage1.getTransientChildren().get(i);
			if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
				appliedStereotypeCompartmentNotation = view;
			}
			if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
				shapeCompartmentView= view;
			}
		}
		// the mechanism of stereotype display is running.
		//the thread is synchronous
		assertTrue( "No stereotype Compartment found in the notation", appliedStereotypeCompartmentNotation != null);
		assertTrue( "No stereotype  shape Compartment found in the notation", shapeCompartmentView != null);

		//now display stereotypes
		stereotypeTest=package1.getAppliedStereotypes().get(0);

		{//display stereotype1
			RecordingCommand displayStereotypeCommand= AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(diagramEditor.getEditingDomain(), NotationPackage1,stereotypeTest.getQualifiedName() , UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);

			diagramEditor.getEditingDomain().getCommandStack().execute(displayStereotypeCommand);
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);

			//get the label
			org.eclipse.draw2d.Label stereotypeLabel=((ClassifierFigure)nodePlate.getChildren().get(0)).getStereotypesLabel();
			assertTrue( "stereotype label must be not null" ,stereotypeLabel!=null);
			assertTrue( "text of stereotype label be equals to "+ST_LEFT+"stereotype1"+ST_RIGHT ,stereotypeLabel.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));
		}

		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			package1figure=((PackageFigure)nodePlate.getChildren().get(0));
			package1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
			package1figure.getLayoutManager().layout(package1figure);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good X coordinate",package1figure.getBounds().x==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good Y coordinate",package1figure.getBounds().y==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good width coordinate",package1figure.getBounds().width==200);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good height coordinate",package1figure.getBounds().height==200);

			// At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ 3compartments
			assertTrue("The number of children «stereotype1»Class1 is not equals to 6",package1figure.getChildren().size()==5);


			//wrappingLabel for stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",package1figure.getChildren().get(0) instanceof Label);
			Label stereotypelabelClass=(Label)package1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
			assertTrue("The label of the Class does not display "+ST_LEFT+"stereotype1"+ST_RIGHT,stereotypelabelClass.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));


			//wrappingLabel for name
			assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",package1figure.getChildren().get(1) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(1);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));

			// compartment for property of stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure stereotypePropertiesClass=(RectangleFigure)package1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",stereotypePropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);


			assertTrue("The compartment attribute of the Class has not the good X coordinate",stereotypePropertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",stereotypePropertiesClass.getBounds().y==36);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",stereotypePropertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",stereotypePropertiesClass.getBounds().height==54);


			// compartment attribute
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(2);
			assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);


			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==36);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==54);


			//compartment for operation
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(3);
			assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==91);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==54);

			//compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(4) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(4);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==146);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==54);

		}






		{//test display of property of stereotype in compartment 
			RecordingCommand displayPropertyStereotypeCommand= AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(diagramEditor.getEditingDomain(), NotationPackage1,stereotypeTest.getQualifiedName()+".testInt");
			diagramEditor.getEditingDomain().getCommandStack().execute(displayPropertyStereotypeCommand);

			//the compartment must be visible
			assertTrue( "the compartment must be visible", appliedStereotypeCompartmentNotation.isVisible()==true);
			//look for view that represents the property of the applied stereotype
			stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
			assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
			//look for the editpart that represents the property of applied stereotype
			stereotypeCompartmentEdipart=(GraphicalEditPart)packageEditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
			stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
			assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
			assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
			EditingFlowPage textarea=(EditingFlowPage)stereotypePropertyEdipart.getFigure();
			assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)textarea.getChildren().get(0)).getText().equals("testInt=0"));
		}

		{//test about the layout
			org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
			// now verify position of each subfigure
			package1figure=((PackageFigure)nodePlate.getChildren().get(0));
			package1figure.setBounds(new Rectangle(0,0,200,200));
			assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
			package1figure.getLayoutManager().layout(package1figure);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good X coordinate",package1figure.getBounds().x==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good Y coordinate",package1figure.getBounds().y==0);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good width coordinate",package1figure.getBounds().width==200);
			assertTrue("The figure of the  «stereotype1»Class1 has not the good height coordinate",package1figure.getBounds().height==200);

			// At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ compartment of stereotypes+ 3compartments
			assertTrue("The number of children «stereotype1»Class1 is not equals to 6",package1figure.getChildren().size()==6);


			//label for stereotype
			assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",package1figure.getChildren().get(0) instanceof Label);
			Label stereotypelabelClass=(Label)package1figure.getChildren().get(0);

			assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
			assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
			assertTrue("The label of the Class does not display "+ST_LEFT+"stereotype1"+ST_RIGHT,stereotypelabelClass.getText().equals(ST_LEFT+"stereotype1"+ST_RIGHT));


			//wrappingLabel for name
			assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",package1figure.getChildren().get(1) instanceof WrappingLabel);
			WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(1);

			assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
			assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
			assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
			assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
			assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));


			// compartment for property of stereotypes
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof StereotypePropertiesCompartment);
			StereotypePropertiesCompartment sterotypesPropertiesClass=(StereotypePropertiesCompartment)package1figure.getChildren().get(2);
			
			assertTrue("the stereotype properties compartment does not conent the compartment for a stereotype",sterotypesPropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			ResizableCompartmentFigure compartmentFigure=(ResizableCompartmentFigure) sterotypesPropertiesClass.getChildren().get(0);
			assertTrue("The content of the sterotype properties compartment is not an EditingFlowPage",compartmentFigure.getContentPane().getChildren().get(0) instanceof EditingFlowPage);
			EditingFlowPage stereotypeProperty= (EditingFlowPage)compartmentFigure.getContentPane().getChildren().get(0);
			assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)stereotypeProperty.getChildren().get(0)).getText().equals("testInt=0"));
	
			assertTrue("The compartment property of stereotypes of the Class has not the good X coordinate",sterotypesPropertiesClass.getBounds().x==1);
			assertTrue("The compartment property of stereotypes of the Class has not the good Y coordinate",sterotypesPropertiesClass.getBounds().y==36);
			assertTrue("The compartment property of stereotypes of the Class has not the good width coordinate",sterotypesPropertiesClass.getBounds().width==200);
			assertTrue("The compartment property of stereotypes of the Class has not the good height coordinate",sterotypesPropertiesClass.getBounds().height==51);
			
			//compartment for attribute
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(3) instanceof RectangleFigure);
			RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(3);
			assertTrue("The sub figure [2] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			
			assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
			assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==88);
			assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
			assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==37);


			//compartment for operation
			assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(4) instanceof RectangleFigure);
			RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(4);
			assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
			assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==126);
			assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
			assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==37);

			//compartment for nested classifier
			assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(5) instanceof RectangleFigure);
			RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(5);
			assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
			assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
			assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==164);
			assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
			assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==37);

		}
	}
	
	
	@Before
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		RegisteredProfile registeredProfile = RegisteredProfile.getRegisteredProfile("TestProfile");
		final Model root = ((Model)getDiagramEditPart().resolveSemanticElement());
		URI modelUri = registeredProfile.uri;
		@SuppressWarnings("deprecation")
		final Resource modelResource = Util.getResourceSet(root).getResource(modelUri, true);
		final Profile profile = (Profile)modelResource.getContents().get(0);
		//	PackageUtil.applyProfile(root,profile, false);
		final TransactionalEditingDomain domain = ServiceUtils.getInstance().getTransactionalEditingDomain(papyrusEditor.getServicesRegistry());
		AppliedProfileCommand appliedProfileCommand = new AppliedProfileCommand(domain, root, profile);
		domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(appliedProfileCommand));


	}
}

Back to the top