Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3355a8d98dd590b9780413d28a68d75debc06ae5 (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
/*******************************************************************************
 * 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.test.internal;

import junit.framework.Assert;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.integration.test.mocks.DslAsserts;
import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockModel;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.junit.Test;

/**
 * Test Case for {@link RestrictionHandler classes}
 * 
 * @author Roberto E. Escobar
 */
public abstract class BaseRestrictionHandlerTest<T extends ObjectRestriction> {

   private final RestrictionHandler<T> restrictionHandler;
   private final ObjectRestriction validRestriction;
   private final ObjectRestriction invalidRestriction;

   protected BaseRestrictionHandlerTest(RestrictionHandler<T> restrictionHandler, ObjectRestriction validRestriction, ObjectRestriction invalidRestriction) {
      this.restrictionHandler = restrictionHandler;
      this.validRestriction = validRestriction;
      this.invalidRestriction = invalidRestriction;
   }

   protected RestrictionHandler<T> getRestrictionHandler() {
      return restrictionHandler;
   }

   @Test
   public void testAsCastedObject() {
      T actualObject = restrictionHandler.asCastedObject(validRestriction);
      Assert.assertNotNull(actualObject);
      Assert.assertEquals(validRestriction, actualObject);
   }

   @Test
   public void testAsCastedObjectReturnsNull() {
      ObjectRestriction objectRestriction = MockModel.createObjectRestriction();
      T actualObject = restrictionHandler.asCastedObject(objectRestriction);
      Assert.assertNull(actualObject);
   }

   @Test
   public void testProcessNullObjectRestriction() throws OseeCoreException {
      DslAsserts.assertNullAccessDetail(restrictionHandler, null, null);
   }

   @Test
   public void testProcessInvalidObjectRestriction() throws OseeCoreException {
      DslAsserts.assertNullAccessDetail(restrictionHandler, invalidRestriction, null);
   }
}

Back to the top