/*
 * $Id$
 *
 * SARL is an general-purpose agent programming language.
 * More details on http://www.sarl.io
 *
 * Copyright (C) 2014-2026 SARL.io, the original authors and main authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.sarl.lang.tests.general.parsing.aop;

import static io.sarl.lang.tests.api.tools.TestAssertions.assertParameterDefaultValues;
import static org.eclipse.xtext.xbase.validation.IssueCodes.*;
import static io.sarl.tests.api.tools.TestAssertions.assertNoMoreIssues;
import static io.sarl.tests.api.tools.TestAssertions.assertNullOrEmpty;
import static io.sarl.tests.api.tools.TestAssertions.assertParameterNames;
import static io.sarl.tests.api.tools.TestAssertions.assertParameterTypes;
import static io.sarl.tests.api.tools.TestAssertions.assertTypeReferenceIdentifier;
import static io.sarl.tests.api.tools.TestAssertions.assertTypeReferenceIdentifiers;
import static io.sarl.tests.api.tools.TestAssertions.assertWarning;
import static io.sarl.tests.api.tools.TestAssertions.assertXExpression;
import static io.sarl.tests.api.tools.TestEObjects.file;
import static io.sarl.tests.api.tools.TestEObjects.issues;
import static io.sarl.tests.api.tools.TestUtils.multilineString;
import static io.sarl.tests.api.tools.TestValidator.validate;
import static org.eclipse.xtend.core.validation.IssueCodes.FIELD_NOT_INITIALIZED;
import static org.eclipse.xtend.core.validation.IssueCodes.INVALID_MEMBER_NAME;
import static org.eclipse.xtend.core.validation.IssueCodes.INVALID_MODIFIER;
import static org.eclipse.xtend.core.validation.IssueCodes.MISSING_ABSTRACT;
import static org.eclipse.xtend.core.validation.IssueCodes.MISSING_OVERRIDE;
import static org.eclipse.xtend.core.validation.IssueCodes.OBSOLETE_OVERRIDE;
import static org.eclipse.xtext.xbase.validation.IssueCodes.CLASS_EXPECTED;
import static org.eclipse.xtext.xbase.validation.IssueCodes.DUPLICATE_FIELD;
import static org.eclipse.xtext.xbase.validation.IssueCodes.DUPLICATE_METHOD;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;

import com.google.common.base.Strings;
import org.eclipse.xtext.common.types.JvmTypeConstraint;
import org.eclipse.xtext.common.types.JvmTypeParameter;
import org.eclipse.xtext.common.types.JvmVisibility;
import org.eclipse.xtext.common.types.TypesPackage;
import org.eclipse.xtext.validation.Issue;
import org.eclipse.xtext.xbase.XNumberLiteral;
import org.eclipse.xtext.xbase.XStringLiteral;
import org.eclipse.xtext.xbase.XbasePackage;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.sarl.lang.sarl.SarlAction;
import io.sarl.lang.sarl.SarlAgent;
import io.sarl.lang.sarl.SarlCapacity;
import io.sarl.lang.sarl.SarlCapacityUses;
import io.sarl.lang.sarl.SarlField;
import io.sarl.lang.sarl.SarlPackage;
import io.sarl.lang.sarl.SarlScript;
import io.sarl.lang.sarl.SarlSkill;
import io.sarl.lang.tests.api.AbstractSarlTest;
import io.sarl.lang.validation.IssueCodes;

/**
 * @author $Author: srodriguez$
 * @author $Author: sgalland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
 */
@SuppressWarnings("all")
@DisplayName("Syntax: skill")
@Tag("core")
public class SkillParsingTest {

	@Nested
	public class TopElementTest extends AbstractSarlTest {

