package migr.test.tests;

/*Generated by MPS */

import jetbrains.mps.MPSLaunch;
import jetbrains.mps.lang.test.runtime.BaseTransformationTest;
import org.junit.jupiter.api.extension.RegisterExtension;
import jetbrains.mps.lang.test.runtime.TestParametersCacheExtension;
import jetbrains.mps.lang.test.runtime.TestParametersCache;
import jetbrains.mps.lang.test.runtime.ExecuteCommandExtension;
import org.junit.jupiter.api.Test;
import jetbrains.mps.lang.test.runtime.BaseMigrationTestBody;
import jetbrains.mps.lang.test.runtime.TransformationTest;
import java.util.Collection;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import java.util.ArrayList;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.migration.runtime.base.MigrationScript;
import decl.migration.SampleDeclMigration;
import ref.migration.SampleRefMigration;
import java.util.List;
import jetbrains.mps.lang.migration.runtime.base.MigrationScriptReference;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.internal.collections.runtime.CollectionSequence;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SProperty;

@MPSLaunch
public class SampleDeclMigration_Test extends BaseTransformationTest {
  @RegisterExtension
  private static final TestParametersCacheExtension ourParametersCacheExtension = new TestParametersCacheExtension(new TestParametersCache(SampleDeclMigration_Test.class, "${module}/../..", "r:6e4b2d34-6979-4587-970a-72cdf9e24f7c(migr.test.tests@tests)", false));

  @RegisterExtension
  private ExecuteCommandExtension myCommandExtension = new ExecuteCommandExtension(this);

  public SampleDeclMigration_Test() {
    super(ourParametersCacheExtension.getParametersCache());
  }

  @Test
  public void test_SampleDeclMigration_Test() throws Throwable {
    new TestBody(this).testMethod();
  }

  /*package*/ static class TestBody extends BaseMigrationTestBody {

    /*package*/ TestBody(TransformationTest owner) {
      super(owner);
    }

    @Override
    public Collection<SNode> getInputNodes() {
      return ListSequence.fromListAndArray(new ArrayList<SNode>(), SLinkOperations.getTarget(SNodeOperations.cast(getRealNodeById("6109541130559844919"), CONCEPTS.TestNode$zF), LINKS.nodeToCheck$OBcW), SLinkOperations.getTarget(SNodeOperations.cast(getRealNodeById("6109541130559844928"), CONCEPTS.TestNode$zF), LINKS.nodeToCheck$OBcW));
    }
    @Override
    public Collection<SNode> getOutputNodes() {
      return ListSequence.fromListAndArray(new ArrayList<SNode>(), SLinkOperations.getTarget(SNodeOperations.cast(getRealNodeById("6109541130559846225"), CONCEPTS.TestNode$zF), LINKS.nodeToCheck$OBcW), SLinkOperations.getTarget(SNodeOperations.cast(getRealNodeById("6109541130559846226"), CONCEPTS.TestNode$zF), LINKS.nodeToCheck$OBcW));
    }
    @Override
    public MigrationScript[] getMigrationScript() {
      return new MigrationScript[]{new SampleDeclMigration(), new SampleRefMigration()};
    }
    @Override
    public void postProcess(Collection<SNode> output) {
      List<MigrationScriptReference> allScripts = ListSequence.fromListAndArray(new ArrayList<MigrationScriptReference>(), new MigrationScriptReference(MetaAdapterFactory.getLanguage(0x9de7c5ceea6f4fb4L, 0xa7ba45e62b53cbadL, "decl"), 1));
      for (SNode root : CollectionSequence.fromCollection(output)) {
        for (SNode data : ListSequence.fromList(SNodeOperations.getNodeDescendants(root, CONCEPTS.MigrationDataAnnotation$Ct, false, new SAbstractConcept[]{}))) {
          if (ListSequence.fromList(allScripts).contains(MigrationScriptReference.deserialize(SPropertyOperations.getString(data, PROPS.createdByScript$dQMM)))) {
            SNodeOperations.deleteNode(data);
          }
        }
      }
    }
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept TestNode$zF = MetaAdapterFactory.getConcept(0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x11b5a38fc01L, "jetbrains.mps.lang.test.structure.TestNode");
    /*package*/ static final SConcept MigrationDataAnnotation$Ct = MetaAdapterFactory.getConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x78c7e79625990591L, "jetbrains.mps.lang.core.structure.MigrationDataAnnotation");
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink nodeToCheck$OBcW = MetaAdapterFactory.getContainmentLink(0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x11b5a38fc01L, 0x11b5a397b92L, "nodeToCheck");
  }

  private static final class PROPS {
    /*package*/ static final SProperty createdByScript$dQMM = MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x78c7e79625a38e13L, 0x78c7e79625a38e14L, "createdByScript");
  }
}
