-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from silk-framework/fix/taskCloning
Fix/task cloning
- Loading branch information
Showing
5 changed files
with
91 additions
and
6 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
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
48 changes: 48 additions & 0 deletions
48
silk-workbench/silk-workbench-workspace/test/controllers/workspace/WorkspaceApiTest.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,48 @@ | ||
package controllers.workspace | ||
|
||
import helper.IntegrationTestTrait | ||
import org.scalatest.{BeforeAndAfterAll, FlatSpec, MustMatchers} | ||
import org.scalatestplus.play.PlaySpec | ||
import org.silkframework.dataset.DatasetSpec | ||
import org.silkframework.dataset.DatasetSpec.GenericDatasetSpec | ||
import org.silkframework.entity.StringValueType | ||
import org.silkframework.plugins.dataset.rdf.datasets.InMemoryDataset | ||
import org.silkframework.util.Uri | ||
import test.Routes | ||
|
||
/** | ||
* Workspace API integration tests. | ||
*/ | ||
class WorkspaceApiTest extends PlaySpec with IntegrationTestTrait with MustMatchers with BeforeAndAfterAll { | ||
|
||
private val project = "project" | ||
|
||
override def workspaceProviderId: String = "inMemory" | ||
|
||
protected override def routes: Option[Class[Routes]] = Some(classOf[test.Routes]) | ||
|
||
override def beforeAll(): Unit = { | ||
super.beforeAll() | ||
retrieveOrCreateProject(project) | ||
} | ||
|
||
"Project clone endpoint" should { | ||
"re-create tasks when cloning them" in { | ||
val inMemoryDataset = InMemoryDataset(clearGraphBeforeExecution = false) | ||
val tripleSink = inMemoryDataset.tripleSink | ||
tripleSink.init() | ||
tripleSink.writeTriple("a", "http://prop", "c", StringValueType()) | ||
tripleSink.close() | ||
inMemoryDataset.source.retrievePaths("").flatMap(_.propertyUri) mustBe Seq(Uri("http://prop")) | ||
val datasetName = "oneTripleInMemoryDataset" | ||
val newProject = "newProject" | ||
val p = retrieveOrCreateProject(project) | ||
p.addAnyTask(datasetName, new DatasetSpec(inMemoryDataset)) | ||
checkResponse(client.url(s"$baseUrl/workspace/projects/$project/clone?newProject=$newProject").post("")) | ||
val clonedInmemoryDataset = retrieveOrCreateProject(newProject).task[GenericDatasetSpec](datasetName) | ||
clonedInmemoryDataset.data.plugin.asInstanceOf[InMemoryDataset].clearGraphBeforeExecution mustBe false | ||
// Check that this is a new instance and does not contain the old state | ||
clonedInmemoryDataset.source.retrievePaths("") mustBe Seq.empty | ||
} | ||
} | ||
} |