Skip to content

Commit

Permalink
test(external iiif image): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
domsteinbach committed Aug 6, 2024
1 parent 5f5dc10 commit a54eb82
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/api/v2/values/values-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import { ReadBooleanValue } from "../../../models/v2/resources/values/read/read-
import { ReadColorValue } from "../../../models/v2/resources/values/read/read-color-value";
import { KnoraDate, ReadDateValue } from "../../../models/v2/resources/values/read/read-date-value";
import { ReadDecimalValue } from "../../../models/v2/resources/values/read/read-decimal-value";
import { ReadStillImageFileValue } from "../../../models/v2/resources/values/read/read-file-value";
import {
ReadStillImageExternalFileValue,
ReadStillImageFileValue
} from "../../../models/v2/resources/values/read/read-file-value";
import { ReadGeomValue } from "../../../models/v2/resources/values/read/read-geom-value";
import { ReadGeonameValue } from "../../../models/v2/resources/values/read/read-geoname-value";
import { ReadIntValue } from "../../../models/v2/resources/values/read/read-int-value";
Expand Down Expand Up @@ -490,6 +493,35 @@ describe("ValuesEndpoint", () => {

});

it("should read an external image file value", done => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0803/RRjceJu5S86zfc_-ZrIEtg", "1-COzXfuTXiwDJ_2GZxeoQ").subscribe(
(res: ReadResource) => {
const externalImageVal = res.getValuesAs("http://api.knora.org/ontology/knora-api/v2#hasStillImageFileValue", ReadStillImageExternalFileValue);
expect(externalImageVal.length).toEqual(1);
expect(externalImageVal[0].externalUrl).toEqual("https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg");

expect(getResourceClassDefinitionFromCacheSpy).toHaveBeenCalledTimes(1);
expect(getResourceClassDefinitionFromCacheSpy).toHaveBeenCalledWith("http://0.0.0.0:3333/ontology/0001/anything/v2#ThingPicture");

expect(getListNodeFromCacheSpy).toHaveBeenCalledTimes(0);

done();
}
);

const request = jasmine.Ajax.requests.mostRecent();

const resource = require("../../../../test/data/api/v2/manually-generated/get-still-image-external-file-value-response.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(resource)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/values/http%3A%2F%2Frdfh.ch%2F0803%2FRRjceJu5S86zfc_-ZrIEtg/1-COzXfuTXiwDJ_2GZxeoQ");

expect(request.method).toEqual("GET");

});

it("should read a geometry value", done => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw", "we-ybmj-SRen-91n4RaDOQ").subscribe(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"knora-api:arkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0001/a=thing=picture1",
"@type": "xsd:anyURI"
},
"knora-api:versionArkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0001/a=thing=picture1.20110302T150510Z",
"@type": "xsd:anyURI"
},
"knora-api:attachedToProject": {
"@id": "http://rdfh.ch/projects/0001"
},
"knora-api:userHasPermission": "CR",
"knora-api:creationDate": {
"@value": "2024-08-05T15:20:29.932538430Z",
"@type": "xsd:dateTimeStamp"
},
"knora-api:attachedToUser": {
"@id": "http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q"
},
"knora-api:hasPermissions": "CR knora-admin:Creator|M knora-admin:ProjectMember|RV knora-admin:UnknownUser",
"@type": "anything:ThingPicture",
"@id": "http://rdfh.ch/0001/a-thing-picture",
"rdfs:label": "A thing with an external iiif picture",
"knora-api:hasStillImageFileValue": {
"knora-api:arkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0803/RRjceJu5S86zfc_=ZrIEtgK/1=COzXfuTXiwDJ_2GZxeoQR",
"@type": "xsd:anyURI"
},
"knora-api:versionArkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0803/RRjceJu5S86zfc_=ZrIEtgK/1=COzXfuTXiwDJ_2GZxeoQR.20240805T15202993253843Z",
"@type": "xsd:anyURI"
},
"knora-api:userHasPermission": "CR",
"knora-api:valueCreationDate": {
"@value": "2024-08-05T15:20:29.932538430Z",
"@type": "xsd:dateTimeStamp"
},
"knora-api:valueHasUUID": "1-COzXfuTXiwDJ_2GZxeoQ",
"knora-api:stillImageFileValueHasIIIFBaseUrl": {
"@value": "https://ids.lib.harvard.edu",
"@type": "xsd:anyURI"
},
"@id": "http://rdfh.ch/0803/RRjceJu5S86zfc_-ZrIEtg/values/1-COzXfuTXiwDJ_2GZxeoQ",
"knora-api:stillImageFileValueHasExternalUrl": {
"@value": "https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg",
"@type": "xsd:anyURI"
},
"knora-api:attachedToUser": {
"@id": "http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q"
},
"knora-api:fileValueAsUrl": {
"@value": "https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg",
"@type": "xsd:anyURI"
},
"knora-api:hasPermissions": "M knora-admin:Creator,knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser",
"@type": "knora-api:StillImageExternalFileValue",
"knora-api:fileValueHasFilename": "internalFilename"
},
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"knora-api": "http://api.knora.org/ontology/knora-api/v2#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"anything": "http://0.0.0.0:3333/ontology/0001/anything/v2#"
}
}

0 comments on commit a54eb82

Please sign in to comment.