/* Copyright (C) 2010 by Claas Wilke (claas.wilke@tu-dresden.de) This file is part of the PAIN Case Study of Dresden OCL. Dresden OCL 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 OCL 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 OCL. If not, see <http://www.gnu.org/licenses/>. */ package org.dresdenocl.interpreter.test.standardlibrary; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.Arrays; import java.util.List; import org.junit.Test; import org.dresdenocl.interpreter.IInterpretationResult; import org.dresdenocl.model.ModelAccessException; import org.dresdenocl.parser.ParseException; /** * <p> * Contains some test cases to test Standard Library operations on * <code>Boolean</code>s. * </p> * * @author Claas Wilke */ public class TestString extends AbstractInterpreterTest { /** The name of the constraint directory for this test suite. */ private static final String CONSTRAINT_DIRECTORY = "standardlibrary/string"; /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan01() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan01", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan02() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan02", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan03() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan03", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan04() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan04", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan05() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan05", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan06() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan06", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan07() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan07", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThan08() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThan08", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals01() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals01", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals02() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals02", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals03() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals03", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals04() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals04", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals05() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals05", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals06() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals06", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals07() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals07", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.>=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testGreaterThanEquals08() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/greaterThanEquals08", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan01() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan01", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan02() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan02", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan03() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan03", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan04() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan04", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan05() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan05", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan06() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan06", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan07() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan07", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThan08() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThan08", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual01() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual01", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual02() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual02", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual03() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual03", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsTrue(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual04() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual04", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsFalse(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual05() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual05", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual06() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual06", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual07() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual07", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } /** * <p> * Tests the operation <code>String.<=(String)</code>. * </p> * * @throws ParseException * @throws ModelAccessException * @throws IllegalArgumentException */ @Test public void testLessThanEqual08() throws IllegalArgumentException, ModelAccessException, ParseException { List<IInterpretationResult> results; results = super.interpretConstraintsForInstance(MODEL1_NAME, CONSTRAINT_DIRECTORY + "/lessThanEqual08", INSTANCE1_NAME, Arrays.asList(new String[] { "Class1" })); assertNotNull(results); assertEquals(1, results.size()); this.assertIsInvalid(results.get(0)); } }