		@Test
		@Tag("sarlValidation")
		public void capacityDirectImplementation() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"import io.sarl.lang.core.Capacity",
					"skill S1 implements Capacity {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_IMPLEMENTED_TYPE,
					"Invalid implemented type: 'io.sarl.lang.core.Capacity'. Only subtypes of 'io.sarl.lang.core.Capacity' are allowed for 'S1'");
		}

		@Test
		@Tag("sarlValidation")
		public void redundantCapacity_fromSuperType() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {}",
					"capacity C2 {}",
					"skill S1 implements C1 { }",
					"skill S2 extends S1 implements C2, C1 { }"
					));
			validate(getValidationHelper(), getInjector(), mas).assertWarning(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.REDUNDANT_INTERFACE_IMPLEMENTATION,
					"The feature 'C1' is already implemented by the super-type 'S1'");
		}

		@Test
		@Tag("sarlValidation")
		public void redundantCapacity_duplicate() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {}",
					"capacity C2 {}",
					"capacity C3 {}",
					"skill S1 implements C1 { }",
					"skill S2 extends S1 implements C2, C3, C2 { }"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.REDUNDANT_INTERFACE_IMPLEMENTATION,
					"Duplicate implemented feature 'C2'");
		}

		@Test
		@Tag("sarlValidation")
		public void redundantCapacity_fromPreviousCapacity() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {}",
					"capacity C2 {}",
					"capacity C3 extends C2 {}",
					"skill S1 implements C1 { }",
					"skill S2 extends S1 implements C3, C2 { }"
					));
			validate(getValidationHelper(), getInjector(), mas).assertWarning(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.REDUNDANT_INTERFACE_IMPLEMENTATION,
					"The feature 'C2' is already implemented by the super-type 'C3'");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillExtend_0() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {",
					"}",
					"agent A1 {",
					"}",
					"skill S1 extends A1 implements C1 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_EXTENDED_TYPE,
					"Supertype must be of type 'io.sarl.lang.core.Skill'");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillExtend_1() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {",
					"}",
					"capacity C2 {",
					"}",
					"skill S1 extends C1 implements C2 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					CLASS_EXPECTED,
					"Invalid supertype. Expecting a class");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillImplement_0() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"behavior B1 {",
					"}",
					"skill S1 implements B1 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_IMPLEMENTED_TYPE,
					"Invalid implemented type: 'B1'. Only subtypes of 'io.sarl.lang.core.Capacity' are allowed for 'S1'");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillImplement_1() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"behavior B1 {",
					"}",
					"capacity C1 {",
					"}",
					"capacity C2 {",
					"}",
					"skill S1 implements B1, C1, C2 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_IMPLEMENTED_TYPE,
					"Invalid implemented type: 'B1'. Only subtypes of 'io.sarl.lang.core.Capacity' are allowed for 'S1'");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillImplement_2() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"behavior B1 {",
					"}",
					"capacity C1 {",
					"}",
					"capacity C2 {",
					"}",
					"skill S1 implements C1, B1, C2 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_IMPLEMENTED_TYPE,
					"Invalid implemented type: 'B1'. Only subtypes of 'io.sarl.lang.core.Capacity' are allowed for 'S1'");
		}

		@Test
		@Tag("sarlValidation")
		public void invalidSkillImplement_3() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"behavior B1 {",
					"}",
					"capacity C1 {",
					"}",
					"capacity C2 {",
					"}",
					"skill S1 implements C1, C2, B1 {",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					IssueCodes.INVALID_IMPLEMENTED_TYPE,
					"Invalid implemented type: 'B1'. Only subtypes of 'io.sarl.lang.core.Capacity' are allowed for 'S1'");
		}

		@Test
		@Tag("sarlParsing")
		public void skillImplementCapacity() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"capacity C1 {",
					"	def myaction",
					"}",
					"skill S1 implements C1 {",
					"	def myaction { }",
					"}"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertTrue(Strings.isNullOrEmpty(mas.getPackage()));
			//
			SarlCapacity capacity = (SarlCapacity) mas.getXtendTypes().get(0);
			assertEquals("C1", capacity.getName());
			assertTypeReferenceIdentifiers(capacity.getExtends());
			assertEquals(1, capacity.getMembers().size());
			//
			SarlAction signature = (SarlAction) capacity.getMembers().get(0);
			assertEquals("myaction", signature.getName());
			assertTypeReferenceIdentifiers(signature.getFiredEvents());
			assertTypeReferenceIdentifier(signature.getReturnType(), "void");
			assertParameterNames(signature.getParameters());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertTypeReferenceIdentifiers(skill.getImplements(), "C1");
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction action = (SarlAction) skill.getMembers().get(0);
			assertEquals("myaction", action.getName());
			assertTypeReferenceIdentifiers(action.getFiredEvents());
			assertTypeReferenceIdentifier(action.getReturnType(), "void");
			assertParameterNames(action.getParameters());
		}

		@Test
		@Tag("sarlParsing")
		public void skillExtendSkill() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"capacity C1 {",
					"	def myaction",
					"}",
					"skill S1 implements C1 {",
					"	def myaction { }",
					"}",
					"skill S2 extends S1 {",
					"	def myaction { }",
					"}"
					));
			assertEquals(3, mas.getXtendTypes().size());
			//
			assertTrue(Strings.isNullOrEmpty(mas.getPackage()));
			//
			SarlCapacity capacity = (SarlCapacity) mas.getXtendTypes().get(0);
			assertEquals("C1", capacity.getName());
			assertTrue(capacity.getExtends().isEmpty());
			assertEquals(1, capacity.getMembers().size());
			//
			SarlAction signature = (SarlAction) capacity.getMembers().get(0);
			assertEquals("myaction", signature.getName());
			assertTrue(signature.getFiredEvents().isEmpty());
			assertTypeReferenceIdentifier(signature.getReturnType(), "void");
			assertParameterNames(signature.getParameters());
			//
			SarlSkill skill1 = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill1.getName());
			assertTrue(capacity.getExtends().isEmpty());
			assertTypeReferenceIdentifiers(skill1.getImplements(), "C1");
			assertEquals(1, skill1.getMembers().size());
			//
			SarlAction action1 = (SarlAction) skill1.getMembers().get(0);
			assertEquals("myaction", action1.getName());
			assertTrue(signature.getFiredEvents().isEmpty());
			assertTypeReferenceIdentifier(action1.getReturnType(), "void");
			assertParameterNames(action1.getParameters());
			//
			SarlSkill skill2 = (SarlSkill) mas.getXtendTypes().get(2);
			assertEquals("S2", skill2.getName());
			assertTypeReferenceIdentifier(skill2.getExtends(), "S1");
			assertTrue(skill2.getImplements().isEmpty());
			assertEquals(1, skill2.getMembers().size());
			//
			SarlAction action2 = (SarlAction) skill2.getMembers().get(0);
			assertEquals("myaction", action2.getName());
			assertTrue(signature.getFiredEvents().isEmpty());
			assertTypeReferenceIdentifier(action2.getReturnType(), "void");
			assertParameterNames(action2.getParameters());
		}

		@Test
		@Tag("sarlParsing")
		public void skillExtendSkillImplementCapacity() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"capacity C1 {",
					"	def myaction",
					"}",
					"capacity C2 {",
					"	def myaction2",
					"}",
					"skill S1 implements C1 {",
					"	def myaction { }",
					"}",
					"skill S2 extends S1 implements C2 {",
					"	def myaction { }",
					"	def myaction2 { }",
					"}"
					));
			assertEquals(4, mas.getXtendTypes().size());
			//
			assertTrue(Strings.isNullOrEmpty(mas.getPackage()));
			//
			SarlCapacity capacity1 = (SarlCapacity) mas.getXtendTypes().get(0);
			assertEquals("C1", capacity1.getName());
			assertTrue(capacity1.getExtends().isEmpty());
			assertEquals(1, capacity1.getMembers().size());
			//
			SarlAction signature1 = (SarlAction) capacity1.getMembers().get(0);
			assertEquals("myaction", signature1.getName());
			assertTrue(signature1.getFiredEvents().isEmpty());
			assertTypeReferenceIdentifier(signature1.getReturnType(), "void");
			assertParameterNames(signature1.getParameters());
			//
			SarlCapacity capacity2 = (SarlCapacity) mas.getXtendTypes().get(1);
			assertEquals("C2", capacity2.getName());
			assertTypeReferenceIdentifiers(capacity2.getExtends());
			assertEquals(1, capacity2.getMembers().size());
			//
			SarlAction signature2 = (SarlAction) capacity2.getMembers().get(0);
			assertEquals("myaction2", signature2.getName());
			assertTypeReferenceIdentifiers(signature2.getFiredEvents());
			assertTypeReferenceIdentifier(signature2.getReturnType(), "void");
			assertParameterNames(signature2.getParameters());
			//
			SarlSkill skill1 = (SarlSkill) mas.getXtendTypes().get(2);
			assertEquals("S1", skill1.getName());
			assertNull(skill1.getExtends());
			assertTypeReferenceIdentifiers(skill1.getImplements(), "C1");
			assertEquals(1, skill1.getMembers().size());
			//
			SarlAction action1 = (SarlAction) skill1.getMembers().get(0);
			assertEquals("myaction", action1.getName());
			assertTypeReferenceIdentifiers(action1.getFiredEvents());
			assertTypeReferenceIdentifier(action1.getReturnType(), "void");
			assertParameterNames(action1.getParameters());
			//
			SarlSkill skill2 = (SarlSkill) mas.getXtendTypes().get(3);
			assertEquals("S2", skill2.getName());
			assertTypeReferenceIdentifier(skill2.getExtends(), "S1");
			assertTypeReferenceIdentifiers(skill2.getImplements(), "C2");
			assertEquals(2, skill2.getMembers().size());
			//
			SarlAction action2 = (SarlAction) skill2.getMembers().get(0);
			assertEquals("myaction", action2.getName());
			assertTypeReferenceIdentifiers(action2.getFiredEvents());
			assertTypeReferenceIdentifier(action2.getReturnType(), "void");
			assertParameterNames(action2.getParameters());
			//
			SarlAction action3 = (SarlAction) skill2.getMembers().get(1);
			assertEquals("myaction2", action3.getName());
			assertTypeReferenceIdentifiers(action3.getFiredEvents());
			assertTypeReferenceIdentifier(action3.getReturnType(), "void");
			assertParameterNames(action3.getParameters());
		}

		@Test
		@Tag("sarlValidation")
		public void skillNoExtendSkillNoImplementCapacity() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"skill S1 {",
					"	def myaction { }",
					"}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					org.eclipse.xtext.xbase.validation.IssueCodes.MISSING_TYPE,
					"Missing implemented type 'io.sarl.lang.core.Capacity' for 'S1'");
		}

		@Test
		@Tag("sarlParsing")
		public void skillmodifier_public() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"public skill S1 implements C1 {}"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(JvmVisibility.PUBLIC, skill.getVisibility());
			assertEquals(0, skill.getMembers().size());
			assertFalse(skill.isAbstract());
			assertFalse(skill.isFinal());
			assertFalse(skill.isStatic());
			assertFalse(skill.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void skillmodifier_none() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"skill S1 implements C1 {}"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(JvmVisibility.PUBLIC, skill.getVisibility());
			assertEquals(0, skill.getMembers().size());
			assertFalse(skill.isAbstract());
			assertFalse(skill.isFinal());
			assertFalse(skill.isStatic());
			assertFalse(skill.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_private() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"private skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_protected() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"protected skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlParsing")
		public void skillmodifier_package() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"package skill S1 implements C1 {}"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(JvmVisibility.DEFAULT, skill.getVisibility());
			assertEquals(0, skill.getMembers().size());
			assertFalse(skill.isAbstract());
			assertFalse(skill.isFinal());
			assertFalse(skill.isStatic());
			assertFalse(skill.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void skillmodifier_abstract() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"abstract skill S1 implements C1 { }"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(JvmVisibility.PUBLIC, skill.getVisibility());
			assertEquals(0, skill.getMembers().size());
			assertTrue(skill.isAbstract());
			assertFalse(skill.isFinal());
			assertFalse(skill.isStatic());
			assertFalse(skill.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_static() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"static skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_dispatch() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"dispatch skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlParsing")
		public void skillmodifier_final() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"final skill S1 implements C1 {}"
					));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(JvmVisibility.PUBLIC, skill.getVisibility());
			assertEquals(0, skill.getMembers().size());
			assertFalse(skill.isAbstract());
			assertTrue(skill.isFinal());
			assertFalse(skill.isStatic());
			assertFalse(skill.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_strictfp() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"strictfp skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_native() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"native skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_volatile() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"volatile skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_synchronized() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"synchronized skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_transient() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"transient skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER);
		}

		@Test
		@Tag("sarlValidation")
		public void skillmodifier_public_package() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 {}",
					"public package skill S1 implements C1 {}"
					));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					INVALID_MODIFIER,
					"public, package, final or abstract");
		}

		@Test
		@Tag("sarlValidation")
		public void abstractSkill() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"capacity C1 {",
					"	def fct(a : int = 4)",
					"}",
					"skill S1 implements C1 { }"));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlSkill(),
					CLASS_MUST_BE_ABSTRACT,
					"class S1 must be defined abstract");
		}

	}

	@Nested
	public class ActionTest extends AbstractSarlTest {

		@Test
		@Tag("sarlValidation")
		public void modifier_override_possible_but_no_warning() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { def fakefct() }",
					"abstract skill S1 implements C1 {",
					"   override fakefct() { }",
					"	abstract def name",
					"}",
					"skill S2 extends S1 {",
					"	def name { }",
					"}"));
			validate(getValidationHelper(), getInjector(), mas).assertNoWarnings(
					SarlPackage.eINSTANCE.getSarlAction(),
					MISSING_OVERRIDE);
		}

		@Test
		@Tag("sarlValidation")
		public void modifier_override_invalid() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { def fakefct() }",
					"skill S1 implements C1 {",
					"  override fakefct() { }",
					"}",
					"skill S2 extends S1 {",
					"	override name { }",
					"}"));
			validate(getValidationHelper(), getInjector(), mas).assertError(
					SarlPackage.eINSTANCE.getSarlAction(),
					OBSOLETE_OVERRIDE,
					"The method name() of type S2 must override a superclass method");
		}

		@Test
		@Tag("sarlValidation")
		public void modifier_override_valid() throws Exception {
			SarlScript mas = file(getParseHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { def fakefct() }",
					"abstract skill S1 implements C1 {",
					"   override fakefct() { }",
					"	abstract def name()",
					"}",
					"skill S2 extends S1 {",
					"   override fakefct() { }",
					"	override name() { }",
					"}"));
			validate(getValidationHelper(), getInjector(), mas).assertNoIssues();
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_public() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	public def name { }",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
			assertEquals(JvmVisibility.PUBLIC, act1.getVisibility());
			assertFalse(act1.isAbstract());
			assertFalse(act1.isStatic());
			assertFalse(act1.isDispatch());
			assertFalse(act1.isFinal());
			assertFalse(act1.isSynchonized());
			assertFalse(act1.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_private() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	private def name { }",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
			assertEquals(JvmVisibility.PRIVATE, act1.getVisibility());
			assertFalse(act1.isAbstract());
			assertFalse(act1.isStatic());
			assertFalse(act1.isDispatch());
			assertFalse(act1.isFinal());
			assertFalse(act1.isSynchonized());
			assertFalse(act1.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_protected() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	protected def name { }",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
			assertEquals(JvmVisibility.PROTECTED, act1.getVisibility());
			assertFalse(act1.isAbstract());
			assertFalse(act1.isStatic());
			assertFalse(act1.isDispatch());
			assertFalse(act1.isFinal());
			assertFalse(act1.isSynchonized());
			assertFalse(act1.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_package() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	package def name { }",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
			assertEquals(JvmVisibility.DEFAULT, act1.getVisibility());
			assertFalse(act1.isAbstract());
			assertFalse(act1.isStatic());
			assertFalse(act1.isDispatch());
			assertFalse(act1.isFinal());
			assertFalse(act1.isSynchonized());
			assertFalse(act1.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_none() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	def name { }",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
			assertEquals(JvmVisibility.PUBLIC, act1.getVisibility());
			assertFalse(act1.isAbstract());
			assertFalse(act1.isStatic());
			assertFalse(act1.isDispatch());
			assertFalse(act1.isFinal());
			assertFalse(act1.isSynchonized());
			assertFalse(act1.isStrictFloatingPoint());
		}

		@Test
		@Tag("sarlParsing")
		public void modifier_abstract() throws Exception {
			SarlScript mas = file(getParseHelper(), getValidationHelper(), multilineString(
					"package io.sarl.lang.tests.test",
					"capacity C1 { }",
					"abstract skill S1 implements C1 {",
					"	abstract def name",
					"}"));
			assertEquals(2, mas.getXtendTypes().size());
			//
			assertEquals("io.sarl.lang.tests.test", mas.getPackage());
			//
			SarlSkill skill = (SarlSkill) mas.getXtendTypes().get(1);
			assertEquals("S1", skill.getName());
			assertNull(skill.getExtends());
			assertEquals(1, skill.getMembers().size());
			//
			SarlAction act1 = (SarlAction) skill.getMembers().get(0);
			assertEquals("name", act1.getName());
