-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch cross-project resolvers when a project is renamed (#4874)
Co-authored-by: Simon Dumas <[email protected]>
- Loading branch information
Showing
2 changed files
with
57 additions
and
3 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
44 changes: 44 additions & 0 deletions
44
ship/src/test/scala/ch/epfl/bluebrain/nexus/ship/resolvers/ResolverProcessorSuite.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,44 @@ | ||
package ch.epfl.bluebrain.nexus.ship.resolvers | ||
|
||
import cats.data.NonEmptyList | ||
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.ResolverValue.{CrossProjectValue, InProjectValue} | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.{IdentityResolution, Priority} | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import ch.epfl.bluebrain.nexus.ship.ProjectMapper | ||
import ch.epfl.bluebrain.nexus.testkit.mu.NexusSuite | ||
|
||
class ResolverProcessorSuite extends NexusSuite { | ||
|
||
private val originalProject = ProjectRef.unsafe("bbp", "sscx") | ||
private val targetProject = ProjectRef.unsafe("obp", "somato") | ||
|
||
private val projectMapper = ProjectMapper(Map(originalProject -> targetProject)) | ||
|
||
private val priority = Priority.unsafe(42) | ||
|
||
test("Patching does not affect in project resolvers") { | ||
val original = InProjectValue(priority) | ||
|
||
val obtained = ResolverProcessor.patchValue(original, projectMapper) | ||
assertEquals(obtained, original) | ||
} | ||
|
||
test("Patching a cross project resolver") { | ||
val unpatchedProject = ProjectRef.unsafe("neurosciencegraph", "datamodels") | ||
val originalProjects = NonEmptyList.of(unpatchedProject, originalProject) | ||
val original = CrossProjectValue( | ||
Some("My resolver"), | ||
Some("My description"), | ||
priority, | ||
Set(nxv + "Schema"), | ||
originalProjects, | ||
IdentityResolution.UseCurrentCaller | ||
) | ||
|
||
val expected = original.copy(projects = NonEmptyList.of(unpatchedProject, targetProject)) | ||
val obtained = ResolverProcessor.patchValue(original, projectMapper) | ||
assertEquals(obtained, expected) | ||
} | ||
|
||
} |