Skip to content

Commit

Permalink
test(clientapi): Add test responses for create value and update value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Geer committed Feb 26, 2020
1 parent e498d72 commit e3e1727
Showing 1 changed file with 47 additions and 1 deletion.
Expand Up @@ -358,6 +358,28 @@ class ValuesRouteV2(routeData: KnoraRouteData) extends KnoraRoute(routeData) wit
)
}

private def createValueTestResponse: Future[SourceCodeFileContent] = {
val resourceIri: IRI = stringFormatter.makeRandomResourceIri("0001")

val createValueResponseV2: CreateValueResponseV2 = CreateValueResponseV2(
valueIri = stringFormatter.makeRandomValueIri(resourceIri),

This comment has been minimized.

Copy link
@tobiasschweizer

tobiasschweizer Feb 27, 2020

Contributor

Could you make this constant? stringFormatter.makeRandomResourceIri and stringFormatter.makeRandomValueIri return a new resource and value id whenever the test data is regenerated, e.g. on github-ci.

valueType = OntologyConstants.KnoraApiV2Complex.IntValue.toSmartIri,
valueUUID = UUID.randomUUID,
projectADM = SharedTestDataADM.anythingProject
)

Future {
SourceCodeFileContent(
filePath = SourceCodeFilePath.makeJsonPath("create-value-response"),
text = createValueResponseV2.toJsonLDDocument(
targetSchema = ApiV2Complex,
settings = settings,
schemaOptions = Set.empty
).toPrettyString
)
}
}

private def updateValue: Route = path(ValuesBasePath) {
put {
entity(as[String]) { jsonRequest =>
Expand Down Expand Up @@ -583,6 +605,28 @@ class ValuesRouteV2(routeData: KnoraRouteData) extends KnoraRoute(routeData) wit
)
}

private def updateValueTestResponse: Future[SourceCodeFileContent] = {
val resourceIri: IRI = stringFormatter.makeRandomResourceIri("0001")

val createValueResponseV2: UpdateValueResponseV2 = UpdateValueResponseV2(
valueIri = stringFormatter.makeRandomValueIri(resourceIri),
valueType = OntologyConstants.KnoraApiV2Complex.IntValue.toSmartIri,
valueUUID = UUID.randomUUID,
projectADM = SharedTestDataADM.anythingProject
)

Future {
SourceCodeFileContent(
filePath = SourceCodeFilePath.makeJsonPath("update-value-response"),
text = createValueResponseV2.toJsonLDDocument(
targetSchema = ApiV2Complex,
settings = settings,
schemaOptions = Set.empty
).toPrettyString
)
}
}

private def deleteValue: Route = path(ValuesBasePath / "delete") {
post {
entity(as[String]) { jsonRequest =>
Expand Down Expand Up @@ -647,6 +691,8 @@ class ValuesRouteV2(routeData: KnoraRouteData) extends KnoraRoute(routeData) wit
createRequests: Set[SourceCodeFileContent] <- createValueTestRequests
updateRequests: Set[SourceCodeFileContent] <- updateValueTestRequests
deleteRequests: Set[SourceCodeFileContent] <- deleteValueTestRequests
} yield getResponses ++ createRequests ++ updateRequests ++ deleteRequests
createValueResponse: SourceCodeFileContent <- createValueTestResponse
updateValueResponse: SourceCodeFileContent <- updateValueTestResponse
} yield getResponses ++ createRequests ++ updateRequests ++ deleteRequests + createValueResponse + updateValueResponse
}
}

0 comments on commit e3e1727

Please sign in to comment.