From d84c0c19c32ab29cee778298f2a9761dd0349b4f Mon Sep 17 00:00:00 2001 From: Simon Dumas Date: Wed, 20 Sep 2023 17:25:50 +0200 Subject: [PATCH] Rename practice to trial --- ...outes.scala => ResourcesTrialRoutes.scala} | 34 +++++++++---------- .../nexus/delta/wiring/DeltaModule.scala | 2 +- ...odule.scala => ResourcesTrialModule.scala} | 22 ++++++------ .../generated-resource.json | 0 ...c.scala => ResourcesTrialRoutesSpec.scala} | 26 +++++++------- ...cesPractice.scala => ResourcesTrial.scala} | 6 ++-- ...eSuite.scala => ResourcesTrialSuite.scala} | 26 +++++++------- .../{practice => trial}/resources/generate.sh | 2 +- .../resources/generated.json | 0 .../resources/payload.json | 0 docs/src/main/paradox/docs/delta/api/index.md | 2 +- .../docs/delta/api/{practice.md => trial.md} | 12 +++---- docs/src/main/paradox/docs/releases/index.md | 2 +- .../docs/releases/v1.8-release-notes.md | 2 +- .../docs/releases/v1.9-release-notes.md | 4 +-- ...iceSpec.scala => ResourcesTrialSpec.scala} | 18 +++++----- 16 files changed, 79 insertions(+), 79 deletions(-) rename delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/{ResourcesPracticeRoutes.scala => ResourcesTrialRoutes.scala} (84%) rename delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/{ResourcesPracticeModule.scala => ResourcesTrialModule.scala} (83%) rename delta/app/src/test/resources/{practice => trial}/generated-resource.json (100%) rename delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/{ResourcesPracticeRoutesSpec.scala => ResourcesTrialRoutesSpec.scala} (91%) rename delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/{ResourcesPractice.scala => ResourcesTrial.scala} (98%) rename delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/{ResourcesPracticeSuite.scala => ResourcesTrialSuite.scala} (88%) rename docs/src/main/paradox/docs/delta/api/assets/{practice => trial}/resources/generate.sh (88%) rename docs/src/main/paradox/docs/delta/api/assets/{practice => trial}/resources/generated.json (100%) rename docs/src/main/paradox/docs/delta/api/assets/{practice => trial}/resources/payload.json (100%) rename docs/src/main/paradox/docs/delta/api/{practice.md => trial.md} (83%) rename tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/{ResourcesPracticeSpec.scala => ResourcesTrialSpec.scala} (80%) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutes.scala similarity index 84% rename from delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutes.scala rename to delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutes.scala index 73f4a4d19f..0a1e688917 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutes.scala @@ -7,8 +7,8 @@ import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.schemas import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering -import ch.epfl.bluebrain.nexus.delta.routes.ResourcesPracticeRoutes.SchemaInput._ -import ch.epfl.bluebrain.nexus.delta.routes.ResourcesPracticeRoutes.{GenerateSchema, GenerationInput} +import ch.epfl.bluebrain.nexus.delta.routes.ResourcesTrialRoutes.SchemaInput._ +import ch.epfl.bluebrain.nexus.delta.routes.ResourcesTrialRoutes.{GenerateSchema, GenerationInput} import ch.epfl.bluebrain.nexus.delta.sdk.SchemaResource import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling @@ -22,7 +22,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegment} import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.resources.{write => Write} import ch.epfl.bluebrain.nexus.delta.sdk.resources.NexusSource.DecodingOption import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.ResourceRejection -import ch.epfl.bluebrain.nexus.delta.sdk.resources.{NexusSource, ResourcesPractice} +import ch.epfl.bluebrain.nexus.delta.sdk.resources.{NexusSource, ResourcesTrial} import ch.epfl.bluebrain.nexus.delta.sdk.schemas.Schemas import ch.epfl.bluebrain.nexus.delta.sdk.schemas.model.SchemaRejection import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef @@ -35,13 +35,13 @@ import monix.execution.Scheduler import scala.annotation.nowarn /** - * The resource practice routes allowing to do read-only operations on resource + * The resource trial routes allowing to do read-only operations on resources */ -final class ResourcesPracticeRoutes( +final class ResourcesTrialRoutes( identities: Identities, aclCheck: AclCheck, generateSchema: GenerateSchema, - resourcesPractice: ResourcesPractice, + resourcesTrial: ResourcesTrial, schemeDirectives: DeltaSchemeDirectives )(implicit baseUri: BaseUri, @@ -56,7 +56,7 @@ final class ResourcesPracticeRoutes( import schemeDirectives._ def routes: Route = baseUriPrefix(baseUri.prefix) { - concat(validateRoute, practiceRoute) + concat(validateRoute, generateRoute) } private def validateRoute: Route = @@ -67,7 +67,7 @@ final class ResourcesPracticeRoutes( (get & idSegment & idSegmentRef & pathPrefix("validate") & pathEndOrSingleSlash) { (schema, id) => val schemaOpt = underscoreToOption(schema) emit( - resourcesPractice.validate(id, project, schemaOpt).leftWiden[ResourceRejection] + resourcesTrial.validate(id, project, schemaOpt).leftWiden[ResourceRejection] ) } } @@ -75,8 +75,8 @@ final class ResourcesPracticeRoutes( } } - private def practiceRoute: Route = - (get & pathPrefix("practice") & pathPrefix("resources")) { + private def generateRoute: Route = + (get & pathPrefix("trial") & pathPrefix("resources")) { extractCaller { implicit caller => (resolveProjectRef & pathEndOrSingleSlash) { project => authorizeFor(project, Write).apply { @@ -92,18 +92,18 @@ final class ResourcesPracticeRoutes( private def generate(project: ProjectRef, input: GenerationInput)(implicit caller: Caller) = input.schema match { case ExistingSchema(schemaId) => - emit(resourcesPractice.generate(project, schemaId, input.resource).flatMap(_.asJson)) + emit(resourcesTrial.generate(project, schemaId, input.resource).flatMap(_.asJson)) case NewSchema(schemaSource) => emit( generateSchema(project, schemaSource, caller).flatMap { schema => - resourcesPractice.generate(project, schema, input.resource).flatMap(_.asJson) + resourcesTrial.generate(project, schema, input.resource).flatMap(_.asJson) } ) } } -object ResourcesPracticeRoutes { +object ResourcesTrialRoutes { type GenerateSchema = (ProjectRef, Json, Caller) => IO[SchemaRejection, SchemaResource] @@ -143,7 +143,7 @@ object ResourcesPracticeRoutes { identities: Identities, aclCheck: AclCheck, schemas: Schemas, - resourcesPractice: ResourcesPractice, + resourcesTrial: ResourcesTrial, schemeDirectives: DeltaSchemeDirectives )(implicit baseUri: BaseUri, @@ -151,12 +151,12 @@ object ResourcesPracticeRoutes { cr: RemoteContextResolution, ordering: JsonKeyOrdering, decodingOption: DecodingOption - ): ResourcesPracticeRoutes = - new ResourcesPracticeRoutes( + ): ResourcesTrialRoutes = + new ResourcesTrialRoutes( identities, aclCheck, (project, source, caller) => schemas.createDryRun(project, source)(caller).toBIO[SchemaRejection], - resourcesPractice, + resourcesTrial, schemeDirectives ) } diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala index 508e3cf83a..6fda0c657f 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala @@ -168,7 +168,7 @@ class DeltaModule(appCfg: AppConfig, config: Config)(implicit classLoader: Class include(ResolversModule) include(SchemasModule) include(ResourcesModule) - include(ResourcesPracticeModule) + include(ResourcesTrialModule) include(MultiFetchModule) include(IdentitiesModule) include(VersionModule) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesPracticeModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesTrialModule.scala similarity index 83% rename from delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesPracticeModule.scala rename to delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesTrialModule.scala index bf24456871..7135e8d258 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesPracticeModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/ResourcesTrialModule.scala @@ -6,7 +6,7 @@ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering -import ch.epfl.bluebrain.nexus.delta.routes.ResourcesPracticeRoutes +import ch.epfl.bluebrain.nexus.delta.routes.ResourcesTrialRoutes import ch.epfl.bluebrain.nexus.delta.sdk.PriorityRoute import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives @@ -16,7 +16,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext.ContextRejection import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.ResourceRejection.ProjectContextRejection -import ch.epfl.bluebrain.nexus.delta.sdk.resources.{Resources, ResourcesConfig, ResourcesPractice, ValidateResource} +import ch.epfl.bluebrain.nexus.delta.sdk.resources.{Resources, ResourcesConfig, ResourcesTrial, ValidateResource} import ch.epfl.bluebrain.nexus.delta.sdk.schemas.Schemas import distage.ModuleDef import izumi.distage.model.definition.Id @@ -24,11 +24,11 @@ import monix.bio.UIO import monix.execution.Scheduler /** - * Resources practice wiring + * Resources trial wiring */ -object ResourcesPracticeModule extends ModuleDef { +object ResourcesTrialModule extends ModuleDef { - make[ResourcesPractice].from { + make[ResourcesTrial].from { ( resources: Resources, validate: ValidateResource, @@ -38,7 +38,7 @@ object ResourcesPracticeModule extends ModuleDef { clock: Clock[UIO], uuidF: UUIDF ) => - ResourcesPractice( + ResourcesTrial( resources.fetch(_, _, None), validate, fetchContext.mapRejection(ProjectContextRejection), @@ -46,12 +46,12 @@ object ResourcesPracticeModule extends ModuleDef { )(api, clock, uuidF) } - make[ResourcesPracticeRoutes].from { + make[ResourcesTrialRoutes].from { ( identities: Identities, aclCheck: AclCheck, schemas: Schemas, - resourcesPractice: ResourcesPractice, + resourcesTrial: ResourcesTrial, schemeDirectives: DeltaSchemeDirectives, baseUri: BaseUri, s: Scheduler, @@ -59,11 +59,11 @@ object ResourcesPracticeModule extends ModuleDef { ordering: JsonKeyOrdering, config: ResourcesConfig ) => - ResourcesPracticeRoutes( + ResourcesTrialRoutes( identities, aclCheck, schemas, - resourcesPractice, + resourcesTrial, schemeDirectives )( baseUri, @@ -74,7 +74,7 @@ object ResourcesPracticeModule extends ModuleDef { ) } - many[PriorityRoute].add { (route: ResourcesPracticeRoutes) => + many[PriorityRoute].add { (route: ResourcesTrialRoutes) => PriorityRoute(pluginsMinPriority - 1, route.routes, requiresStrictEntity = true) } diff --git a/delta/app/src/test/resources/practice/generated-resource.json b/delta/app/src/test/resources/trial/generated-resource.json similarity index 100% rename from delta/app/src/test/resources/practice/generated-resource.json rename to delta/app/src/test/resources/trial/generated-resource.json diff --git a/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutesSpec.scala b/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutesSpec.scala similarity index 91% rename from delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutesSpec.scala rename to delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutesSpec.scala index 577b15509f..af1b8a7852 100644 --- a/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesPracticeRoutesSpec.scala +++ b/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesTrialRoutesSpec.scala @@ -6,7 +6,7 @@ import akka.http.scaladsl.server.Route import ch.epfl.bluebrain.nexus.delta.kernel.utils.UrlUtils import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.{contexts, nxv, schemas} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords -import ch.epfl.bluebrain.nexus.delta.routes.ResourcesPracticeRoutes.GenerateSchema +import ch.epfl.bluebrain.nexus.delta.routes.ResourcesTrialRoutes.GenerateSchema import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives import ch.epfl.bluebrain.nexus.delta.sdk.generators.SchemaGen @@ -32,7 +32,7 @@ import monix.bio.{IO, UIO} import java.time.Instant -class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFixture with ValidateResourceFixture { +class ResourcesTrialRoutesSpec extends BaseRouteSpec with ResourceInstanceFixture with ValidateResourceFixture { implicit private val caller: Caller = Caller(alice, Set(alice, Anonymous, Authenticated(realm), Group("group", realm))) @@ -72,7 +72,7 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix private val expectedError = ReservedResourceId(nxv + "invalid") - private val resourcesPractice = new ResourcesPractice { + private val resourcesTrial = new ResourcesTrial { override def generate(project: ProjectRef, schema: IdSegment, source: NexusSource)(implicit caller: Caller ): UIO[ResourceGenerationResult] = @@ -116,20 +116,20 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix private lazy val routes = Route.seal( - new ResourcesPracticeRoutes( + new ResourcesTrialRoutes( IdentitiesDummy(caller), aclCheck, generateSchema, - resourcesPractice, + resourcesTrial, DeltaSchemeDirectives(fetchContext) ).routes ) - "A resource practice route" should { + "A resource trial route" should { "fail to generate a resource for a user without access" in { val payload = json"""{ "resource": $validSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> routes ~> check { response.status shouldEqual StatusCodes.Forbidden response.asJson shouldEqual jsonContentOf("errors/authorization-failed.json") } @@ -137,18 +137,18 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix "generate a resource without passing a schema" in { val payload = json"""{ "resource": $validSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { response.status shouldEqual StatusCodes.OK val jsonResponse = response.asJsonObject jsonResponse("schema") shouldBe empty - jsonResponse("result") shouldEqual Some(jsonContentOf("practice/generated-resource.json")) + jsonResponse("result") shouldEqual Some(jsonContentOf("trial/generated-resource.json")) jsonResponse("error") shouldBe empty } } "generate a resource passing a new schema" in { val payload = json"""{ "schema": $schemaSource, "resource": $validSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { response.status shouldEqual StatusCodes.OK val jsonResponse = response.asJsonObject jsonResponse("schema") should not be empty @@ -159,7 +159,7 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix "fails to generate a resource when passing an invalid new schema" in { val payload = json"""{ "schema": { "invalid": "xxx" }, "resource": $validSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { response.status shouldEqual StatusCodes.BadRequest response.asJson shouldEqual json"""{ @@ -174,7 +174,7 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix "fails to generate a resource when the resource payload is invalid and without passing a schema" in { val payload = json"""{ "resource": $invalidSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { response.status shouldEqual StatusCodes.OK response.asJson shouldEqual json""" @@ -190,7 +190,7 @@ class ResourcesPracticeRoutesSpec extends BaseRouteSpec with ResourceInstanceFix "fail to generate a resource passing a new schema" in { val payload = json"""{ "schema": $schemaSource, "resource": $invalidSource }""" - Get(s"/v1/practice/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { + Get(s"/v1/trial/resources/$projectRef/", payload.toEntity) ~> asAlice ~> routes ~> check { response.status shouldEqual StatusCodes.OK val jsonResponse = response.asJsonObject jsonResponse("schema") should not be empty diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPractice.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrial.scala similarity index 98% rename from delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPractice.scala rename to delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrial.scala index ec0b528c99..987b77a0f1 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPractice.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrial.scala @@ -20,7 +20,7 @@ import monix.bio.{IO, UIO} /** * Operations allowing to perform read-only operations on resources */ -trait ResourcesPractice { +trait ResourcesTrial { /** * Generates the resource and validate it against the provided schema reference @@ -69,13 +69,13 @@ trait ResourcesPractice { ): IO[ResourceRejection, ValidationResult] } -object ResourcesPractice { +object ResourcesTrial { def apply( fetchResource: (IdSegmentRef, ProjectRef) => IO[ResourceFetchRejection, DataResource], validateResource: ValidateResource, fetchContext: FetchContext[ProjectContextRejection], contextResolution: ResolverContextResolution - )(implicit api: JsonLdApi, clock: Clock[UIO], uuidF: UUIDF): ResourcesPractice = new ResourcesPractice { + )(implicit api: JsonLdApi, clock: Clock[UIO], uuidF: UUIDF): ResourcesTrial = new ResourcesTrial { private val sourceParser = JsonLdSourceResolvingParser[ResourceRejection](contextResolution, uuidF) diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPracticeSuite.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala similarity index 88% rename from delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPracticeSuite.scala rename to delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala index d36b8e0cd7..bfd737d63f 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesPracticeSuite.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala @@ -23,7 +23,7 @@ import munit.Location import java.util.UUID -class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with TestHelpers with IOFixedClock { +class ResourcesTrialSuite extends BioSuite with ValidateResourceFixture with TestHelpers with IOFixedClock { private val uuid = UUID.randomUUID() implicit private val uuidF: UUIDF = UUIDF.fixed(uuid) @@ -78,7 +78,7 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with } test("Successfully generates a resource") { - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => fetchResourceFail, alwaysValidate, fetchContext, @@ -87,11 +87,11 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with val expectedData = ResourceGen.resource(id, projectRef, source.value, Revision(resourceSchema, defaultSchemaRevision)) - assertSuccess(practice.generate(projectRef, resourceSchema, source))(None, expectedData) + assertSuccess(trial.generate(projectRef, resourceSchema, source))(None, expectedData) } test("Successfully generates a resource with a new schema") { - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => fetchResourceFail, alwaysValidate, fetchContext, @@ -106,19 +106,19 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with val expectedData = ResourceGen.resource(id, projectRef, source.value, Revision(anotherSchema, defaultSchemaRevision)) - assertSuccess(practice.generate(projectRef, schema, source))(Some(schema), expectedData) + assertSuccess(trial.generate(projectRef, schema, source))(Some(schema), expectedData) } test("Fail when validation raises an error") { val expectedError = ReservedResourceId(id) - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => fetchResourceFail, alwaysFail(expectedError), fetchContext, resolverContextResolution ) - assertError(practice.generate(projectRef, resourceSchema, source))(None, expectedError) + assertError(trial.generate(projectRef, resourceSchema, source))(None, expectedError) } test("Validate a resource against a new schema reference") { @@ -127,7 +127,7 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with ) val anotherSchema = nxv + "anotherSchema" - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => IO.pure(resource), alwaysValidate, fetchContext, @@ -135,7 +135,7 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with ) val expected = Validated(projectRef, Revision(anotherSchema, defaultSchemaRevision), defaultReport) - practice.validate(id, projectRef, Some(anotherSchema)).assert(expected) + trial.validate(id, projectRef, Some(anotherSchema)).assert(expected) } test("Validate a resource against its own schema") { @@ -143,7 +143,7 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with ResourceGen.resource(id, projectRef, source.value, Revision(resourceSchema, 1)) ) - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => IO.pure(resource), alwaysValidate, fetchContext, @@ -151,7 +151,7 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with ) val expected = Validated(projectRef, Revision(resourceSchema, defaultSchemaRevision), defaultReport) - practice.validate(id, projectRef, None).assert(expected) + trial.validate(id, projectRef, None).assert(expected) } test("Fail to validate a resource against the specified schema") { @@ -163,14 +163,14 @@ class ResourcesPracticeSuite extends BioSuite with ValidateResourceFixture with val expectedError = InvalidResource(id, Revision(anotherSchema, defaultSchemaRevision), defaultReport, resource.value.expanded) - val practice = ResourcesPractice( + val trial = ResourcesTrial( (_, _) => IO.pure(resource), alwaysFail(expectedError), fetchContext, resolverContextResolution ) - practice.validate(id, projectRef, Some(anotherSchema)).error(expectedError) + trial.validate(id, projectRef, Some(anotherSchema)).error(expectedError) } } diff --git a/docs/src/main/paradox/docs/delta/api/assets/practice/resources/generate.sh b/docs/src/main/paradox/docs/delta/api/assets/trial/resources/generate.sh similarity index 88% rename from docs/src/main/paradox/docs/delta/api/assets/practice/resources/generate.sh rename to docs/src/main/paradox/docs/delta/api/assets/trial/resources/generate.sh index 333c5940ae..13f05eeb63 100644 --- a/docs/src/main/paradox/docs/delta/api/assets/practice/resources/generate.sh +++ b/docs/src/main/paradox/docs/delta/api/assets/trial/resources/generate.sh @@ -1,6 +1,6 @@ curl -X PUT \ -H "Content-Type: application/json" \ - "http://localhost:8080//practice/resources/myorg/myproj/" \ + "http://localhost:8080/trial/resources/myorg/myproj/" \ -d \ '{ "schema": "https://bbp.epfl.ch/nexus/schema/morphology" diff --git a/docs/src/main/paradox/docs/delta/api/assets/practice/resources/generated.json b/docs/src/main/paradox/docs/delta/api/assets/trial/resources/generated.json similarity index 100% rename from docs/src/main/paradox/docs/delta/api/assets/practice/resources/generated.json rename to docs/src/main/paradox/docs/delta/api/assets/trial/resources/generated.json diff --git a/docs/src/main/paradox/docs/delta/api/assets/practice/resources/payload.json b/docs/src/main/paradox/docs/delta/api/assets/trial/resources/payload.json similarity index 100% rename from docs/src/main/paradox/docs/delta/api/assets/practice/resources/payload.json rename to docs/src/main/paradox/docs/delta/api/assets/trial/resources/payload.json diff --git a/docs/src/main/paradox/docs/delta/api/index.md b/docs/src/main/paradox/docs/delta/api/index.md index 80259e5ca5..3751f4c23c 100644 --- a/docs/src/main/paradox/docs/delta/api/index.md +++ b/docs/src/main/paradox/docs/delta/api/index.md @@ -13,7 +13,7 @@ * @ref:[Quotas](quotas.md) * @ref:[Schemas](schemas-api.md) * @ref:[Resources](resources-api.md) -* @ref:[Practice](practice.md) +* @ref:[Practice](trial.md) * @ref:[Multi-fetch](multi-fetch.md) * @ref:[Resolvers](resolvers-api.md) * @ref:[Views](views/index.md) diff --git a/docs/src/main/paradox/docs/delta/api/practice.md b/docs/src/main/paradox/docs/delta/api/trial.md similarity index 83% rename from docs/src/main/paradox/docs/delta/api/practice.md rename to docs/src/main/paradox/docs/delta/api/trial.md index 4c9045c55d..80131023a5 100644 --- a/docs/src/main/paradox/docs/delta/api/practice.md +++ b/docs/src/main/paradox/docs/delta/api/trial.md @@ -1,5 +1,5 @@ -# Practice -Practice operations contain read-only operations designed to help users compose and validate their +# Trial +Trial operations contain read-only operations designed to help users compose and validate their resources before effectively saving them in Nexus. @@@ note { .tip title="Authorization notes" } @@ -19,7 +19,7 @@ It applies the same validation steps than the creation/update of resources, the that nothing is persisted. ``` -GET /v1/practice/resources/{org_label}/{project_label} +GET /v1/trial/resources/{org_label}/{project_label} { "schema": {schema}, @@ -43,13 +43,13 @@ The Json response will contain: **Example** Request -: @@snip [create.sh](assets/practice/resources/generate.sh) +: @@snip [create.sh](assets/trial/resources/generate.sh) Payload -: @@snip [payload.json](assets/practice/resources/payload.json) +: @@snip [payload.json](assets/trial/resources/payload.json) Response -: @@snip [created.json](assets/practice/resources/generated.json) +: @@snip [created.json](assets/trial/resources/generated.json) ## Validate diff --git a/docs/src/main/paradox/docs/releases/index.md b/docs/src/main/paradox/docs/releases/index.md index 4b926979c7..21c4b430fa 100644 --- a/docs/src/main/paradox/docs/releases/index.md +++ b/docs/src/main/paradox/docs/releases/index.md @@ -55,7 +55,7 @@ In the upcoming version, the support of the tar format to download archives will - Only trigger reindexing when indexing is impacted - Project deletion has been rewritten - @ref:[A refresh operation is now available for resources](../delta/api/resources-api.md#refresh) -- @ref:[A validate operation is now available for resources](../delta/api/practice.md#validate) +- @ref:[A validate operation is now available for resources](../delta/api/trial.md#validate) - Archives can now be downloaded as a zip A detailed list of changes included in the release can be found in the @ref:[release notes](v1.8-release-notes.md). diff --git a/docs/src/main/paradox/docs/releases/v1.8-release-notes.md b/docs/src/main/paradox/docs/releases/v1.8-release-notes.md index fe4e36acb3..1141171f14 100644 --- a/docs/src/main/paradox/docs/releases/v1.8-release-notes.md +++ b/docs/src/main/paradox/docs/releases/v1.8-release-notes.md @@ -134,7 +134,7 @@ upstream dependencies has changed without having to provide again its original p This new validate operation allows to check a resource against a provided schema. This operation is read-only and allows to test a schema against different resources -@ref:[More information](../delta/api/practice.md#validate) +@ref:[More information](../delta/api/trial.md#validate) #### Annotated original payload diff --git a/docs/src/main/paradox/docs/releases/v1.9-release-notes.md b/docs/src/main/paradox/docs/releases/v1.9-release-notes.md index dfed266939..7ccd280186 100644 --- a/docs/src/main/paradox/docs/releases/v1.9-release-notes.md +++ b/docs/src/main/paradox/docs/releases/v1.9-release-notes.md @@ -30,13 +30,13 @@ Multiple resources can now be retrieved within a single call with the multi-fetc @ref:[More information](../delta/api/multi-fetch.md) -#### Resources practice and resource generation +#### Resources trial and resource generation Until 1.9, operations about resources were resulting in writes in the primary store and indexing in the knowledge graph. However, users may also want to first experiment/refine/polish/validate a resource and schema and only create/update the resource when they are happy with it. -@ref:[More information](../delta/api/practice.md#resource-generation) +@ref:[More information](../delta/api/trial.md#resource-generation) #### Payload validation diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesPracticeSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesTrialSpec.scala similarity index 80% rename from tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesPracticeSpec.scala rename to tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesTrialSpec.scala index 7840f0c8a9..363eb2a9af 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesPracticeSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/resources/ResourcesTrialSpec.scala @@ -7,7 +7,7 @@ import ch.epfl.bluebrain.nexus.tests.{BaseSpec, SchemaPayload} import io.circe.Json import io.circe.optics.JsonPath.root -class ResourcesPracticeSpec extends BaseSpec with CirceEq { +class ResourcesTrialSpec extends BaseSpec with CirceEq { private val org = genId() private val proj = genId() @@ -43,15 +43,15 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { def schema = root.schema.`@id`.string.getOption(_) "fail for a user without access" in { - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payloadWithoutSchema, Alice)(expectForbidden) + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payloadWithoutSchema, Alice)(expectForbidden) } "fail for an unknown project" in { - deltaClient.getWithBody[Json](s"/practice/resources/$org/xxx/", payloadWithoutSchema, Alice)(expectForbidden) + deltaClient.getWithBody[Json](s"/trial/resources/$org/xxx/", payloadWithoutSchema, Alice)(expectForbidden) } "succeed for a payload without schema" in { - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payloadWithoutSchema, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payloadWithoutSchema, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json).value shouldEqual resourceId schema(json) shouldBe empty @@ -60,7 +60,7 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { } "succeed for a payload with an existing schema" in { - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payloadWithExistingSchema, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payloadWithExistingSchema, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json).value shouldEqual resourceId schema(json) shouldBe empty @@ -69,7 +69,7 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { } "succeed for a payload with a new schema" in { - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payloadWithNewSchema, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payloadWithNewSchema, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json).value shouldEqual resourceId schema(json).value shouldBe newSchemaId @@ -79,7 +79,7 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { "fail for a resource with an invalid context without generating any schema" in { val payload = json"""{ "resource": { "@context": [ "https://bbp.epfl.ch/unknown-context" ], "test": "fail" } }""" - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payload, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payload, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json) shouldBe empty schema(json) shouldBe empty @@ -90,7 +90,7 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { "fail for a resource with an invalid context but also returning the generated schema" in { val resourcePayload = json"""{ "@context": [ "https://bbp.epfl.ch/unknown-context" ], "test": "fail" }""" val payload = json"""{ "schema": $newSchemaPayload, "resource": $resourcePayload }""" - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payload, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payload, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json) shouldBe empty schema(json).value shouldBe newSchemaId @@ -101,7 +101,7 @@ class ResourcesPracticeSpec extends BaseSpec with CirceEq { "fail for a resource when shacl validation fails returning the generated " in { val resourcePayload = SimpleResource.sourcePayloadWithType("nxv:UnexpectedType", 99) val payload = json"""{ "schema": $newSchemaPayload ,"resource": $resourcePayload }""" - deltaClient.getWithBody[Json](s"/practice/resources/$ref/", payload, Bob) { (json, response) => + deltaClient.getWithBody[Json](s"/trial/resources/$ref/", payload, Bob) { (json, response) => response.status shouldEqual StatusCodes.OK resultId(json) shouldBe empty schema(json).value shouldBe newSchemaId