package jetbrains.mps.build.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 org.junit.jupiter.api.Test;
import jetbrains.mps.lang.test.runtime.BaseTestBody;
import jetbrains.mps.lang.test.runtime.TransformationTest;
import org.junit.Assert;
import jetbrains.mps.build.behavior.BuildLayout_NamedContainer__BehaviorDescriptor;
import org.jetbrains.mps.openapi.model.SModel;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;

@MPSLaunch
public class TestTemporalPaths_Test extends BaseTransformationTest {
  @RegisterExtension
  private static final TestParametersCacheExtension ourParametersCacheExtension = new TestParametersCacheExtension(new TestParametersCache(TestTemporalPaths_Test.class, "${mps_home}", "r:361d93bd-9223-4768-9e37-bcd7b8db1f40(jetbrains.mps.build.tests@tests)", false));

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

  @Test
  public void test_topLevelJar() throws Throwable {
    new TestBody(this).test_topLevelJar();
  }
  @Test
  public void test_topLevelFolder() throws Throwable {
    new TestBody(this).test_topLevelFolder();
  }
  @Test
  public void test_topInternalFolder() throws Throwable {
    new TestBody(this).test_topInternalFolder();
  }
  @Test
  public void test_jarInFolder() throws Throwable {
    new TestBody(this).test_jarInFolder();
  }
  @Test
  public void test_folderInJar() throws Throwable {
    new TestBody(this).test_folderInJar();
  }
  @Test
  public void test_duplicatedNames() throws Throwable {
    new TestBody(this).test_duplicatedNames();
  }

  /*package*/ static class TestBody extends BaseTestBody {

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

    public void test_topLevelJar() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> Assert.assertEquals(TestContext.DEPLOY + "/test.jar", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("280273048052535266"), new TestContext(TestBody.this.getBuildTestsModel()))));
    }
    public void test_topLevelFolder() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> Assert.assertEquals(TestContext.DEPLOY + "/folder", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("280273048052535287"), new TestContext(TestBody.this.getBuildTestsModel()))));
    }
    public void test_topInternalFolder() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> Assert.assertEquals(TestContext.DEPLOY + "/folder/internal", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("7422876504327290551"), new TestContext(TestBody.this.getBuildTestsModel()))));
    }
    public void test_jarInFolder() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> Assert.assertEquals(TestContext.DEPLOY + "/folder/test.jar", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("280273048052535289"), new TestContext(TestBody.this.getBuildTestsModel()))));
    }
    public void test_folderInJar() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> {
        TestContext testContext = new TestContext(TestBody.this.getBuildTestsModel());
        Assert.assertEquals(TestContext.TEMP + "/default/test.jar/internalFolder", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("8104754176559709900"), testContext));
        Assert.assertEquals(TestContext.TEMP + "/default/test.jar/internalFolder/internalFolder2", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("8104754176559709938"), testContext));
      });
    }
    public void test_duplicatedNames() throws Exception {
      runWithinCommand(() -> addNodeById("4045247515868358884"));
      runWithinCommand(() -> {
        TestContext testContext = new TestContext(TestBody.this.getBuildTestsModel());
        Assert.assertEquals(TestContext.TEMP + "/default/some.jar/someFolder", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("4209004860870558811"), testContext));
        Assert.assertEquals(TestContext.TEMP + "/default/some.jar1/someFolder", BuildLayout_NamedContainer__BehaviorDescriptor.getOutputPath_WithMacro_idfzIHCHip1Q.invoke(getNodeById("4209004860870558814"), testContext));
      });
    }

    public SModel getBuildTestsModel() {
      return PersistenceFacade.getInstance().createModelReference("r:361d93bd-9223-4768-9e37-bcd7b8db1f40(jetbrains.mps.build.tests@tests)").resolve(myProject.getRepository());
    }
  }
}
