/* Copyright (C) 2008-2009 by Claas Wilke (claaswilke@gmx.net) This file is part of the OCL2 Parser Test Suite of Dresden OCL2 for Eclipse. Dresden OCL2 for Eclipse is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Dresden OCL2 for Eclipse is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Dresden OCL2 for Eclipse. If not, see <http://www.gnu.org/licenses/>. */ package org.dresdenocl.ocl2parser.test.standardlibrary; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; import org.junit.Ignore; import org.junit.Test; import org.dresdenocl.essentialocl.expressions.ExpressionInOcl; import org.dresdenocl.essentialocl.expressions.OclExpression; import org.dresdenocl.essentialocl.expressions.OperationCallExp; import org.dresdenocl.ocl2parser.test.TestPerformer; import org.dresdenocl.pivotmodel.Constraint; /** * <p> * Contains test cases that check that all operations defined on the type * Integer are parsed appropriately. * </p> * * @author Claas Wilke */ public class TestInteger { /** * <p> * A test case testing the method <code>Integer.abs()</code>. * </p> */ @Test public void testAbsPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/absPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.+(Integer)</code>. * </p> */ @Test public void testAddPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/addPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.+(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testAddPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/addPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.div(Integer)</code>. * </p> */ @Test public void testDivPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/divPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer./(Integer)</code>. * </p> */ @Test public void testDivisionPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/divisionPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer./(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testDivisionPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/divisionPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method * <code>Integer.greaterThanEqual(Integer)</code>. * </p> */ @Test public void testGreaterThanEqualPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/greaterThanEqualPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method * <code>Integer.greaterThanEqual(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testGreaterThanEqualPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/greaterThanEqualPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.greaterThan(Integer)</code>. * </p> */ @Test public void testGreaterThanPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/greaterThanPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.greaterThan(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testGreaterThanPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/greaterThanPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method * <code>Integer.lessThanEqual(Integer)</code>. * </p> */ @Test public void testLessThanEqualPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/lessThanEqualPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method * <code>Integer.lessThanEqual(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testLessThanEqualPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/lessThanEqualPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.lessThan(Integer)</code>. * </p> */ @Test public void testLessThanPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/lessThanPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.lessThan(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testLessThanPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/lessThanPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.max(Integer)</code>. * </p> */ @Test public void testMaxPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/maxPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.min(Integer)</code>. * </p> */ @Test public void testMinPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/minPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.-(Integer)</code>. * </p> */ @Test public void testMinusPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/minusPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.-(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testMinusPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/minusPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.mod(Integer)</code>. * </p> */ @Test public void testModPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/modPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.*(Integer)</code>. * </p> */ @Test public void testMultiplyPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/multiplyPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.*(Integer)</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testMultiplyPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/multiplyPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.-()</code>. * </p> */ @Test public void testNegationPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/negationPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.-()</code>. * </p> */ @Test @Ignore("Postfix syntax for infix operators is currently not possible using EMFText.") public void testNegationPositive02() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/negationPositive02.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } /** * <p> * A test case testing the method <code>Integer.-()</code>. * </p> */ @Test public void testNegationPositive03() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/negationPositive03.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ List<Constraint> parsedConstraints; parsedConstraints = testPerformer.parseFile(oclFileName); assertEquals(1, parsedConstraints.size()); /* Check that the parsed expression is correct. */ OclExpression exp = ((ExpressionInOcl) parsedConstraints.iterator() .next().getSpecification()).getBodyExpression(); /* Root should be an OperationCallExp on =. */ assertTrue(exp instanceof OperationCallExp); OperationCallExp opCallExp = (OperationCallExp) exp; assertEquals("=", opCallExp.getReferredOperation().getName()); /* Source should be an OperationCallExp on abs. */ exp = opCallExp.getSource(); assertTrue(exp instanceof OperationCallExp); opCallExp = (OperationCallExp) exp; assertEquals("abs", opCallExp.getReferredOperation().getName()); /* Source should be OperationCallExp on - */ exp = opCallExp.getSource(); assertTrue(exp instanceof OperationCallExp); opCallExp = (OperationCallExp) exp; assertEquals("-", opCallExp.getReferredOperation().getName()); } /** * <p> * A test case testing the method <code>Integer.toString()</code>. * </p> */ @Test public void testToStringPositive01() throws Exception { TestPerformer testPerformer; String modelFileName; String oclFileName; oclFileName = "standardlibrary/integer/toStringPositive01.ocl"; modelFileName = "testmodel.uml"; /* Try to get the TestPerformer. */ testPerformer = TestPerformer.getInstance( AllStandardLibraryTests.META_MODEL_ID, AllStandardLibraryTests.MODEL_BUNDLE, AllStandardLibraryTests.MODEL_DIRECTORY); testPerformer.setModel(modelFileName); /* Try to parse the constraint file. */ testPerformer.parseFile(oclFileName); } }