package JavaCompilationXmlConflict.test.test;

/*Generated by MPS */

import jetbrains.mps.MPSLaunch;
import org.junit.jupiter.api.extension.ExtendWith;
import jetbrains.mps.baseLanguage.unitTest.runtime.EnvironmentAwareExtension;
import jetbrains.mps.testbench.EnvironmentAwareTestCase;
import org.junit.jupiter.api.Test;
import jetbrains.mps.project.Project;
import java.io.File;
import jetbrains.mps.make.ModuleMaker;
import jetbrains.mps.messages.LogHandler;
import jetbrains.mps.logging.Logger;
import jetbrains.mps.messages.MessageKind;
import java.util.List;
import org.jetbrains.mps.openapi.module.SModule;
import org.junit.Assume;
import java.util.HashSet;
import jetbrains.mps.progress.EmptyProgressMonitor;
import jetbrains.mps.make.MPSCompilationResult;
import org.junit.Assert;

@MPSLaunch
@ExtendWith(value = EnvironmentAwareExtension.class)
@ExtendWith(EnvironmentAwareExtension.class)
public class TestCompilation_Test extends EnvironmentAwareTestCase {
  private static final String PROJECT_PATH = "testbench/modules/testCompilationJavaXmlConflict/";
  @Test
  public void test_compileSolution() throws Exception {
    final Project project = myEnvironment.openProject(new File(PROJECT_PATH));
    final ModuleMaker maker = new ModuleMaker(new LogHandler(Logger.getLogger(TestCompilation_Test.class)).restrict(MessageKind.ERROR));
    project.getModelAccess().runReadAction(() -> {
      List<SModule> projectModules = project.getProjectModules();
      Assume.assumeFalse(projectModules.isEmpty());
      maker.clean(new HashSet<SModule>(projectModules), new EmptyProgressMonitor());
      maker.prepare(projectModules, true, new EmptyProgressMonitor());
    });

    MPSCompilationResult result = maker.make(new EmptyProgressMonitor());
    myEnvironment.closeProject(project);
    Assert.assertTrue(result.isOk());
  }
}
