diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java')
-rw-r--r-- | plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java new file mode 100644 index 00000000000..d295dc9421a --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.core.dsl.integration.internal; + +import java.util.HashSet; +import java.util.Set; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.dsl.integration.internal.ArtifactTypeRestrictionHandler; +import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; +import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; +import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; +import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; +import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction; +import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.model.type.ArtifactType; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.junit.Test; + +/** + * Test Case for {@link ArtifactTypeRestrictionHandler} + * + * @author Roberto E. Escobar + */ +public class ArtifactTypeRestrictionHandlerTest extends BaseRestrictionHandlerTest<ArtifactTypeRestriction> { + + public ArtifactTypeRestrictionHandlerTest() { + super(new ArtifactTypeRestrictionHandler(), MockModel.createArtifactTypeRestriction(), + MockModel.createAttributeTypeRestriction()); + } + + @Test + public void testProcessDataNotMatchesRestriction() throws OseeCoreException { + IArtifactType artifactType = CoreArtifactTypes.Requirement; + XArtifactType artifactTypeRef = MockModel.createXArtifactType(artifactType.getGuid(), artifactType.getName()); + + ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); + restriction.setPermission(AccessPermissionEnum.ALLOW); + restriction.setArtifactTypeRef(artifactTypeRef); + + ArtifactType artifactType2 = new ArtifactType(GUID.create(), "Some Artifact Type", false); + MockArtifactProxy artData = new MockArtifactProxy(GUID.create(), artifactType2); + DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData); + } + + @Test + public void testProcessCreateAccessDetail() throws OseeCoreException { + IArtifactType artifactType = CoreArtifactTypes.Requirement; + XArtifactType artifactTypeRef = MockModel.createXArtifactType(artifactType.getGuid(), artifactType.getName()); + + ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); + restriction.setPermission(AccessPermissionEnum.ALLOW); + restriction.setArtifactTypeRef(artifactTypeRef); + + ArtifactType expectedAccessObject = new ArtifactType(artifactType.getGuid(), artifactType.getName(), false); + MockArtifactProxy artData = new MockArtifactProxy(GUID.create(), expectedAccessObject); + + DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedAccessObject, + PermissionEnum.WRITE); + } + + @Test + public void testProcessArtifactTypeInheritance() throws OseeCoreException { + IArtifactType artifactType = CoreArtifactTypes.Artifact; + XArtifactType artifactTypeRef = MockModel.createXArtifactType(artifactType.getGuid(), artifactType.getName()); + + ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); + restriction.setPermission(AccessPermissionEnum.ALLOW); + restriction.setArtifactTypeRef(artifactTypeRef); + + ArtifactType expectedAccessObject = + new ArtifactType(CoreArtifactTypes.Requirement.getGuid(), CoreArtifactTypes.Requirement.getName(), false); + + MockArtifactProxy artData = new MockArtifactProxy(GUID.create(), expectedAccessObject); + DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData); + + // Make expectedAccessObject inherit from ArtifactType + Set<ArtifactType> superTypes = new HashSet<ArtifactType>(); + superTypes.add(new ArtifactType(CoreArtifactTypes.Artifact.getGuid(), CoreArtifactTypes.Artifact.getName(), false)); + expectedAccessObject.setSuperTypes(superTypes); + DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedAccessObject, + PermissionEnum.WRITE); + } + +} |