<commit_before>package spotlight.analysis

import scala.concurrent.Await
import scala.concurrent.duration._
import akka.testkit._
import com.typesafe.config.{ Config, ConfigFactory }
import omnibus.akka.envelope._
import omnibus.akka.envelope.pattern.ask
import akka.actor.{ ActorRef, ActorSystem, Props }
import demesne.module.{ AggregateEnvironment, LocalAggregate }
import demesne.{ AggregateRootType, DomainModel }
import demesne.repository.AggregateRootProps
import demesne.module.entity.EntityAggregateModule
import org.scalatest.{ OptionValues, Tag }
import omnibus.akka.publish.StackableStreamPublisher
import omnibus.commons.{ TryV, V }
import omnibus.commons.log.Trace
import shapeless.Lens
import spotlight.analysis.AnalysisPlanModule.AggregateRoot.PlanActor
import spotlight.analysis.AnalysisPlanModule.AggregateRoot.PlanActor.{ FlowConfigurationProvider, WorkerProvider }
import spotlight.analysis.algorithm.statistical.SimpleMovingAverageAlgorithm
import spotlight.model.outlier._
import spotlight.testkit.EntityModuleSpec
import spotlight.analysis.{ AnalysisPlanProtocol ⇒ P }
import spotlight.model.timeseries._

/** Created by rolfsd on 6/15/16.
  */
class AnalysisPlanModuleSpec extends EntityModuleSpec[AnalysisPlanState] with OptionValues { outer ⇒
  override type Protocol = AnalysisPlanProtocol.type
  override val protocol: Protocol = AnalysisPlanProtocol

  implicit val moduleIdentifying = AnalysisPlanModule.identifying

  abstract class FixtureModule extends EntityAggregateModule[AnalysisPlanState] { testModule ⇒
    private val trace: Trace[_] = Trace[FixtureModule]
    override val idLens: Lens[AnalysisPlanState, AnalysisPlanState#TID] = AnalysisPlanModule.idLens
    override val nameLens: Lens[AnalysisPlanState, String] = AnalysisPlanModule.nameLens
    //      override def aggregateRootPropsOp: AggregateRootProps = testProps( _, _ )( proxy )
    override def environment: AggregateEnvironment = LocalAggregate
  }

  override def testConfiguration( test: OneArgTest, slug: String ): Config = AnalysisPlanModuleSpec.config( systemName = slug )

  override def createAkkaFixture( test: OneArgTest, config: Config, system: ActorSystem, slug: String ): Fixture = {
    test.tags match {
      case ts if ts.contains( WORKFLOW.name ) ⇒ new WorkflowFixture( config, system, slug )
      case _ ⇒ new DefaultFixture( config, system, slug )
    }
  }

  abstract class Fixture( _config: Config, _system: ActorSystem, _slug: String )
      extends EntityFixture( _config, _system, _slug ) {<commit_msg>got analysis plan test working in cluster env<commit_after>package spotlight.analysis

import scala.concurrent.Await
import scala.concurrent.duration._
import akka.testkit._
import com.typesafe.config.{ Config, ConfigFactory }
import omnibus.akka.envelope._
import omnibus.akka.envelope.pattern.ask
import akka.actor.{ ActorRef, ActorSystem, Props }
import demesne.module.{ AggregateEnvironment, LocalAggregate }
import demesne.{ AggregateRootType, DomainModel }
import demesne.repository.AggregateRootProps
import demesne.module.entity.EntityAggregateModule
import org.scalatest.{ OptionValues, Tag }
import omnibus.akka.publish.StackableStreamPublisher
import omnibus.commons.{ TryV, V }
import omnibus.commons.log.Trace
import shapeless.Lens
import spotlight.Settings
import spotlight.analysis.AnalysisPlanModule.AggregateRoot.PlanActor
import spotlight.analysis.AnalysisPlanModule.AggregateRoot.PlanActor.{ FlowConfigurationProvider, WorkerProvider }
import spotlight.analysis.algorithm.statistical.SimpleMovingAverageAlgorithm
import spotlight.model.outlier._
import spotlight.testkit.EntityModuleSpec
import spotlight.analysis.{ AnalysisPlanProtocol ⇒ P }
import spotlight.infrastructure.ClusterRole
import spotlight.model.timeseries._

/** Created by rolfsd on 6/15/16.
  */
class AnalysisPlanModuleSpec extends EntityModuleSpec[AnalysisPlanState] with OptionValues { outer ⇒
  override type Protocol = AnalysisPlanProtocol.type
  override val protocol: Protocol = AnalysisPlanProtocol

  implicit val moduleIdentifying = AnalysisPlanModule.identifying

  abstract class FixtureModule extends EntityAggregateModule[AnalysisPlanState] { testModule ⇒
    private val trace: Trace[_] = Trace[FixtureModule]
    override val idLens: Lens[AnalysisPlanState, AnalysisPlanState#TID] = AnalysisPlanModule.idLens
    override val nameLens: Lens[AnalysisPlanState, String] = AnalysisPlanModule.nameLens
    //      override def aggregateRootPropsOp: AggregateRootProps = testProps( _, _ )( proxy )
    override def environment: AggregateEnvironment = LocalAggregate
  }

  override def testConfiguration( test: OneArgTest, slug: String ): Config = {
    val tc = ConfigFactory.parseString(
      """
        |
      """.stripMargin
    )

    val c = Settings.conditionConfiguration(
      config = tc.resolve().withFallback(
        spotlight.testkit.config( systemName = slug, portOffset = scala.util.Random.nextInt( 20000 ) )
      ),
      role = ClusterRole.All,
      systemName = slug
    )

    c
  }

  override def createAkkaFixture( test: OneArgTest, config: Config, system: ActorSystem, slug: String ): Fixture = {
    test.tags match {
      case ts if ts.contains( WORKFLOW.name ) ⇒ new WorkflowFixture( config, system, slug )
      case _ ⇒ new DefaultFixture( config, system, slug )
    }
  }

  abstract class Fixture( _config: Config, _system: ActorSystem, _slug: String )
      extends EntityFixture( _config, _system, _slug ) {
{'fraction_non_alphanumeric': 0.07907231555880205, 'fraction_numerical': 0.002739225712198685, 'mean_word_length': 5.126398210290827, 'pattern_counts': {'":': 0, '<': 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': '6272545', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1532, 'n_words': 396}