/*
 * $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.compilation.aop;

import static io.sarl.tests.api.tools.TestAssertions.assertEqualsExceptNewLines;
import static io.sarl.tests.api.tools.TestUtils.multilineString;

import org.eclipse.xtext.util.IAcceptor;
import org.eclipse.xtext.xbase.testing.CompilationTestHelper;
import org.eclipse.xtext.xbase.testing.CompilationTestHelper.Result;
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.core.SARLVersion;
import io.sarl.lang.sarl.SarlPackage;
import io.sarl.lang.tests.api.AbstractSarlTest;

/**
 * @author $Author: srodriguez$
 * @author $Author: sgalland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
 */
@SuppressWarnings("all")
@DisplayName("Compilation: Skill")
@Tag("core")
@Tag("compileToJava")
public class SkillCompilerTest {

	@Nested
	@DisplayName("Field")
	public class FieldTest extends AbstractSarlTest {

		@Test
		public void fieldmodifier_none() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, (r) -> assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1")));
		}

		@Test
		public void fieldmodifier_package() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  package var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_protected() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  protected var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  protected int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_private() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  private var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_public() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  public var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  public int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_final() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  val field : int = 5",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private final int field = 5;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, (r) -> assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1")));
		}

		@Test
		public void fieldmodifier_static() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  static var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private static int field;",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_transient() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  transient var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private transient int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void fieldmodifier_volatile() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  volatile var field : int",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private volatile int field;",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field != this.field)",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void completeFinalFieldInitialization() throws Exception {
			final String expectedC1 = multilineString(
					"import io.sarl.lang.core.AgentTrait;",
					"import io.sarl.lang.core.Capacity;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_CAPACITY + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public interface C1 extends Capacity {",
					"  /**",
					"   * @ExcludeFromApidoc",
					"   */",
					"  class ContextAwareCapacityWrapper<C extends C1> extends Capacity.ContextAwareCapacityWrapper<C> implements C1 {",
					"    public ContextAwareCapacityWrapper(final C capacity, final AgentTrait caller) {",
					"      super(capacity, caller);",
					"    }",
					"  }",
					"}",
					""
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import java.util.Objects;",
					"import org.eclipse.xtext.xbase.lib.Pure;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private final int field1 = 5;",
					"  ",
					"  private final String field2 = \"\";",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public boolean equals(final Object obj) {",
					"    if (this == obj)",
					"      return true;",
					"    if (obj == null)",
					"      return false;",
					"    if (getClass() != obj.getClass())",
					"      return false;",
					"    S1 other = (S1) obj;",
					"    if (other.field1 != this.field1)",
					"      return false;",
					"    if (!Objects.equals(this.field2, other.field2))",
					"      return false;",
					"    return super.equals(obj);",
					"  }",
					"  ",
					"  @Override",
					"  @Pure",
					"  @SyntheticMember",
					"  public int hashCode() {",
					"    int result = super.hashCode();",
					"    final int prime = 31;",
					"    result = prime * result + Integer.hashCode(this.field1);",
					"    result = prime * result + Objects.hashCode(this.field2);",
					"    return result;",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  val field1 : int = 5",
					"  val field2 : String = \"\"",
					"}"
					);
			getCompileHelper().compile(source, (r) -> {
					assertEqualsExceptNewLines(expectedC1,r.getGeneratedCode("C1"));
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				});
		}

	}

	@Nested
	@DisplayName("Action")
	public class ActionTest extends AbstractSarlTest {

		@Test
		public void actionmodifier_override() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"	def name",
					"}",
					"skill S2 extends S1 {",
					"	override name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public abstract class S1 extends Skill implements C1 {",
					"  public abstract void name();",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			final String expectedS2 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Capacity;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S2 extends S1 implements Capacity {",
					"  @Override",
					"  public void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S2() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S2(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, (r) -> {
					assertEqualsExceptNewLines(expectedS1, r.getGeneratedCode("S1"));
					assertEqualsExceptNewLines(expectedS2, r.getGeneratedCode("S2"));
				});
		}

		@Test
		public void actionmodifier_none() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  def name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  public void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, (r) -> assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1")));
		}

		@Test
		public void actionmodifier_public() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  public def name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  public void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void actionmodifier_protected() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  protected def name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  protected void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void actionmodifier_package() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  package def name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void actionmodifier_private() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  private def name {}",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
					"import io.sarl.lang.core.Skill;",
					"import io.sarl.lang.core.annotation.SarlElementType;",
					"import io.sarl.lang.core.annotation.SarlSpecification;",
					"import io.sarl.lang.core.annotation.SyntheticMember;",
					"import org.eclipse.xtext.xbase.lib.XbaseGenerated;",
					"",
					"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")",
					"@SarlElementType(" + SarlPackage.SARL_SKILL + ")",
					"@XbaseGenerated",
					"@SuppressWarnings(\"all\")",
					"public class S1 extends Skill implements C1 {",
					"  private void name() {",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1() {",
					"    super();",
					"  }",
					"  ",
					"  @SyntheticMember",
					"  public S1(final Agent arg0) {",
					"    super(arg0);",
					"  }",
					"}",
					""
					);
			getCompileHelper().compile(source, new IAcceptor<CompilationTestHelper.Result>() {
				@Override
				public void accept(Result r) {
					assertEqualsExceptNewLines(expectedS1,r.getGeneratedCode("S1"));
				}
			});
		}

		@Test
		public void actionmodifier_abstract_explicit() throws Exception {
			String source = multilineString(
					"capacity C1 { }",
					"skill S1 implements C1 {",
					"  abstract def name",
					"}"
					);
			final String expectedS1 = multilineString(
					"import io.sarl.lang.core.Agent;",
