Skip to main content
summaryrefslogtreecommitdiffstats
blob: f542dd48ec303860f8335cdab9c7f189ababbdbf (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
/*****************************************************************************
 * Copyright (c) 2011 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:
 *  Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
 * 
 * @Generated from Block - Model 
 *
 *****************************************************************************/
package org.eclipse.papyrus.sysml.modelexplorer.tests.copypaste;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.papyrus.core.utils.FilteredCollectionView;
import org.eclipse.papyrus.core.utils.IFilter;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


/**
 * Test for Copy / Paste of a Part
 */
public abstract class AbstractCopyPasteBlockTest extends AbstractCopyPasteTest {

	/**
     * {@inheritDoc}
     * @generated
 	 */
	@Override
	protected void initializeTest(Map<Object, Object> additionalChecks, EObject targetContainer, EObject copiedEObject) {
    super.initializeTest(additionalChecks, targetContainer, copiedEObject);
  
      /* pre-copy initialization */
      List<Property> originalParts = new ArrayList<Property>();  for(Property p : ((org.eclipse.uml2.uml.Class)copiedEObject).getAllAttributes()) {  	if(new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) {originalParts.add(p);}} additionalChecks.put("originalParts", originalParts);
      /* END OF pre-copy initialization */
  }

	/**
	 * {@inheritDoc}
	 * @generated	
	 */
	@Override
	protected void postCopyAdditionalChecks(Map<?, ?> originalModel, List<EObject> newValues, List<EObject> delta) throws Exception {
    super.postCopyAdditionalChecks(originalModel, newValues, delta);
    
      /* post copy checks */
           FilteredCollectionView<EObject> newClasses = new FilteredCollectionView<EObject>(delta, new IFilter() {    /**     * {@inheritDoc}     */    public boolean isAllowed(Object object) {     return object instanceof org.eclipse.uml2.uml.Class && !(object instanceof org.eclipse.uml2.uml.Association);    }   });   Assert.assertEquals("New values should contain a Class", 1, newClasses.size());   org.eclipse.uml2.uml.Class newBlock = newClasses.toArray(new org.eclipse.uml2.uml.Class[]{})[0];   Assert.assertNotNull("Block stereotype should be applied",     ((org.eclipse.uml2.uml.Class) newBlock)       .getAppliedStereotype("SysML::Blocks::Block"));   List<Property> originalParts = (List<Property>) originalModel     .get("originalParts");   List<Property> newParts = new ArrayList<Property>();   for (Property p : ((org.eclipse.uml2.uml.Class) newBlock)     .getAllAttributes()) {    if (new org.eclipse.papyrus.sysml.service.types.matcher.PartPropertyMatcher().matches(p)) {     newParts.add(p);     Assert.assertNotNull(       "Part should have an associated association.",       p.getAssociation());    }   }   Assert.assertEquals(     "Both original and new list of attributes should be quivalent for the blocks",     originalParts.size(), newParts.size());
      /* END OF post copy checks */
  }

}


Back to the top