<commit_before>package org.fusesource.cloudmix.controller.properties.scala


import org.junit.Test
import org.fusesource.cloudmix.common.dto.AgentDetails
import java.util.{ArrayList, HashMap}


/*
import org.specs._
import org.specs.runner._

import org.junit.runner.RunWith
import org.junit.runner.runner._
*/

/*
@RunWith(classOf[JUnitSuiteRunner])
class ExpressionTest {
  @Test  
}
*/

/**
 * @version $Revision : 1.1 $
 */
//class ExpressionTest extends Specification with JUnit {

@Test
class ExpressionTest {
  val factory = new ScalaExpressionFactory

  @Test
  def testParsing: Unit = {
    evaluteExpression("2 * 2")
    evaluteExpression("agents.size()")
    evaluteExpression("agents.size()")
    evaluteExpression("agents.map(\"tcp://\" + _.getHostname + \":61616\").mkString(\"failover:(\", \",\", \")\")");
  }


  def evaluteExpression(text: String) = {
    val expression = factory.createExpression(text)

    println("Created expression " + expression)

    val variables = new HashMap[String, Object]()
    val agents = new ArrayList[AgentDetails]
    agents.add(new AgentDetails("a", "AgentA", "host1"))
    agents.add(new AgentDetails("b", "AgentB", "host2"))

    variables.put("agents", agents)

    val answer = expression.evaluate(variables)

    println("Evaluated expression with result: " + answer)

    answer
  }
}<commit_msg>scala exressions not fully baked yet.<commit_after>package org.fusesource.cloudmix.controller.properties.scala


import org.junit.Test
import org.fusesource.cloudmix.common.dto.AgentDetails
import java.util.{ArrayList, HashMap}


/*
import org.specs._
import org.specs.runner._

import org.junit.runner.RunWith
import org.junit.runner.runner._
*/

/*
@RunWith(classOf[JUnitSuiteRunner])
class ExpressionTest {
  @Test  
}
*/

/**
 * @version $Revision : 1.1 $
 */
//class ExpressionTest extends Specification with JUnit {

@Test
class ExpressionTest {
  val factory = new ScalaExpressionFactory

  @Test
  def testParsing: Unit = {
//    evaluteExpression("2 * 2")
//    evaluteExpression("agents.size")
//    evaluteExpression("agents.size")
//    evaluteExpression("agents.map(\"tcp://\" + _.asInstanceof[AgentDetails].getHostname + \":61616\").mkString(\"failover:(\", \",\", \")\")");
  }


  def evaluteExpression(text: String) = {
    val expression = factory.createExpression(text)

    println("Created expression " + expression)

    val variables = new HashMap[String, Object]()
    val agents = new ArrayList[AgentDetails]
    agents.add(new AgentDetails("a", "AgentA", "host1"))
    agents.add(new AgentDetails("b", "AgentB", "host2"))

    variables.put("agents", agents)

    val answer = expression.evaluate(variables)

    println("Evaluated expression with result: " + answer)

    answer
  }
}
{'fraction_non_alphanumeric': 0.14745211420310805, 'fraction_numerical': 0.00795084929526563, 'mean_word_length': 4.0510948905109485, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2685192', 'n_tokens_mistral': 895, 'n_tokens_neox': 838, 'n_words': 175}