diff --git a/ship/src/test/scala/ch/epfl/bluebrain/nexus/ship/EndToEndTest.scala b/ship/src/test/scala/ch/epfl/bluebrain/nexus/ship/EndToEndTest.scala index 487ede9910..802079eeb5 100644 --- a/ship/src/test/scala/ch/epfl/bluebrain/nexus/ship/EndToEndTest.scala +++ b/ship/src/test/scala/ch/epfl/bluebrain/nexus/ship/EndToEndTest.scala @@ -32,7 +32,7 @@ class EndToEndTest extends BaseIntegrationSpec { "transfer a project" in { - val project = thereIsAProject() + val (project, projectJson) = thereIsAProject() whenTheExportIsRunOnProject(project) @@ -42,13 +42,15 @@ class EndToEndTest extends BaseIntegrationSpec { weFixThePermissions(project) - thereShouldBeAProject(project) + thereShouldBeAProject(project, projectJson) } - def thereIsAProject(): ProjectRef = { + def thereIsAProject(): (ProjectRef, Json) = { val project: ProjectRef = ProjectRef.unsafe(genString(), genString()) createProjects(writer, project.organization.value, project.project.value).accepted - project + val (projectJson, status) = deltaClient.getJsonAndStatus(s"/projects/${project.organization}/${project.project}", writer).accepted + status shouldEqual StatusCodes.OK + project -> projectJson } def whenTheExportIsRunOnProject(project: ProjectRef): Unit = { @@ -87,9 +89,12 @@ class EndToEndTest extends BaseIntegrationSpec { () } - def thereShouldBeAProject(project: ProjectRef): Assertion = { + def thereShouldBeAProject(project: ProjectRef, originalJson: Json): Assertion = { deltaClient.get[Json](s"/projects/${project.organization}/${project.project}", writer) { - (_, response) => response.status shouldEqual StatusCodes.OK + (json, response) => { + response.status shouldEqual StatusCodes.OK + json shouldEqual originalJson + } }.accepted } diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/HttpClient.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/HttpClient.scala index 76e8d5a29c..8a542a5ab5 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/HttpClient.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/HttpClient.scala @@ -200,6 +200,10 @@ class HttpClient private (baseUrl: Uri, httpExt: HttpExt)(implicit requestJson(GET, url, None, identity, (a: A, _: HttpResponse) => a, jsonHeaders) } + def getJsonAndStatus(url: String, identity: Identity)(implicit um: FromEntityUnmarshaller[Json]): IO[(Json, StatusCode)] = { + requestJsonAndStatus(GET, url, None, identity, jsonHeaders) + } + def delete[A](url: String, identity: Identity, extraHeaders: Seq[HttpHeader] = jsonHeaders)( assertResponse: (A, HttpResponse) => Assertion )(implicit um: FromEntityUnmarshaller[A]): IO[Assertion] = @@ -261,6 +265,23 @@ class HttpClient private (baseUrl: Uri, httpExt: HttpExt)(implicit ) } + def requestJsonAndStatus( + method: HttpMethod, + url: String, + body: Option[Json], + identity: Identity, + extraHeaders: Seq[HttpHeader] + )(implicit um: FromEntityUnmarshaller[Json]): IO[(Json, StatusCode)] = + request[Json, Json, (Json, StatusCode)]( + method, + url, + body, + identity, + (j: Json) => HttpEntity(ContentTypes.`application/json`, j.noSpaces), + (json, response) => (json, response.status), + extraHeaders + ) + def requestJson[A, R]( method: HttpMethod, url: String,