Skip to content

Commit

Permalink
refactor: Rename GroupADM and move to domain model package (DEV-3292) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mpro7 authored Mar 6, 2024
1 parent 79e1963 commit 2202bd9
Show file tree
Hide file tree
Showing 24 changed files with 187 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import org.knora.webapi.slice.admin.api.service.ProjectsADMRestServiceLive
import org.knora.webapi.slice.admin.api.service.StoreRestService
import org.knora.webapi.slice.admin.api.service.UsersRestService
import org.knora.webapi.slice.admin.domain.service.*
import org.knora.webapi.slice.admin.repo.service.KnoraGroupRepoLive
import org.knora.webapi.slice.admin.repo.service.KnoraProjectRepoLive
import org.knora.webapi.slice.admin.repo.service.KnoraUserGroupRepoLive
import org.knora.webapi.slice.admin.repo.service.KnoraUserRepoLive
import org.knora.webapi.slice.common.api.*
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
Expand Down Expand Up @@ -103,6 +103,7 @@ object LayersTest {
with FilesEndpointsHandler
with GravsearchTypeInspectionRunner
with GroupsResponderADM
with GroupsService
with HttpServer
with IIIFRequestMessageHandler
with InferenceOptimizationService
Expand Down Expand Up @@ -173,6 +174,7 @@ object LayersTest {
GroupsEndpointsHandler.layer,
GroupsResponderADMLive.layer,
GroupsRestServiceLive.layer,
GroupsService.layer,
HandlerMapper.layer,
HttpServer.layer,
IIIFRequestMessageHandlerLive.layer,
Expand All @@ -181,7 +183,7 @@ object LayersTest {
IriService.layer,
KnoraProjectRepoLive.layer,
KnoraResponseRenderer.layer,
KnoraUserGroupRepoLive.layer,
KnoraGroupRepoLive.layer,
KnoraUserRepoLive.layer,
KnoraUserToUserConverter.layer,
ListRestService.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import org.knora.webapi.E2ESpec
import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
import org.knora.webapi.e2e.TestDataFilePath
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupADM
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupsADMJsonProtocol
import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.Group
import org.knora.webapi.util.AkkaHttpUtils
import org.knora.webapi.util.MutableTestIri

Expand Down Expand Up @@ -115,7 +115,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {

response.status should be(StatusCodes.OK)

val result: GroupADM = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[GroupADM]
val result: Group = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[Group]

// check that the custom IRI is correctly assigned
result.id should be(customGroupIri)
Expand Down Expand Up @@ -186,7 +186,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
// log.debug(s"response: {}", response)
response.status should be(StatusCodes.OK)

val groupInfo: GroupADM = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[GroupADM]
val groupInfo: Group = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[Group]

groupInfo.name should be("NewGroup")
groupInfo.descriptions should be(Seq(StringLiteralV2("NewGroupDescription", Some("en"))))
Expand Down Expand Up @@ -236,7 +236,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
logger.debug(s"response: {}", response)
response.status should be(StatusCodes.OK)

val groupInfo: GroupADM = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[GroupADM]
val groupInfo: Group = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[Group]

groupInfo.name should be("UpdatedGroupName")
groupInfo.descriptions should be(Seq(StringLiteralV2("UpdatedGroupDescription", Some("en"))))
Expand Down Expand Up @@ -265,7 +265,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
logger.debug(s"response: {}", response)
response.status should be(StatusCodes.OK)

val groupInfo: GroupADM = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[GroupADM]
val groupInfo: Group = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[Group]

groupInfo.name should be("UpdatedGroupName")
groupInfo.descriptions should be(Seq(StringLiteralV2("UpdatedGroupDescription", Some("en"))))
Expand Down Expand Up @@ -312,7 +312,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
logger.debug(s"response: {}", response)
response.status should be(StatusCodes.OK)

val groupInfo: GroupADM = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[GroupADM]
val groupInfo: Group = AkkaHttpUtils.httpResponseToJson(response).fields("group").convertTo[Group]

groupInfo.name should be("UpdatedGroupName")
groupInfo.descriptions should be(Seq(StringLiteralV2("UpdatedGroupDescription", Some("en"))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.knora.webapi.*
import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
import org.knora.webapi.e2e.TestDataFilePath
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupADM
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupsADMJsonProtocol
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectADM
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectsADMJsonProtocol
Expand All @@ -24,6 +23,7 @@ import org.knora.webapi.messages.store.triplestoremessages.TriplestoreJsonProtoc
import org.knora.webapi.messages.util.KnoraSystemInstances
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM2
import org.knora.webapi.slice.admin.domain.model.Group
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.util.AkkaHttpUtils
import org.knora.webapi.util.MutableTestIri
Expand Down Expand Up @@ -109,7 +109,7 @@ class UsersADME2ESpec
val userIriEnc = java.net.URLEncoder.encode(userIri, "utf-8")
val request = Get(baseApiUrl + s"/admin/users/iri/$userIriEnc/group-memberships") ~> addRootUserCredentials()
val response = singleAwaitingRequest(request)
AkkaHttpUtils.httpResponseToJson(response).fields("groups").convertTo[Seq[GroupADM]]
AkkaHttpUtils.httpResponseToJson(response).fields("groups").convertTo[Seq[Group]]
}

"The Users Route ('admin/users')" when {
Expand Down Expand Up @@ -1364,8 +1364,8 @@ class UsersADME2ESpec

assert(response.status === StatusCodes.OK)

val groups: Seq[GroupADM] =
AkkaHttpUtils.httpResponseToJson(response).fields("groups").convertTo[List[GroupADM]]
val groups: Seq[Group] =
AkkaHttpUtils.httpResponseToJson(response).fields("groups").convertTo[List[Group]]
groups should contain allElementsOf Seq(SharedTestDataADM.imagesReviewerGroupExternal)

// testing getUserGroupMemberships method, which should return the same result
Expand All @@ -1388,7 +1388,7 @@ class UsersADME2ESpec
"used to modify group membership" should {
"add user to group" in {
val membershipsBeforeUpdate = getUserGroupMemberships(normalUser.id)
membershipsBeforeUpdate should equal(Seq.empty[GroupADM])
membershipsBeforeUpdate should equal(Seq.empty[Group])

val request = Post(
baseApiUrl + s"/admin/users/iri/${URLEncoder.encode(normalUser.id, "utf-8")}/group-memberships/$imagesReviewerGroupIriEnc",
Expand Down Expand Up @@ -1424,7 +1424,7 @@ class UsersADME2ESpec
assert(response.status === StatusCodes.OK)

val membershipsAfterUpdate = getUserProjectMemberships(normalUserIri)
membershipsAfterUpdate should equal(Seq.empty[GroupADM])
membershipsAfterUpdate should equal(Seq.empty[Group])

clientTestDataCollector.addFile(
TestDataFileContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class GroupsResponderADMSpec extends CoreSpec {
name = Some(GroupName.unsafeFrom("UpdatedGroupName")),
descriptions = Some(
GroupDescriptions.unsafeFrom(
Seq(V2.StringLiteralV2(value = """UpdatedDescription with "quotes" and <html tag>""", Some("en"))),
Seq(V2.StringLiteralV2("""UpdatedDescription with "quotes" and <html tag>""", Some("en"))),
),
),
status = Some(GroupStatus.active),
Expand Down Expand Up @@ -216,8 +216,8 @@ class GroupsResponderADMSpec extends CoreSpec {

"remove all members when group is deactivated" in {
val group = UnsafeZioRun.runOrThrow(
GroupsResponderADM.groupMembersGetRequestADM(
GroupIri.unsafeFrom(imagesReviewerGroup.id).value,
GroupsResponderADM.groupMembersGetRequest(
GroupIri.unsafeFrom(imagesReviewerGroup.id),
rootUser,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import dsp.errors.ForbiddenException
import dsp.errors.NotFoundException
import dsp.valueobjects.LanguageCode
import org.knora.webapi.*
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupADM
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupMembersGetRequestADM
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM.*
import org.knora.webapi.messages.admin.responder.usersmessages.*
import org.knora.webapi.messages.util.KnoraSystemInstances
Expand All @@ -31,6 +29,7 @@ import org.knora.webapi.slice.admin.api.UsersEndpoints.Requests.StatusChangeRequ
import org.knora.webapi.slice.admin.api.UsersEndpoints.Requests.SystemAdminChangeRequest
import org.knora.webapi.slice.admin.api.UsersEndpoints.Requests.UserCreateRequest
import org.knora.webapi.slice.admin.api.service.UsersRestService
import org.knora.webapi.slice.admin.domain.model.Group
import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri
import org.knora.webapi.slice.admin.domain.model.Username
import org.knora.webapi.slice.admin.domain.model.*
Expand Down Expand Up @@ -572,7 +571,7 @@ class UsersRestServiceSpec extends CoreSpec with ImplicitSender {
}

"asked to update the user's group membership" should {
def findGroupMembershipsByIri(userIri: UserIri): Seq[GroupADM] =
def findGroupMembershipsByIri(userIri: UserIri): Seq[Group] =
UnsafeZioRun.runOrThrow(
ZIO.serviceWithZIO[UserService](_.findUserByIri(userIri).map(_.map(_.groups).getOrElse(Seq.empty))),
)
Expand All @@ -586,12 +585,12 @@ class UsersRestServiceSpec extends CoreSpec with ImplicitSender {
val membershipsAfterUpdate = findGroupMembershipsByIri(normalUser.userIri)
membershipsAfterUpdate.map(_.id) should equal(Seq(imagesReviewerGroup.id))

appActor ! GroupMembersGetRequestADM(
groupIri = imagesReviewerGroup.id,
requestingUser = rootUser,
val received = UnsafeZioRun.runOrThrow(
GroupsResponderADM.groupMembersGetRequest(
GroupIri.unsafeFrom(imagesReviewerGroup.id),
rootUser,
),
)
val received: GroupMembersGetResponseADM = expectMsgType[GroupMembersGetResponseADM](timeout)

received.members.map(_.id) should contain(normalUser.id)
}

Expand All @@ -610,13 +609,13 @@ class UsersRestServiceSpec extends CoreSpec with ImplicitSender {
val membershipsAfterUpdate = findGroupMembershipsByIri(normalUser.userIri)
membershipsAfterUpdate should equal(Seq())

appActor ! GroupMembersGetRequestADM(
groupIri = imagesReviewerGroup.id,
requestingUser = rootUser,
val received = UnsafeZioRun.runOrThrow(
GroupsResponderADM.groupMembersGetRequest(
GroupIri.unsafeFrom(imagesReviewerGroup.id),
rootUser,
),
)
val received: GroupMembersGetResponseADM = expectMsgType[GroupMembersGetResponseADM](timeout)

received.members.map(_.id) should not contain normalUser.id
received.members.map(_.id) should not contain normalUser
}
}
}
Expand Down
Loading

0 comments on commit 2202bd9

Please sign in to comment.