<commit_before>package com.mindoo.domino.jna.test;

import static org.junit.Assert.*;

import java.util.EnumSet;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import com.mindoo.domino.jna.NotesDatabase;
import com.mindoo.domino.jna.NotesNote;
import com.mindoo.domino.jna.constants.FormulaAttributes;
import com.mindoo.domino.jna.constants.OpenNote;
import com.mindoo.domino.jna.formula.FormulaExecution;
import com.mindoo.domino.jna.formula.FormulaExecution.FormulaExecutionResult;
import com.mindoo.domino.jna.gc.NotesGC;

import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.Session;
import lotus.domino.View;

/**
 * Tests cases for formula execution
 * 
 * @author <NAME>
 */
public class TestFormulaExecution extends BaseJNATestClass {

	@Test
	public void testFormulaAnalyze() {
		runWithSession(new IDominoCallable<Object>() {

			@Override
			public Object call(Session session) throws Exception {
				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT),
						new FormulaExecution("123").analyze().getAttributes()
						);
				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT, FormulaAttributes.FUNC_SIBLINGS),
						new FormulaExecution("@DocSiblings").analyze().getAttributes()
						);

				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT, FormulaAttributes.FUNC_DESCENDANTS),
						new FormulaExecution("@DocDescendants").analyze().getAttributes()
						);

				assertEquals(
						EnumSet.of(FormulaAttributes.TIME_VARIANT),
						new FormulaExecution("@Now").analyze().getAttributes()
						);

				List<String> allFunctions = FormulaExecution.getAllFunctions();
				assertTrue(allFunctions.contains("@Left("));
				assertTrue(!FormulaExecution.getFunctionParameters("@Left(").isEmpty());
				
				List<String> allCommands = FormulaExecution.getAllCommands();
				assertTrue(allCommands.contains("MailSend"));
				assertTrue(!FormulaExecution.getFunctionParameters("ToolsRunMacro").isEmpty());
				
				return null;
			}
		});
	}
	
//	@Test
	public void testFormulaExecution_formulaExecution() {

		runWithSession(new IDominoCallable<Object>() {

			@Override
			public Object call(Session session) throws Exception {
				NotesGC.setDebugLoggingEnabled(true);

				System.out.println("Starting formula execution test");
<commit_msg>Renamed method, enabled testcase<commit_after>package com.mindoo.domino.jna.test;

import static org.junit.Assert.*;

import java.util.EnumSet;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import com.mindoo.domino.jna.NotesDatabase;
import com.mindoo.domino.jna.NotesNote;
import com.mindoo.domino.jna.constants.FormulaAttributes;
import com.mindoo.domino.jna.constants.OpenNote;
import com.mindoo.domino.jna.formula.FormulaExecution;
import com.mindoo.domino.jna.formula.FormulaExecution.FormulaExecutionResult;
import com.mindoo.domino.jna.gc.NotesGC;

import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.Session;
import lotus.domino.View;

/**
 * Tests cases for formula execution
 * 
 * @author <NAME>
 */
public class TestFormulaExecution extends BaseJNATestClass {

	@Test
	public void testAnalyzeFormula() {
		runWithSession(new IDominoCallable<Object>() {

			@Override
			public Object call(Session session) throws Exception {
				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT),
						new FormulaExecution("123").analyze().getAttributes()
						);
				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT, FormulaAttributes.FUNC_SIBLINGS),
						new FormulaExecution("@DocSiblings").analyze().getAttributes()
						);

				assertEquals(
						EnumSet.of(FormulaAttributes.CONSTANT, FormulaAttributes.FUNC_DESCENDANTS),
						new FormulaExecution("@DocDescendants").analyze().getAttributes()
						);

				assertEquals(
						EnumSet.of(FormulaAttributes.TIME_VARIANT),
						new FormulaExecution("@Now").analyze().getAttributes()
						);

				List<String> allFunctions = FormulaExecution.getAllFunctions();
				assertTrue(allFunctions.contains("@Left("));
				assertTrue(!FormulaExecution.getFunctionParameters("@Left(").isEmpty());
				
				List<String> allCommands = FormulaExecution.getAllCommands();
				assertTrue(allCommands.contains("MailSend"));
				assertTrue(!FormulaExecution.getFunctionParameters("ToolsRunMacro").isEmpty());
				
				return null;
			}
		});
	}
	
	@Test
	public void testFormulaExecution_formulaExecution() {

		runWithSession(new IDominoCallable<Object>() {

			@Override
			public Object call(Session session) throws Exception {
				NotesGC.setDebugLoggingEnabled(true);

				System.out.println("Starting formula execution test");

{'fraction_non_alphanumeric': 0.11705542478065482, 'fraction_numerical': 0.0012839717526214422, 'mean_word_length': 4.827930174563591, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5713850', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1382, 'n_words': 219}