[Workspace Model] Add entity source editing to propertyBased tests

GitOrigin-RevId: 8a68c9ce3b6757328c2d5333daa034ba663b04a2
This commit is contained in:
Alex Plate
2020-06-09 13:04:07 +03:00
committed by intellij-monorepo-bot
parent efc7e0a52b
commit c570ed8e65
@@ -20,7 +20,8 @@ internal fun getEntityManipulation(workspace: WorkspaceEntityStorageBuilderImpl)
return Generator.anyOf(
RemoveSomeEntity.create(workspace),
EntityManipulation.addManipulations(workspace),
EntityManipulation.modifyManipulations(workspace)
EntityManipulation.modifyManipulations(workspace),
ChangeEntitySource.create(workspace)
)
}
@@ -65,6 +66,27 @@ private class RemoveSomeEntity(private val storage: WorkspaceEntityStorageBuilde
}
}
private class ChangeEntitySource(private val storage: WorkspaceEntityStorageBuilderImpl) : ImperativeCommand {
override fun performCommand(env: ImperativeCommand.Environment) {
val id = env.generateValue(EntityIdGenerator.create(storage), null) ?: run {
env.logMessage("Tried to change entity source, but entity to change isn't found")
return
}
val newSource = env.generateValue(sources, null)
val entity = storage.entityDataByIdOrDie(id).createEntity(storage)
val oldEntitySource = entity.entitySource
storage.changeSource(entity, newSource)
env.logMessage("Entity source changed. Entity: $entity, Old source: $oldEntitySource, New source: $newSource")
}
companion object {
fun create(workspace: WorkspaceEntityStorageBuilderImpl): Generator<ChangeEntitySource> {
return Generator.constant(ChangeEntitySource(workspace))
}
}
}
internal abstract class AddEntity(protected val storage: WorkspaceEntityStorageBuilderImpl,
private val entityDescription: String) : ImperativeCommand {
abstract fun makeEntity(source: EntitySource, someProperty: String, env: ImperativeCommand.Environment): WorkspaceEntity?