package jetbrains.mps.lang.quotation.test.generationTest;

/*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 org.junit.jupiter.api.Test;
import jetbrains.mps.lang.test.runtime.BaseTestBody;
import jetbrains.mps.lang.test.runtime.TransformationTest;
import org.jetbrains.mps.openapi.model.SModel;
import jetbrains.mps.smodel.tempmodel.TemporaryModels;
import jetbrains.mps.smodel.tempmodel.TempModuleOptions;
import jetbrains.mps.smodel.SNodeId;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;
import org.junit.Assert;
import java.util.Objects;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.builder.SNodeBuilder;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SContainmentLink;

@MPSLaunch
public class QuotationModelNodeId_Test extends BaseTransformationTest {
  @RegisterExtension
  private static final TestParametersCacheExtension ourParametersCacheExtension = new TestParametersCacheExtension(new TestParametersCache(QuotationModelNodeId_Test.class, "${mps_home}", "r:1cc42aa8-6d2d-49a0-9b1f-2e5f92988fc5(jetbrains.mps.lang.quotation.test.generationTest@tests)", false));

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

  @Test
  public void test_lightQuotation_nodeId() throws Throwable {
    new TestBody(this).test_lightQuotation_nodeId();
  }
  @Test
  public void test_quotation_nodeId() throws Throwable {
    new TestBody(this).test_quotation_nodeId();
  }
  @Test
  public void test_quotationTreeNodeId() throws Throwable {
    new TestBody(this).test_quotationTreeNodeId();
  }

  /*package*/ static class TestBody extends BaseTestBody {

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

    public void test_lightQuotation_nodeId() throws Exception {
      runWithinCommand(() -> {
        SModel model = TemporaryModels.getInstance().createEditable(false, TempModuleOptions.nonReloadableModule());
        SNodeId.Regular id = new SNodeId.Regular(239);
        SNode node = createReturnStatement_fw7ydn_a0c0a0a0d8(model, id);
        SModelOperations.addRootNode(model, node);
        Assert.assertTrue(node.getNodeId().equals(id));
        TemporaryModels.getInstance().dispose(model);
      });
    }
    public void test_quotation_nodeId() throws Exception {
      runWithinCommand(() -> {
        SModel model = TemporaryModels.getInstance().createEditable(false, TempModuleOptions.nonReloadableModule());
        SNodeId.Regular id = new SNodeId.Regular(239);
        SNode node = _quotation_createNode_fw7ydn_a0c0a0a0e8(model, id);
        SModelOperations.addRootNode(model, node);
        Assert.assertTrue(node.getNodeId().equals(id));
        TemporaryModels.getInstance().dispose(model);
      });
    }
    public void test_quotationTreeNodeId() throws Exception {
      runWithinCommand(() -> {
        // when quotation constructs a tree of nodes, make sure it's only the top one that gets the id
        SNodeId.Regular id = new SNodeId.Regular(239);
        SNode node = _quotation_createNode_fw7ydn_a0c0a0a0f8(null, id);
        Assert.assertTrue(Objects.equals(node.getNodeId(), id));
        Assert.assertEquals(2, ListSequence.fromList(SNodeOperations.getChildren(node)).count());
        Assert.assertFalse(Objects.equals(ListSequence.fromList(SNodeOperations.getChildren(node)).getElement(0).getNodeId(), id));
        Assert.assertFalse(Objects.equals(ListSequence.fromList(SNodeOperations.getChildren(node)).getElement(1).getNodeId(), id));
      });
    }

    private static SNode createReturnStatement_fw7ydn_a0c0a0a0d8(SModel modelToCreate, org.jetbrains.mps.openapi.model.SNodeId nodeId) {
      SNodeBuilder n0 = new SNodeBuilder(modelToCreate, nodeId).init(CONCEPTS.ReturnStatement$lt);
      n0.forChild(LINKS.expression$eJ92).init(CONCEPTS.NullLiteral$QQ);
      return n0.getResult();
    }
    private static SNode _quotation_createNode_fw7ydn_a0c0a0a0e8(Object parameter_1, Object parameter_2) {
      SNode quotedNode_3 = null;
      SNode quotedNode_4 = null;
      SNodeBuilder nb = new SNodeBuilder((SModel) parameter_1, (org.jetbrains.mps.openapi.model.SNodeId) parameter_2).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc67c7feL, "ReturnStatement"));
      quotedNode_3 = nb.getResult();
      SNodeBuilder nb1 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf940cd6167L, "NullLiteral"));
      quotedNode_4 = nb1.getResult();
      quotedNode_3.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, 0xf8cc6bf96cL, "expression"), quotedNode_4);
      return quotedNode_3;
    }
    private static SNode _quotation_createNode_fw7ydn_a0c0a0a0f8(Object parameter_1, Object parameter_2) {
      SNode quotedNode_3 = null;
      SNode quotedNode_4 = null;
      SNode quotedNode_5 = null;
      SNode quotedNode_6 = null;
      SNode quotedNode_7 = null;
      SNode quotedNode_8 = null;
      SNodeBuilder nb = new SNodeBuilder((SModel) parameter_1, (org.jetbrains.mps.openapi.model.SNodeId) parameter_2).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b200L, "StatementList"));
      quotedNode_3 = nb.getResult();
      SNodeBuilder nb1 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b213L, "ExpressionStatement"));
      quotedNode_4 = nb1.getResult();
      SNodeBuilder nb2 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x10ab8473cc5L, "GenericNewExpression"));
      quotedNode_6 = nb2.getResult();
      SNodeBuilder nb3 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x11a59b0fbceL, "ClassCreator"));
      quotedNode_8 = nb3.getResult();
      nb3.setReference(MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration"), "6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)/~Object.<init>%28%29");
      quotedNode_6.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ab8473cc5L, 0x10ab847b486L, "creator"), quotedNode_8);
      quotedNode_4.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b213L, 0xf8cc56b214L, "expression"), quotedNode_6);
      quotedNode_3.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), quotedNode_4);
      SNodeBuilder nb4 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc67c7feL, "ReturnStatement"));
      quotedNode_5 = nb4.getResult();
      SNodeBuilder nb5 = new SNodeBuilder((SModel) parameter_1, null).init(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf940cd6167L, "NullLiteral"));
      quotedNode_7 = nb5.getResult();
      quotedNode_5.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, 0xf8cc6bf96cL, "expression"), quotedNode_7);
      quotedNode_3.addChild(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), quotedNode_5);
      return quotedNode_3;
    }
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept ReturnStatement$lt = MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, "jetbrains.mps.baseLanguage.structure.ReturnStatement");
    /*package*/ static final SConcept NullLiteral$QQ = MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940cd6167L, "jetbrains.mps.baseLanguage.structure.NullLiteral");
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink expression$eJ92 = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, 0xf8cc6bf96cL, "expression");
  }
}
