Skip to content

Commit

Permalink
refactor: Align rest services naming & make layers more readable (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpro7 authored Apr 11, 2024
1 parent 28a085b commit 5a3374a
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 164 deletions.
71 changes: 58 additions & 13 deletions integration/src/test/scala/org/knora/webapi/core/LayersTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import org.knora.webapi.routing._
import org.knora.webapi.slice.admin.AdminModule
import org.knora.webapi.slice.admin.api.AdminApiModule
import org.knora.webapi.slice.admin.api._
import org.knora.webapi.slice.admin.api.service.GroupsRestService
import org.knora.webapi.slice.admin.api.service.PermissionsRestService
import org.knora.webapi.slice.admin.api.service.GroupRestService
import org.knora.webapi.slice.admin.api.service.PermissionRestService
import org.knora.webapi.slice.admin.api.service.ProjectRestService
import org.knora.webapi.slice.admin.api.service.UsersRestService
import org.knora.webapi.slice.admin.api.service.UserRestService
import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageService
import org.knora.webapi.slice.admin.domain.service._
import org.knora.webapi.slice.common.api._
Expand Down Expand Up @@ -86,16 +86,61 @@ object LayersTest {
pekko.actor.ActorSystem & AppConfigurationsTest & JwtConfig & WhichSipiService

type CommonR =
ApiRoutes & AdminApiEndpoints & ApiV2Endpoints & AppRouter & AssetPermissionsResponder & Authenticator &
AuthorizationRestService & CacheServiceRequestMessageHandler & CardinalityHandler & ConstructResponseUtilV2 &
DspIngestClient & GravsearchTypeInspectionRunner & GroupsResponderADM & GroupsRestService & GroupService &
HttpServer & IIIFRequestMessageHandler & InferenceOptimizationService & IriConverter & KnoraUserToUserConverter & ListsResponder &
ListsResponderV2 & MessageRelay & OntologyCache & OntologyHelpers & OntologyInferencer & OntologyRepo &
OntologyResponderV2 & PermissionUtilADM & PermissionsResponder & PermissionsRestService & ProjectExportService &
ProjectExportStorageService & ProjectImportService & ProjectService & ProjectRestService & QueryTraverser &
RepositoryUpdater & ResourceUtilV2 & ResourcesResponderV2 & RestCardinalityService & SearchApiRoutes &
SearchResponderV2 & StandoffResponderV2 & StandoffTagUtilV2 & State & TestClientService & TriplestoreService &
UserService & UsersResponder & UsersRestService & ValuesResponderV2 & JwtService & SipiService & StringFormatter
AdminApiEndpoints &
ApiRoutes &
ApiV2Endpoints &
AppRouter &
AssetPermissionsResponder &
Authenticator &
AuthorizationRestService &
CacheServiceRequestMessageHandler &
CardinalityHandler &
ConstructResponseUtilV2 &
DspIngestClient &
GravsearchTypeInspectionRunner &
GroupRestService &
GroupService &
GroupsResponderADM &
HttpServer &
IIIFRequestMessageHandler &
InferenceOptimizationService &
IriConverter &
JwtService &
KnoraUserToUserConverter &
ListsResponder &
ListsResponderV2 &
MessageRelay &
OntologyCache &
OntologyHelpers &
OntologyInferencer &
OntologyRepo &
OntologyResponderV2 &
PermissionRestService &
PermissionUtilADM &
PermissionsResponder &
ProjectExportService &
ProjectExportStorageService &
ProjectImportService &
ProjectRestService &
ProjectService &
QueryTraverser &
RepositoryUpdater &
ResourceUtilV2 &
ResourcesResponderV2 &
RestCardinalityService &
SearchApiRoutes &
SearchResponderV2 &
SipiService &
StandoffResponderV2 &
StandoffTagUtilV2 &
State &
StringFormatter &
TestClientService &
TriplestoreService &
UserRestService &
UserService &
UsersResponder &
ValuesResponderV2

private val commonLayersForAllIntegrationTests =
ZLayer.makeSome[CommonR0, CommonR](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.sharedtestdata.SharedOntologyTestDataADM._
import org.knora.webapi.sharedtestdata.SharedTestDataADM2._
import org.knora.webapi.sharedtestdata._
import org.knora.webapi.slice.admin.api.service.PermissionsRestService
import org.knora.webapi.slice.admin.api.service.PermissionRestService
import org.knora.webapi.slice.admin.domain.model.Permission
import org.knora.webapi.slice.admin.domain.service.KnoraGroupRepo
import org.knora.webapi.util.ZioScalaTestUtil.assertFailsWithA
Expand Down Expand Up @@ -45,7 +45,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"Administrative Permission Create Requests" should {
"return 'BadRequest' if the supplied project IRI for AdministrativePermissionCreateRequestADM is not valid" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
forProject = "invalid-project-IRI",
forGroup = KnoraGroupRepo.builtIn.ProjectMember.id.value,
Expand All @@ -60,7 +60,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"return 'BadRequest' if the supplied group IRI for AdministrativePermissionCreateRequestADM is not valid" in {
val groupIri = "invalid-group-iri"
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = groupIri,
Expand All @@ -75,7 +75,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"return 'BadRequest' if the supplied permission IRI for AdministrativePermissionCreateRequestADM is not valid" in {
val permissionIri = "invalid-permission-IRI"
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
id = Some(permissionIri),
forProject = SharedTestDataADM.imagesProjectIri,
Expand All @@ -98,7 +98,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
),
)
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = KnoraGroupRepo.builtIn.ProjectMember.id.value,
Expand All @@ -116,7 +116,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if the a permissions supplied for AdministrativePermissionCreateRequestADM had invalid name" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = KnoraGroupRepo.builtIn.ProjectMember.id.value,
Expand All @@ -130,7 +130,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'ForbiddenException' if the user requesting AdministrativePermissionCreateRequestADM is not system or project admin" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createAdministrativePermission(
PermissionRestService.createAdministrativePermission(
CreateAdministrativePermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = KnoraGroupRepo.builtIn.ProjectMember.id.value,
Expand Down Expand Up @@ -393,7 +393,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"return 'BadRequest' if the supplied project IRI for DefaultObjectAccessPermissionCreateRequestADM is not valid" in {
val forProject = "invalid-project-IRI"
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = forProject,
forGroup = Some(KnoraGroupRepo.builtIn.ProjectMember.id.value),
Expand All @@ -410,7 +410,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"return 'BadRequest' if the supplied group IRI for DefaultObjectAccessPermissionCreateRequestADM is not valid" in {
val groupIri = "invalid-group-iri"
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = Some(groupIri),
Expand All @@ -427,7 +427,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {
"return 'BadRequest' if the supplied custom permission IRI for DefaultObjectAccessPermissionCreateRequestADM is not valid" in {
val permissionIri = "invalid-permission-IRI"
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
id = Some(permissionIri),
forProject = SharedTestDataADM.imagesProjectIri,
Expand All @@ -444,7 +444,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if the no permissions supplied for DefaultObjectAccessPermissionCreateRequestADM" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = SharedTestDataADM.imagesProjectIri,
forGroup = Some(SharedTestDataADM.thingSearcherGroup.id),
Expand Down Expand Up @@ -546,7 +546,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'ForbiddenException' if the user requesting DefaultObjectAccessPermissionCreateRequestADM is not system or project Admin" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = SharedTestDataADM.anythingProjectIri,
forGroup = Some(SharedTestDataADM.thingSearcherGroup.id),
Expand All @@ -564,7 +564,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if the both group and resource class are supplied for DefaultObjectAccessPermissionCreateRequestADM" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = anythingProjectIri,
forGroup = Some(KnoraGroupRepo.builtIn.ProjectMember.id.value),
Expand All @@ -581,7 +581,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if the both group and property are supplied for DefaultObjectAccessPermissionCreateRequestADM" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = anythingProjectIri,
forGroup = Some(KnoraGroupRepo.builtIn.ProjectMember.id.value),
Expand All @@ -598,7 +598,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if propertyIri supplied for DefaultObjectAccessPermissionCreateRequestADM is not valid" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = anythingProjectIri,
forProperty = Some(SharedTestDataADM.customValueIRI),
Expand All @@ -614,7 +614,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if resourceClassIri supplied for DefaultObjectAccessPermissionCreateRequestADM is not valid" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = anythingProjectIri,
forResourceClass = Some(ANYTHING_THING_RESOURCE_CLASS_LocalHost),
Expand All @@ -633,7 +633,7 @@ class PermissionsMessagesADMSpec extends CoreSpec {

"return 'BadRequest' if neither a group, nor a resource class, nor a property is supplied for DefaultObjectAccessPermissionCreateRequestADM" in {
val exit = UnsafeZioRun.run(
PermissionsRestService.createDefaultObjectAccessPermission(
PermissionRestService.createDefaultObjectAccessPermission(
CreateDefaultObjectAccessPermissionAPIRequestADM(
forProject = anythingProjectIri,
hasPermissions = Set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.knora.webapi.sharedtestdata.SharedTestDataADM._
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupCreateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupStatusUpdateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupUpdateRequest
import org.knora.webapi.slice.admin.api.service.GroupsRestService
import org.knora.webapi.slice.admin.api.service.GroupRestService
import org.knora.webapi.slice.admin.domain.model.GroupDescriptions
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.GroupName
Expand All @@ -33,7 +33,7 @@ import org.knora.webapi.util.ZioScalaTestUtil.assertFailsWithA
* This spec is used to test the messages received by the [[GroupsResponderADMSpec]] actor.
*/
class GroupsResponderADMSpec extends CoreSpec {
private val groupRestService = ZIO.serviceWithZIO[GroupsRestService]
private val groupRestService = ZIO.serviceWithZIO[GroupRestService]
private val groupService = ZIO.serviceWithZIO[GroupService]

"The GroupsResponder " when {
Expand Down
Loading

0 comments on commit 5a3374a

Please sign in to comment.