-
Notifications
You must be signed in to change notification settings - Fork 18
/
TestDataFactory.scala
94 lines (77 loc) · 3.06 KB
/
TestDataFactory.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/
package org.knora.webapi
import zio.NonEmptyChunk
import dsp.valueobjects.Iri._
import dsp.valueobjects.Project._
import dsp.valueobjects.V2
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM._
import org.knora.webapi.slice.admin.domain.model.KnoraProject
import org.knora.webapi.slice.resourceinfo.domain.InternalIri
/**
* Helps in creating value objects for tests.
*/
object TestDataFactory {
val someProject = KnoraProject(
InternalIri("http://rdfh.ch/projects/0001"),
Shortname.unsafeFrom("shortname"),
Shortcode.unsafeFrom("0001"),
None,
NonEmptyChunk(V2.StringLiteralV2("Some description", None)),
List.empty,
None,
true,
false,
List.empty
)
def projectShortcodeIdentifier(shortcode: String): ShortcodeIdentifier =
ShortcodeIdentifier
.fromString(shortcode)
.getOrElse(throw new IllegalArgumentException(s"Invalid ShortcodeIdentifier $shortcode."))
def projectShortnameIdentifier(shortname: String): ShortnameIdentifier =
ShortnameIdentifier
.fromString(shortname)
.getOrElse(throw new IllegalArgumentException(s"Invalid ShortnameIdentifier $shortname."))
def projectIriIdentifier(iri: String): IriIdentifier =
IriIdentifier
.fromString(iri)
.getOrElse(throw new IllegalArgumentException(s"Invalid IriIdentifier $iri."))
def projectShortcode(shortcode: String): Shortcode =
Shortcode
.make(shortcode)
.getOrElse(throw new IllegalArgumentException(s"Invalid Shortcode $shortcode."))
def projectShortname(shortname: String): Shortname =
Shortname
.make(shortname)
.getOrElse(throw new IllegalArgumentException(s"Invalid Shortname $shortname."))
def projectName(name: String): Name =
Name
.make(name)
.getOrElse(throw new IllegalArgumentException(s"Invalid Name $name."))
def projectDescription(description: Seq[V2.StringLiteralV2]): Description =
Description
.make(description)
.getOrElse(throw new IllegalArgumentException(s"Invalid ProjectDescription $description."))
def projectKeywords(keywords: Seq[String]): Keywords =
Keywords
.make(keywords)
.getOrElse(throw new IllegalArgumentException(s"Invalid Keywords $keywords."))
def projectLogo(logo: String): Logo =
Logo
.make(logo)
.getOrElse(throw new IllegalArgumentException(s"Invalid Logo $logo."))
def projectStatus(status: Boolean): ProjectStatus =
ProjectStatus
.make(status)
.getOrElse(throw new IllegalArgumentException(s"Invalid ProjectStatus $status."))
def projectSelfJoin(selfJoin: Boolean): ProjectSelfJoin =
ProjectSelfJoin
.make(selfJoin)
.getOrElse(throw new IllegalArgumentException(s"Invalid ProjectSelfJoin $selfJoin."))
def projectIri(iri: String): ProjectIri =
ProjectIri
.make(iri)
.getOrElse(throw new IllegalArgumentException(s"Invalid ProjectIri $iri."))
}