diff --git a/webapi/src/it/scala/org/knora/webapi/e2e/v1/SearchV1R2RSpec.scala b/webapi/src/it/scala/org/knora/webapi/e2e/v1/SearchV1R2RSpec.scala index 0348bec4c3..a831ee3a3b 100644 --- a/webapi/src/it/scala/org/knora/webapi/e2e/v1/SearchV1R2RSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/e2e/v1/SearchV1R2RSpec.scala @@ -5,9 +5,7 @@ package org.knora.webapi.e2e.v1 -import akka.actor.ActorSystem import akka.http.javadsl.model.StatusCodes -import akka.http.scaladsl.testkit.RouteTestTimeout import org.scalatest.Assertion import org.scalatest.DoNotDiscover import spray.json._ @@ -18,8 +16,6 @@ import org.knora.webapi._ import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject import org.knora.webapi.routing.v1.SearchRouteV1 -import scala.concurrent.duration.{FiniteDuration, NANOSECONDS} - /** * End-to-end test specification for the search endpoint. This specification uses the Spray Testkit as documented * here: http://spray.io/documentation/1.2.2/spray-testkit/ diff --git a/webapi/src/it/scala/org/knora/webapi/responders/admin/GroupsResponderADMSpec.scala b/webapi/src/it/scala/org/knora/webapi/responders/admin/GroupsResponderADMSpec.scala index 645b340369..1ad2d06569 100644 --- a/webapi/src/it/scala/org/knora/webapi/responders/admin/GroupsResponderADMSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/responders/admin/GroupsResponderADMSpec.scala @@ -8,7 +8,6 @@ package org.knora.webapi.responders.admin import akka.actor.Status.Failure import java.util.UUID -import scala.concurrent.duration._ import dsp.errors.BadRequestException import dsp.errors.DuplicateValueException @@ -29,7 +28,6 @@ import org.knora.webapi.util.MutableTestIri class GroupsResponderADMSpec extends CoreSpec { private val imagesProject = SharedTestDataADM.imagesProject private val imagesReviewerGroup = SharedTestDataADM.imagesReviewerGroup - private val rootUser = SharedTestDataADM.rootUser "The GroupsResponder " when { "asked about all groups" should { @@ -81,7 +79,7 @@ class GroupsResponderADMSpec extends CoreSpec { ) .fold(e => throw e.head, v => v), project = ProjectIri.make(SharedTestDataADM.imagesProjectIri).fold(e => throw e.head, v => v), - status = GroupStatus.make(true).fold(e => throw e.head, v => v), + status = GroupStatus.active, selfjoin = GroupSelfJoin.make(false).fold(e => throw e.head, v => v) ), requestingUser = SharedTestDataADM.imagesUser01, @@ -114,7 +112,7 @@ class GroupsResponderADMSpec extends CoreSpec { .make(Seq(V2.StringLiteralV2(value = "NewGroupDescription", language = Some("en")))) .fold(e => throw e.head, v => v), project = ProjectIri.make(SharedTestDataADM.imagesProjectIri).fold(e => throw e.head, v => v), - status = GroupStatus.make(true).fold(e => throw e.head, v => v), + status = GroupStatus.active, selfjoin = GroupSelfJoin.make(false).fold(e => throw e.head, v => v) ), requestingUser = SharedTestDataADM.imagesUser01, diff --git a/webapi/src/it/scala/org/knora/webapi/responders/v2/SearchResponderV2Spec.scala b/webapi/src/it/scala/org/knora/webapi/responders/v2/SearchResponderV2Spec.scala index fa14b59996..f1d0b968ed 100644 --- a/webapi/src/it/scala/org/knora/webapi/responders/v2/SearchResponderV2Spec.scala +++ b/webapi/src/it/scala/org/knora/webapi/responders/v2/SearchResponderV2Spec.scala @@ -7,8 +7,6 @@ package org.knora.webapi.responders.v2 import akka.testkit.ImplicitSender -import scala.concurrent.duration._ - import org.knora.webapi.ApiV2Complex import org.knora.webapi.CoreSpec import org.knora.webapi.SchemaOptions diff --git a/webapi/src/it/scala/org/knora/webapi/responders/v2/ontology/CardinalitiesSpec.scala b/webapi/src/it/scala/org/knora/webapi/responders/v2/ontology/CardinalitiesSpec.scala index a961a4c7e1..89f265871b 100644 --- a/webapi/src/it/scala/org/knora/webapi/responders/v2/ontology/CardinalitiesSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/responders/v2/ontology/CardinalitiesSpec.scala @@ -5,7 +5,6 @@ package org.knora.webapi.responders.v2.ontology -import akka.util.Timeout import zio.ZIO import org.knora.webapi.CoreSpec diff --git a/webapi/src/it/scala/org/knora/webapi/routing/AuthenticatorSpec.scala b/webapi/src/it/scala/org/knora/webapi/routing/AuthenticatorSpec.scala index 8cfa54479b..9c4eb4c154 100644 --- a/webapi/src/it/scala/org/knora/webapi/routing/AuthenticatorSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/routing/AuthenticatorSpec.scala @@ -6,7 +6,6 @@ package org.knora.webapi.routing import akka.testkit.ImplicitSender -import akka.util.Timeout import org.scalatest.PrivateMethodTester import dsp.errors.BadCredentialsException diff --git a/webapi/src/it/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportServiceIT.scala b/webapi/src/it/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportServiceIT.scala index 8ef7167764..1da4fa6716 100644 --- a/webapi/src/it/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportServiceIT.scala +++ b/webapi/src/it/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportServiceIT.scala @@ -5,7 +5,6 @@ package org.knora.webapi.slice.admin.domain.service -import dsp.valueobjects.Project import dsp.valueobjects.Project.Shortcode import org.knora.webapi.config.{Fuseki, Triplestore} import org.knora.webapi.testcontainers.FusekiTestContainer diff --git a/webapi/src/main/scala/dsp/valueobjects/Group.scala b/webapi/src/main/scala/dsp/valueobjects/Group.scala index 95d7e028bf..052ad2d4c9 100644 --- a/webapi/src/main/scala/dsp/valueobjects/Group.scala +++ b/webapi/src/main/scala/dsp/valueobjects/Group.scala @@ -60,13 +60,9 @@ object Group { */ sealed abstract case class GroupStatus private (value: Boolean) object GroupStatus { self => - def make(value: Boolean): Validation[Throwable, GroupStatus] = - Validation.succeed(new GroupStatus(value) {}) - def make(value: Option[Boolean]): Validation[Throwable, Option[GroupStatus]] = - value match { - case Some(v) => self.make(v).map(Some(_)) - case None => Validation.succeed(None) - } + val active: GroupStatus = new GroupStatus(true) {} + val inactive: GroupStatus = new GroupStatus(false) {} + def make(value: Boolean): GroupStatus = if (value) active else inactive } /** diff --git a/webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala b/webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala index a4655829b3..574d129d5c 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala @@ -506,11 +506,7 @@ final case class GroupsResponderADMLive( !userPermissions.isSystemAdmin } - maybeStatus = changeGroupRequest.status match { - case Some(value) => - Some(GroupStatus.make(value).fold(e => throw e.head, v => v)) - case None => None - } + maybeStatus = changeGroupRequest.status.map(GroupStatus.make) /* create the update request */ groupUpdatePayload = GroupUpdatePayloadADM(status = maybeStatus) diff --git a/webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala b/webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala index 2f04808b28..2e2f8e7589 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/admin/GroupsRouteADM.scala @@ -77,7 +77,7 @@ final case class GroupsRouteADM( val name: Validation[Throwable, GroupName] = GroupName.make(apiRequest.name) val descriptions: Validation[Throwable, GroupDescriptions] = GroupDescriptions.make(apiRequest.descriptions) val project: Validation[Throwable, ProjectIri] = ProjectIri.make(apiRequest.project) - val status: Validation[Throwable, GroupStatus] = GroupStatus.make(apiRequest.status) + val status: Validation[Throwable, GroupStatus] = Validation.succeed(GroupStatus.make(apiRequest.status)) val selfjoin: Validation[Throwable, GroupSelfJoin] = GroupSelfJoin.make(apiRequest.selfjoin) val payloadValidation: Validation[Throwable, GroupCreatePayloadADM] = Validation.validateWith(id, name, descriptions, project, status, selfjoin)(GroupCreatePayloadADM) @@ -108,7 +108,7 @@ final case class GroupsRouteADM( .when(apiRequest.status.nonEmpty) name = GroupName.make(apiRequest.name) descriptions = GroupDescriptions.make(apiRequest.descriptions) - status = GroupStatus.make(apiRequest.status) + status = Validation.succeed(apiRequest.status.map(GroupStatus.make)) selfjoin = GroupSelfJoin.make(apiRequest.selfjoin) validatedPayload = Validation.validateWith(name, descriptions, status, selfjoin)(GroupUpdatePayloadADM) iri <- Iri diff --git a/webapi/src/test/scala/dsp/valueobjects/GroupSpec.scala b/webapi/src/test/scala/dsp/valueobjects/GroupSpec.scala index 699b5d0d07..2b23ec0964 100644 --- a/webapi/src/test/scala/dsp/valueobjects/GroupSpec.scala +++ b/webapi/src/test/scala/dsp/valueobjects/GroupSpec.scala @@ -91,13 +91,12 @@ object GroupSpec extends ZIOSpecDefault { ) private val groupStatusTest = suite("GroupSpec - GroupStatus")( - test("pass a valid object and successfully create value object") { - assertTrue(GroupStatus.make(true).toOption.get.value == true) && - assertTrue(GroupStatus.make(Some(false)).getOrElse(null).get.value == false) - }, - test("successfully validate passing None") { + test("creating a GroupStatus") { assertTrue( - GroupStatus.make(None) == Validation.succeed(None) + !GroupStatus.inactive.value, + GroupStatus.active.value, + GroupStatus.make(true).value, + !GroupStatus.make(false).value ) } )