From ae1eddd193a4b61a81c63df9444d408e3e52c623 Mon Sep 17 00:00:00 2001 From: Raitis Veinbahs Date: Thu, 7 Nov 2024 15:11:56 +0100 Subject: [PATCH] fix.it --- .../knora/webapi/e2e/v2/ValuesV2R2RSpec.scala | 50 ++++++------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/integration/src/test/scala/org/knora/webapi/e2e/v2/ValuesV2R2RSpec.scala b/integration/src/test/scala/org/knora/webapi/e2e/v2/ValuesV2R2RSpec.scala index dab3bc0a711..9a0783e92fb 100644 --- a/integration/src/test/scala/org/knora/webapi/e2e/v2/ValuesV2R2RSpec.scala +++ b/integration/src/test/scala/org/knora/webapi/e2e/v2/ValuesV2R2RSpec.scala @@ -11,7 +11,6 @@ import org.apache.pekko.http.scaladsl.model.headers.BasicHttpCredentials import scala.concurrent.ExecutionContextExecutor -import dsp.errors.AssertionException import dsp.errors.BadRequestException import dsp.valueobjects.Iri import org.knora.webapi.* @@ -30,7 +29,7 @@ import org.apache.pekko.http.scaladsl.model.HttpResponse /** * Tests creating a still image file value using a mock Sipi. */ -class ValuesV2R2RSpec extends E2ESpec { +class ValuesV2R2RSpec extends ITKnoraLiveSpec { private implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -80,32 +79,14 @@ class ValuesV2R2RSpec extends E2ESpec { propertyIriInResult: SmartIri, expectedValueIri: IRI, ): JsonLDObject = { - val resourceIri: IRI = - resource.body.requireStringWithValidation(JsonLDKeywords.ID, validationFun) - val propertyValues: JsonLDArray = - getValuesFromResource(resource = resource, propertyIriInResult = propertyIriInResult) - - val matchingValues: Seq[JsonLDObject] = propertyValues.value.collect { - case jsonLDObject: JsonLDObject - if jsonLDObject.requireStringWithValidation( - JsonLDKeywords.ID, - validationFun, - ) == expectedValueIri => - jsonLDObject - } - - if (matchingValues.isEmpty) { - throw AssertionException( - s"Property <$propertyIriInResult> of resource <$resourceIri> does not have value <$expectedValueIri>", - ) - } - - if (matchingValues.size > 1) { - throw AssertionException( - s"Property <$propertyIriInResult> of resource <$resourceIri> has more than one value with the IRI <$expectedValueIri>", - ) - } - + val matchingValues: Seq[JsonLDObject] = + getValuesFromResource(resource = resource, propertyIriInResult = propertyIriInResult).value.collect { + case jsonLDObject: JsonLDObject + if jsonLDObject.requireStringWithValidation(JsonLDKeywords.ID, validationFun) == expectedValueIri => + jsonLDObject + } + + assert(matchingValues.size == 1) matchingValues.head } @@ -132,8 +113,7 @@ class ValuesV2R2RSpec extends E2ESpec { "The values v2 endpoint" should { "update a still image file value using a mock Sipi" in { val resourceIri: IRI = aThingPictureIri - val internalFilename = "IQUO3t1AABm-FSLC0vNvVpr.jp2" - // val internalFilename = "De6XyNL4H71-D9QxghOuOPJ.jp2" + val internalFilename = "De6XyNL4H71-D9QxghOuOPJ.jp2" val jsonLDEntity = s"""{ | "@id" : "$resourceIri", @@ -151,9 +131,9 @@ class ValuesV2R2RSpec extends E2ESpec { val header = addHeader("X-Asset-Ingested", "true") val request = - Put(baseApiUrl + "/v2/values", HttpEntity(RdfMediaTypes.`application/ld+json`, jsonLDEntity)) ~> addCredentials( - BasicHttpCredentials(anythingUserEmail, password), - ) + Put(baseApiUrl + "/v2/values", HttpEntity(RdfMediaTypes.`application/ld+json`, jsonLDEntity)) + ~> addCredentials(BasicHttpCredentials(anythingUserEmail, password)) + ~> header val response: HttpResponse = singleAwaitingRequest(request) assert(response.status == StatusCodes.OK) @@ -174,8 +154,8 @@ class ValuesV2R2RSpec extends E2ESpec { ) savedValue.getRequiredString(OntConsts.FileValueHasFilename).toOption should contain(internalFilename) - savedValue.getRequiredInt(OntConsts.StillImageFileValueHasDimX).toOption should contain(512) - savedValue.getRequiredInt(OntConsts.StillImageFileValueHasDimY).toOption should contain(256) + savedValue.getRequiredInt(OntConsts.StillImageFileValueHasDimX).toOption should contain(72) + savedValue.getRequiredInt(OntConsts.StillImageFileValueHasDimY).toOption should contain(72) } } }