-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename source 'sample-generator' to 'event-generator' and 'period' to…
… 'schedule'
- Loading branch information
Showing
27 changed files
with
149 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...defaultmodel/migrations/SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pl.touk.nussknacker.defaultmodel.migrations | ||
|
||
import pl.touk.nussknacker.engine.api.MetaData | ||
import pl.touk.nussknacker.engine.api.parameter.ParameterName | ||
import pl.touk.nussknacker.engine.graph.node | ||
import pl.touk.nussknacker.engine.graph.node.Source | ||
import pl.touk.nussknacker.engine.graph.source.SourceRef | ||
import pl.touk.nussknacker.engine.migration.NodeMigration | ||
|
||
object SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter extends NodeMigration { | ||
|
||
override val description: String = "Change name of component: sample-generator -> event-generator " + | ||
"and its parameter: period -> schedule" | ||
|
||
override def migrateNode(metaData: MetaData): PartialFunction[node.NodeData, node.NodeData] = { | ||
case source @ Source(_, ref @ SourceRef("sample-generator", _), _) => | ||
source.copy(ref = | ||
ref.copy( | ||
typ = "event-generator", | ||
parameters = ref.parameters.map { param => | ||
param.name.value match { | ||
case "period" => param.copy(name = ParameterName("schedule")) | ||
case _ => param | ||
} | ||
} | ||
) | ||
) | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...er/defaultModel/migrations/SampleGeneratorToEventGeneratorAndPeriodicToScheduleSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package pl.touk.nussknacker.defaultModel.migrations | ||
|
||
import org.scalatest.freespec.AnyFreeSpecLike | ||
import org.scalatest.matchers.should.Matchers | ||
import pl.touk.nussknacker.defaultmodel.migrations.SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter | ||
import pl.touk.nussknacker.engine.api.parameter.ParameterName | ||
import pl.touk.nussknacker.engine.api.{MetaData, StreamMetaData} | ||
import pl.touk.nussknacker.engine.graph.evaluatedparam.Parameter | ||
import pl.touk.nussknacker.engine.graph.node.Source | ||
import pl.touk.nussknacker.engine.graph.source.SourceRef | ||
import pl.touk.nussknacker.engine.spel.SpelExtension._ | ||
|
||
class SampleGeneratorToEventGeneratorAndPeriodicToScheduleSpec extends AnyFreeSpecLike with Matchers { | ||
|
||
"PeriodicToSampleGeneratorMigration should be applied" in { | ||
val metaData = MetaData("test", StreamMetaData(Some(1))) | ||
val beforeMigration = Source( | ||
id = "sample-generator", | ||
ref = SourceRef( | ||
typ = "sample-generator", | ||
parameters = List( | ||
Parameter(ParameterName("period"), "T(java.time.Duration).parse('PT1M')".spel), | ||
Parameter(ParameterName("count"), "1".spel), | ||
Parameter(ParameterName("value"), "1".spel), | ||
) | ||
) | ||
) | ||
val expectedAfterMigration = Source( | ||
id = "sample-generator", | ||
ref = SourceRef( | ||
typ = "event-generator", | ||
parameters = List( | ||
Parameter(ParameterName("schedule"), "T(java.time.Duration).parse('PT1M')".spel), | ||
Parameter(ParameterName("count"), "1".spel), | ||
Parameter(ParameterName("value"), "1".spel), | ||
) | ||
) | ||
) | ||
|
||
val migrated = SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter.migrateNode(metaData)(beforeMigration) | ||
|
||
migrated shouldBe expectedAfterMigration | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.