@Test
  public void createsOutputFilesWithDefaultEncodingReadFromMainTemplate() throws Exception {
    // prepare test
    final File templateFile =
        prepareArtefactDirectory("main.tpl", GENERATOR_PLUGIN_ID, "myNewArtefact");

    MOGLiFileUtil.createNewFileWithContent(
        templateFile,
        "@CreateNew true"
            + FileUtil.getSystemLineSeparator()
            + "@TargetFileName UmlautTest.txt"
            + FileUtil.getSystemLineSeparator()
            + "@TargetDir "
            + MOGLiSystemConstants.APPLICATION_ROOT_IDENTIFIER
            + "/example"
            + FileUtil.getSystemLineSeparator()
            + "äüößÜÖÄ");

    // call functionality under test
    executeMogliApplication();

    // verify test result
    final File outputFile =
        new File(applicationOutputDir, GENERATOR_PLUGIN_ID + "/myNewArtefact/UmlautTest.txt");
    assertStringEquals("outputFileContent", "äüößÜÖÄ", MOGLiFileUtil.getFileContent(outputFile));
  }
 private File createTestArtefact(final String artefactName) {
   final File artefactDir = new File(infrastructure.getPluginInputDir(), artefactName);
   artefactDir.mkdirs();
   assertFileExists(artefactDir);
   final File templateFile = new File(artefactDir, "main.tpl");
   MOGLiFileUtil.createNewFileWithContent(
       templateFile,
       "@" + KnownGeneratorPropertyNames.NameOfValidModel + " " + MockDataBuilder.MOCK_MODEL_NAME);
   return artefactDir;
 }
  @Test
  public void returnsMetaInfoValidatorList() throws MOGLiPluginException {
    // prepare test
    final File conditionFile =
        new File(
            velocityClassBasedGenerator.getInfrastructure().getPluginInputDir(), "condition.txt");
    MOGLiFileUtil.createNewFileWithContent(
        conditionFile,
        "|if MetaInfo| The \"other\" MetaInfo Name1 |exists.|"
            + FileUtil.getSystemLineSeparator()
            + "|if MetaInfo| The \"other\" MetaInfo Name2 |does not exist.|"
            + FileUtil.getSystemLineSeparator()
            + "|if MetaInfo| The \"other\" MetaInfo Name3 |with value| my value |does not exist.|");

    final File validatorFile =
        new File(
            velocityClassBasedGenerator.getInfrastructure().getPluginInputDir(),
            MetaInfoValidationUtil.FILENAME_VALIDATION);
    MOGLiFileUtil.createNewFileWithContent(
        validatorFile,
        "|MetaInfo| MetaInfoTestName1 |is| optional |for| attributes |in| ModelName |.|"
            + FileUtil.getSystemLineSeparator()
            + "|MetaInfo| MetaInfoTestName2 |is| mandatory |for| attributes |in| ModelName |.|"
            + FileUtil.getSystemLineSeparator()
            + "|MetaInfo| MetaInfoTestName3 |is valid to occur| 0-4 |time(s) for| attributes |in| ModelName |.|"
            + FileUtil.getSystemLineSeparator()
            + "|MetaInfo| MetaInfoTestName4 |is valid to occur| 1-2 |time(s) for| attributes |in| ModelName |if| condition.txt |is true.|");

    // call functionality under test
    final List<MetaInfoValidator> metaInfoValidatorList =
        velocityClassBasedGenerator.getMetaInfoValidatorList();

    // verify test result
    assertEquals("validator number", 4, metaInfoValidatorList.size());
    assertEquals(
        "condition number",
        3,
        ((ConditionalMetaInfoValidator) metaInfoValidatorList.get(3)).getTotalNumberOfConditions());
  }
  @Test
  public void findsArtefactList() throws MOGLiPluginException {
    // prepare test
    MOGLiFileUtil.createNewFileWithContent(generatorPropertiesFile, "");
    giveSystemTimeToExecute();

    // call functionality under test
    final List<String> artefactList = velocityClassBasedGenerator.getArtefactList();

    // verify test result
    final StringBuffer sb = new StringBuffer(System.getProperty("line.separator"));
    for (String artefactName : artefactList) {
      sb.append(artefactName);
      sb.append(System.getProperty("line.separator"));
      System.out.println(artefactName);
    }
    assertEquals("Unexpected artefact list: " + sb.toString(), 11, artefactList.size());
  }
  @Test
  public void throwsExceptionIfConditionFileWasNotFound() throws MOGLiPluginException {
    // prepare test
    final File validatorFile =
        new File(
            velocityClassBasedGenerator.getInfrastructure().getPluginInputDir(),
            MetaInfoValidationUtil.FILENAME_VALIDATION);
    MOGLiFileUtil.createNewFileWithContent(
        validatorFile,
        "|MetaInfo| MetaInfoTestName1 |is| optional |for| attributes |in| ModelName |.|"
            + FileUtil.getSystemLineSeparator()
            + "|MetaInfo| MetaInfoTestName4 |is valid to occur| 1-2 |time(s) for| attributes |in| ModelName |if| notExistingConditionFile.txt |is true.|");

    // call functionality under test
    try {
      velocityClassBasedGenerator.getMetaInfoValidatorList();
      fail("Expected exception not thrown!");
    } catch (MOGLiPluginException e) {
      assertStringContains(e.getMessage(), "Expected condition file does not exist: ");
      assertStringContains(e.getMessage(), "notExistingConditionFile.txt");
    }
  }