From d4c227e5e31f4d74e93550637df88acc907ecf5a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 25 Jun 2024 09:50:41 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.2 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 463c08a0..7eff6346 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.7.17 +version = 3.8.2 runner.dialect = Scala213Source3 maxColumn = 100 indent.defnSite = 2 From c980f5875ba856d02ca8da6162f54f44793dcd16 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 25 Jun 2024 09:51:08 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.2 Executed command: scalafmt --non-interactive --- build.sbt | 2 +- .../director/daemon/DaemonBoot.scala | 22 +++- .../director/db/Repository.scala | 5 +- .../director/db/Schema.scala | 112 ++++++------------ .../db/deviceregistry/DeviceRepository.scala | 19 +-- .../db/deviceregistry/EventJournal.scala | 20 ++-- .../deviceregistry/GroupInfoRepository.scala | 17 +-- .../GroupMemberRepository.scala | 15 ++- .../db/deviceregistry/InstalledPackages.scala | 10 +- .../PackageListItemRepository.scala | 13 +- .../TaggedDeviceRepository.scala | 19 +-- .../deviceregistry/GroupMembership.scala | 7 +- .../daemon/DeviceUpdateEventListener.scala | 5 +- .../director/deviceregistry/data/Device.scala | 5 +- .../DeviceMonitoringResource.scala | 5 +- .../http/deviceregistry/DevicesResource.scala | 12 +- .../director/http/deviceregistry/Errors.scala | 7 +- .../http/deviceregistry/GroupsResource.scala | 6 +- .../deviceregistry/PackageListsResource.scala | 5 +- .../PublicCredentialsResource.scala | 10 +- .../deviceregistry/SystemInfoResource.scala | 5 +- .../http/deviceregistry/TomlSupport.scala | 2 + .../http/deviceregistry/Unmarshallers.scala | 2 + .../db/deviceregistry/EventJournalSpec.scala | 5 +- ...DeviceInstallationReportListenerSpec.scala | 10 +- .../data/DeviceGenerators.scala | 1 + .../data/GroupExpressionParserSpec.scala | 14 ++- .../director/http/DeviceResourceSpec.scala | 47 +++++++- .../http/OfflineUpdatesRoutesSpec.scala | 7 +- .../http/RemoteSessionsRoutesSpec.scala | 7 +- .../DeviceRegistryResourceUri.scala | 2 +- .../deviceregistry/DeviceResourceSpec.scala | 3 +- .../http/deviceregistry/GroupRequests.scala | 5 +- .../PackageListsResourceSpec.scala | 11 +- .../deviceregistry/ResourcePropSpec.scala | 1 - .../deviceregistry/SearchResourceSpec.scala | 33 ++++-- .../director/util/DirectorSpec.scala | 2 +- 37 files changed, 288 insertions(+), 185 deletions(-) diff --git a/build.sbt b/build.sbt index 8583a8ce..a3812ab1 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ libraryDependencies ++= { "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV, "com.typesafe.akka" %% "akka-stream-testkit" % akkaV, "com.typesafe.akka" %% "akka-slf4j" % akkaV, - "org.scalatest" %% "scalatest" % scalaTestV % Test, + "org.scalatest" %% "scalatest" % scalaTestV % Test, "org.scalacheck" %% "scalacheck" % "1.18.0" % Test, "io.github.uptane" %% "libats" % libatsV, "io.github.uptane" %% "libats-messaging" % libatsV, diff --git a/src/main/scala/com/advancedtelematic/director/daemon/DaemonBoot.scala b/src/main/scala/com/advancedtelematic/director/daemon/DaemonBoot.scala index 2169dc11..2ff65d86 100644 --- a/src/main/scala/com/advancedtelematic/director/daemon/DaemonBoot.scala +++ b/src/main/scala/com/advancedtelematic/director/daemon/DaemonBoot.scala @@ -7,8 +7,20 @@ import akka.http.scaladsl.server.Directives import akka.http.scaladsl.util.FastFuture import com.advancedtelematic.director.{Settings, VersionInfo} import com.advancedtelematic.libats.http.{BootApp, BootAppDatabaseConfig, BootAppDefaultConfig} -import com.advancedtelematic.libats.messaging.{BusListenerMetrics, MessageBus, MessageBusPublisher, MessageListenerSupport, MetricsBusMonitor} -import com.advancedtelematic.libats.messaging_datatype.Messages.{DeleteDeviceRequest, DeviceEventMessage, DeviceSeen, DeviceUpdateEvent, EcuReplacement} +import com.advancedtelematic.libats.messaging.{ + BusListenerMetrics, + MessageBus, + MessageBusPublisher, + MessageListenerSupport, + MetricsBusMonitor +} +import com.advancedtelematic.libats.messaging_datatype.Messages.{ + DeleteDeviceRequest, + DeviceEventMessage, + DeviceSeen, + DeviceUpdateEvent, + EcuReplacement +} import com.advancedtelematic.libats.slick.db.{BootMigrations, DatabaseSupport} import com.advancedtelematic.libats.slick.monitoring.DbHealthResource import com.advancedtelematic.libtuf_server.data.Messages.TufTargetAdded @@ -18,7 +30,11 @@ import com.typesafe.config.Config import com.advancedtelematic.libats.http.VersionDirectives.* import com.advancedtelematic.libats.messaging.metrics.MonitoredBusListenerSupport import com.advancedtelematic.metrics.prometheus.PrometheusMetricsSupport -import com.advancedtelematic.director.deviceregistry.daemon.{DeviceEventListener, DeviceUpdateEventListener, EcuReplacementListener} +import com.advancedtelematic.director.deviceregistry.daemon.{ + DeviceEventListener, + DeviceUpdateEventListener, + EcuReplacementListener +} import org.bouncycastle.jce.provider.BouncyCastleProvider import java.security.Security diff --git a/src/main/scala/com/advancedtelematic/director/db/Repository.scala b/src/main/scala/com/advancedtelematic/director/db/Repository.scala index 22b71779..6e583d82 100644 --- a/src/main/scala/com/advancedtelematic/director/db/Repository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/Repository.scala @@ -483,9 +483,8 @@ protected class AssignmentsRepository()(implicit val db: Database, val ec: Execu else DBIO .seq( - Schema.processedAssignments ++= assignments.map( - _.toProcessedAssignment(successful = true, canceled = true) - ), + Schema.processedAssignments ++= assignments + .map(_.toProcessedAssignment(successful = true, canceled = true)), assignmentQuery.delete, deviceRepository.setMetadataOutdatedAction(Set(deviceId), outdated = true) ) diff --git a/src/main/scala/com/advancedtelematic/director/db/Schema.scala b/src/main/scala/com/advancedtelematic/director/db/Schema.scala index b064e96d..89c07bbb 100644 --- a/src/main/scala/com/advancedtelematic/director/db/Schema.scala +++ b/src/main/scala/com/advancedtelematic/director/db/Schema.scala @@ -51,13 +51,10 @@ object Schema { def pk = primaryKey("devices_pk", id) - override def * = ( - namespace, - id, - primaryEcu, - generatedMetadataOutdated, - deleted - ) <> ((Device.apply _).tupled, Device.unapply) + override def * = (namespace, id, primaryEcu, generatedMetadataOutdated, deleted) <> ( + (Device.apply _).tupled, + Device.unapply + ) } @@ -77,14 +74,10 @@ object Schema { def primKey = primaryKey("ecus_pk", (deviceId, ecuSerial)) - override def * = ( - ecuSerial, - deviceId, - namespace, - hardwareId, - publicKey, - installedTarget - ) <> ((Ecu.apply _).tupled, Ecu.unapply) + override def * = (ecuSerial, deviceId, namespace, hardwareId, publicKey, installedTarget) <> ( + (Ecu.apply _).tupled, + Ecu.unapply + ) } @@ -106,16 +99,11 @@ object Schema { def primKey = primaryKey("ecu_targets_pk", id) - override def * = ( - namespace, - id, - filename, - length, - checksum, - sha256, - uri, - userDefinedCustom - ) <> ((EcuTarget.apply _).tupled, EcuTarget.unapply) + override def * = + (namespace, id, filename, length, checksum, sha256, uri, userDefinedCustom) <> ( + (EcuTarget.apply _).tupled, + EcuTarget.unapply + ) } @@ -134,16 +122,10 @@ object Schema { def primKey = primaryKey("offline_targets_pk", (repoId, name, version)) - override def * = ( - repoId, - role, - name, - checksum, - length, - version, - expires, - content - ) <> ((DbAdminRole.apply _).tupled, DbAdminRole.unapply) + override def * = (repoId, role, name, checksum, length, version, expires, content) <> ( + (DbAdminRole.apply _).tupled, + DbAdminRole.unapply + ) } @@ -161,15 +143,10 @@ object Schema { def primKey = primaryKey("device_roles_pk", (role, version, device)) - override def * = ( - role, - device, - checksum, - length, - version, - expires, - content - ) <> ((DbDeviceRole.apply _).tupled, DbDeviceRole.unapply) + override def * = (role, device, checksum, length, version, expires, content) <> ( + (DbDeviceRole.apply _).tupled, + DbDeviceRole.unapply + ) } @@ -184,15 +161,10 @@ object Schema { def createdAt = column[Instant]("created_at")(javaInstantMapping) def inFlight = column[Boolean]("in_flight") - def * = ( - namespace, - deviceId, - ecuId, - ecuTargetId, - correlationId, - inFlight, - createdAt - ) <> ((Assignment.apply _).tupled, Assignment.unapply) + def * = (namespace, deviceId, ecuId, ecuTargetId, correlationId, inFlight, createdAt) <> ( + (Assignment.apply _).tupled, + Assignment.unapply + ) def pk = primaryKey("assignments_pk", (deviceId, ecuId)) } @@ -233,13 +205,10 @@ object Schema { def toTarget = column[EcuTargetId]("to_target_id") def fromTarget = column[Option[EcuTargetId]]("from_target_id") - def * = ( - namespace, - id, - hardwareId, - fromTarget, - toTarget - ) <> ((HardwareUpdate.apply _).tupled, HardwareUpdate.unapply) + def * = (namespace, id, hardwareId, fromTarget, toTarget) <> ( + (HardwareUpdate.apply _).tupled, + HardwareUpdate.unapply + ) def pk = primaryKey("mtu_pk", (id, hardwareId)) } @@ -264,13 +233,10 @@ object Schema { def targetName = column[TargetName]("target_name") def deleted = column[Boolean]("deleted") - override def * = ( - id, - namespace, - deviceId, - ecuId, - targetName - ) <> ((AutoUpdateDefinition.apply _).tupled, AutoUpdateDefinition.unapply) + override def * = (id, namespace, deviceId, ecuId, targetName) <> ( + (AutoUpdateDefinition.apply _).tupled, + AutoUpdateDefinition.unapply + ) } @@ -305,14 +271,10 @@ object Schema { def pk = primaryKey("scheduled-updates-pk", id) - override def * = ( - namespace, - id, - deviceId, - updateId, - scheduledAt, - status - ) <> ((ScheduledUpdate.apply _).tupled, ScheduledUpdate.unapply) + override def * = (namespace, id, deviceId, updateId, scheduledAt, status) <> ( + (ScheduledUpdate.apply _).tupled, + ScheduledUpdate.unapply + ) } diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/DeviceRepository.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/DeviceRepository.scala index 32e55633..be80cd6d 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/DeviceRepository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/DeviceRepository.scala @@ -26,10 +26,7 @@ import com.advancedtelematic.director.deviceregistry.data.DeviceStatus.DeviceSta import com.advancedtelematic.director.deviceregistry.data.Group.GroupId import com.advancedtelematic.director.deviceregistry.data.GroupType.GroupType import com.advancedtelematic.director.deviceregistry.data.* -import DbOps.{ - deviceTableToSlickOrder, - PaginationResultOps -} +import DbOps.{deviceTableToSlickOrder, PaginationResultOps} import GroupInfoRepository.groupInfos import GroupMemberRepository.groupMembers import SlickMappings.* @@ -67,7 +64,9 @@ object DeviceRepository { val dbIO = devices += dbDevice dbIO .handleIntegrityErrors(Errors.ConflictingDevice(device.deviceName.some, device.deviceId.some)) - .andThen(GroupMemberRepository.addDeviceToDynamicGroups(ns, DeviceDB.toDevice(dbDevice), Map.empty)) + .andThen( + GroupMemberRepository.addDeviceToDynamicGroups(ns, DeviceDB.toDevice(dbDevice), Map.empty) + ) .map(_ => uuid) .transactionally } @@ -88,7 +87,10 @@ object DeviceRepository { .filter(d => d.namespace === ns && d.id === uuid) .result .headOption - .flatMap(_.map(DeviceDB.toDevice(_)).fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful)) + .flatMap( + _.map(DeviceDB.toDevice(_)) + .fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful) + ) def filterExisting(ns: Namespace, deviceOemIds: Set[DeviceOemId]): DBIO[Seq[DeviceId]] = devices @@ -136,7 +138,10 @@ object DeviceRepository { .filter(_.id === uuid) .result .headOption - .flatMap(_.map(DeviceDB.toDevice(_)).fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful)) + .flatMap( + _.map(DeviceDB.toDevice(_)) + .fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful) + ) def findByUuids(ns: Namespace, ids: Seq[DeviceId]): Query[DeviceTable, DeviceDB, Seq] = devices.filter(d => (d.namespace === ns) && (d.id.inSet(ids))) diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/EventJournal.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/EventJournal.scala index 63398e66..384661d3 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/EventJournal.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/EventJournal.scala @@ -77,12 +77,10 @@ object EventJournal { def pk = primaryKey("indexed_event_pk", (deviceUuid, eventId)) - def * = ( - deviceUuid, - eventId, - eventType, - correlationId - ).shaped <> (IndexedEvent.tupled, IndexedEvent.unapply) + def * = (deviceUuid, eventId, eventType, correlationId).shaped <> ( + IndexedEvent.tupled, + IndexedEvent.unapply + ) } @@ -97,12 +95,10 @@ object EventJournal { def pk = primaryKey("indexed_event_pk", (deviceUuid, eventId)) - def * = ( - deviceUuid, - eventId, - eventType, - correlationId - ).shaped <> (IndexedEvent.tupled, IndexedEvent.unapply) + def * = (deviceUuid, eventId, eventType, correlationId).shaped <> ( + IndexedEvent.tupled, + IndexedEvent.unapply + ) } diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupInfoRepository.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupInfoRepository.scala index 0854334f..9132b4ce 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupInfoRepository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupInfoRepository.scala @@ -26,10 +26,7 @@ import com.advancedtelematic.libats.slick.db.SlickUUIDKey.* import com.advancedtelematic.libats.slick.db.SlickValidatedGeneric.validatedStringMapper import com.advancedtelematic.director.deviceregistry.data import com.advancedtelematic.director.deviceregistry.data.GroupType.GroupType -import DbOps.{ - PaginationResultOps, - SortBySlickOrderedGroupConversion -} +import DbOps.{PaginationResultOps, SortBySlickOrderedGroupConversion} import SlickMappings.* import com.advancedtelematic.director.http.deviceregistry.Errors import slick.jdbc.MySQLProfile.api.* @@ -48,14 +45,10 @@ object GroupInfoRepository { def createdAt = column[Instant]("created_at")(javaInstantMapping) def updatedAt = column[Instant]("updated_at")(javaInstantMapping) - def * = ( - id, - groupName, - namespace, - createdAt, - groupType, - expression - ) <> ((Group.apply _).tupled, Group.unapply) + def * = (id, groupName, namespace, createdAt, groupType, expression) <> ( + (Group.apply _).tupled, + Group.unapply + ) } // scalastyle:on diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupMemberRepository.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupMemberRepository.scala index b036b14b..119931b4 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupMemberRepository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/GroupMemberRepository.scala @@ -17,7 +17,14 @@ import com.advancedtelematic.libats.slick.db.SlickUUIDKey.* import com.advancedtelematic.director.http.deviceregistry.Errors.MemberAlreadyExists import com.advancedtelematic.director.deviceregistry.data.DataType.HibernationStatus import com.advancedtelematic.director.deviceregistry.data.Group.GroupId -import com.advancedtelematic.director.deviceregistry.data.{Device, DeviceDB, GroupExpression, GroupExpressionAST, GroupType, TagId} +import com.advancedtelematic.director.deviceregistry.data.{ + Device, + DeviceDB, + GroupExpression, + GroupExpressionAST, + GroupType, + TagId +} import DbOps.PaginationResultOps import com.advancedtelematic.director.http.deviceregistry.Errors import slick.jdbc.{PositionedParameters, SetParameter} @@ -152,7 +159,11 @@ object GroupMemberRepository { _ <- GroupInfoRepository.updateSmartGroupExpression(groupId, newExpression) _ <- groupMembers.filter(_.groupId === groupId).delete devs <- Schema.devices.filter(_.namespace === namespace).result - _ <- DBIO.sequence(devs.map(DeviceDB.toDevice(_)).map(GroupMemberRepository.addDeviceToDynamicGroups(namespace, _))) + _ <- DBIO.sequence( + devs + .map(DeviceDB.toDevice(_)) + .map(GroupMemberRepository.addDeviceToDynamicGroups(namespace, _)) + ) } yield () } diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/InstalledPackages.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/InstalledPackages.scala index 9d697805..9e3cb4cd 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/InstalledPackages.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/InstalledPackages.scala @@ -33,9 +33,8 @@ object InstalledPackages { object InstalledPackage { import com.advancedtelematic.libats.codecs.CirceCodecs._ - implicit val EncoderInstance: io.circe.Encoder.AsObject[ - InstalledPackages.InstalledPackage - ] = io.circe.generic.semiauto.deriveEncoder[InstalledPackage] + implicit val EncoderInstance: io.circe.Encoder.AsObject[InstalledPackages.InstalledPackage] = + io.circe.generic.semiauto.deriveEncoder[InstalledPackage] } @@ -43,9 +42,8 @@ object InstalledPackages { object DevicesCount { - implicit val EncoderInstance: io.circe.Encoder.AsObject[ - InstalledPackages.DevicesCount - ] = io.circe.generic.semiauto.deriveEncoder[DevicesCount] + implicit val EncoderInstance: io.circe.Encoder.AsObject[InstalledPackages.DevicesCount] = + io.circe.generic.semiauto.deriveEncoder[DevicesCount] } diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/PackageListItemRepository.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/PackageListItemRepository.scala index 81d370f9..80bd9f4f 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/PackageListItemRepository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/PackageListItemRepository.scala @@ -31,11 +31,14 @@ object PackageListItemRepository { def comment = column[String]("comment") def * = (namespace, packageName, packageVersion, comment) <> - ({ case (ns, pkgName, pkgVersion, comment) => - PackageListItem(ns, PackageId(pkgName, pkgVersion), comment) - }, { (bp: PackageListItem) => - Some(bp.namespace, bp.packageId.name, bp.packageId.version, bp.comment) - }) + ( + { case (ns, pkgName, pkgVersion, comment) => + PackageListItem(ns, PackageId(pkgName, pkgVersion), comment) + }, + { (bp: PackageListItem) => + Some(bp.namespace, bp.packageId.name, bp.packageId.version, bp.comment) + } + ) def pk = primaryKey("pk_PackageListItem", (namespace, packageName, packageVersion)) } diff --git a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/TaggedDeviceRepository.scala b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/TaggedDeviceRepository.scala index f14a36a0..eaae2dd6 100644 --- a/src/main/scala/com/advancedtelematic/director/db/deviceregistry/TaggedDeviceRepository.scala +++ b/src/main/scala/com/advancedtelematic/director/db/deviceregistry/TaggedDeviceRepository.scala @@ -1,7 +1,10 @@ package com.advancedtelematic.director.db.deviceregistry import com.advancedtelematic.director.db.deviceregistry.DeviceRepository.findByDeviceIdQuery -import com.advancedtelematic.director.db.deviceregistry.GroupMemberRepository.{addDeviceToDynamicGroups, deleteDynamicGroupsForDevice} +import com.advancedtelematic.director.db.deviceregistry.GroupMemberRepository.{ + addDeviceToDynamicGroups, + deleteDynamicGroupsForDevice +} import com.advancedtelematic.director.deviceregistry.data.DataType.{TagInfo, TaggedDevice} import com.advancedtelematic.director.deviceregistry.data.Device.DeviceOemId import com.advancedtelematic.director.deviceregistry.data.{Device, DeviceDB, TagId} @@ -24,12 +27,10 @@ object TaggedDeviceRepository { def tagId = column[TagId]("tag_id")(validatedStringMapper) def tagValue = column[String]("tag_value") - def * = ( - namespace, - deviceUuid, - tagId, - tagValue - ).shaped <> ((TaggedDevice.apply _).tupled, TaggedDevice.unapply) + def * = (namespace, deviceUuid, tagId, tagValue).shaped <> ( + (TaggedDevice.apply _).tupled, + TaggedDevice.unapply + ) def pk = primaryKey("tagged_device_pk", (deviceUuid, tagId)) } @@ -59,7 +60,7 @@ object TaggedDeviceRepository { def fetchForDevices(deviceUuids: Seq[DeviceId]): DBIO[Seq[(DeviceId, (TagId, String))]] = taggedDevices - .filter(_.deviceUuid inSet deviceUuids) + .filter(_.deviceUuid.inSet(deviceUuids)) .map(td => td.deviceUuid -> (td.tagId -> td.tagValue)) .result @@ -110,7 +111,7 @@ object TaggedDeviceRepository { val action = for { d <- DeviceRepository.exists(namespace, deviceId) currentTags <- fetchForDevice(deviceId).map(_.toMap) - newTags = currentTags + (tagId -> tagValue) + newTags = currentTags + (tagId -> tagValue) _ <- refreshDeviceTags(namespace, d, newTags) } yield () action.transactionally diff --git a/src/main/scala/com/advancedtelematic/director/deviceregistry/GroupMembership.scala b/src/main/scala/com/advancedtelematic/director/deviceregistry/GroupMembership.scala index 1a70e307..baf6425c 100644 --- a/src/main/scala/com/advancedtelematic/director/deviceregistry/GroupMembership.scala +++ b/src/main/scala/com/advancedtelematic/director/deviceregistry/GroupMembership.scala @@ -1,7 +1,12 @@ package com.advancedtelematic.director.deviceregistry import akka.http.scaladsl.util.FastFuture -import com.advancedtelematic.director.db.deviceregistry.{DeviceRepository, GroupInfoRepository, GroupMemberRepository, SearchDBIO} +import com.advancedtelematic.director.db.deviceregistry.{ + DeviceRepository, + GroupInfoRepository, + GroupMemberRepository, + SearchDBIO +} import com.advancedtelematic.libats.data.DataType.Namespace import com.advancedtelematic.libats.data.PaginationResult import com.advancedtelematic.director.deviceregistry.data.Group.GroupId diff --git a/src/main/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceUpdateEventListener.scala b/src/main/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceUpdateEventListener.scala index c6d50a1a..3698f525 100644 --- a/src/main/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceUpdateEventListener.scala +++ b/src/main/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceUpdateEventListener.scala @@ -2,7 +2,10 @@ package com.advancedtelematic.director.deviceregistry.daemon import java.time.Instant import akka.http.scaladsl.util.FastFuture -import com.advancedtelematic.director.db.deviceregistry.{DeviceRepository, InstallationReportRepository} +import com.advancedtelematic.director.db.deviceregistry.{ + DeviceRepository, + InstallationReportRepository +} import com.advancedtelematic.libats.data.DataType.{CorrelationId, Namespace} import com.advancedtelematic.libats.messaging.MessageBusPublisher import com.advancedtelematic.libats.messaging.MsgOperation.MsgOperation diff --git a/src/main/scala/com/advancedtelematic/director/deviceregistry/data/Device.scala b/src/main/scala/com/advancedtelematic/director/deviceregistry/data/Device.scala index a57d65d6..2ff0d1bd 100644 --- a/src/main/scala/com/advancedtelematic/director/deviceregistry/data/Device.scala +++ b/src/main/scala/com/advancedtelematic/director/deviceregistry/data/Device.scala @@ -31,6 +31,7 @@ final case class DeviceDB(namespace: Namespace, hibernated: Boolean = false) object DeviceDB { + def toDevice(dbDevice: DeviceDB, attributes: Map[TagId, String] = Map.empty): Device = Device( namespace = dbDevice.namespace, @@ -44,7 +45,9 @@ object DeviceDB { deviceStatus = dbDevice.deviceStatus, notes = dbDevice.notes, hibernated = dbDevice.hibernated, - attributes = attributes) + attributes = attributes + ) + } final case class Device(namespace: Namespace, diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DeviceMonitoringResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DeviceMonitoringResource.scala index f8922c1f..9654cf7d 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DeviceMonitoringResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DeviceMonitoringResource.scala @@ -8,7 +8,10 @@ import com.advancedtelematic.director.deviceregistry.data.DataType.ObservationPu import com.advancedtelematic.libats.data.DataType.Namespace import com.advancedtelematic.libats.messaging.MessageBusPublisher import com.advancedtelematic.libats.messaging_datatype.DataType -import com.advancedtelematic.libats.messaging_datatype.Messages.{DeviceMetricsObservation, deviceMetricsObservationMessageLike} +import com.advancedtelematic.libats.messaging_datatype.Messages.{ + deviceMetricsObservationMessageLike, + DeviceMetricsObservation +} import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport.* import io.circe.{Decoder, Json} import org.slf4j.LoggerFactory diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DevicesResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DevicesResource.scala index 97a889af..b67e0ea3 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DevicesResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/DevicesResource.scala @@ -220,20 +220,16 @@ class DevicesResource(namespaceExtractor: Directive1[Namespace], limit ) ) { params => - complete( - for { + complete(for { pr <- db.run(SearchDBIO.search(ns, params)) taggedDevicesMap <- db.run( TaggedDeviceRepository.fetchForDevices(pr.values.map(_.uuid)).map { deviceTags => deviceTags.groupBy(_._1).map { case (k, v) => (k, v.map(_._2)) } } ) - } yield pr.copy( - values = pr.values.map { device => - DeviceDB.toDevice(device, taggedDevicesMap.getOrElse(device.uuid, Seq.empty).toMap) - } - ) - ) + } yield pr.copy(values = pr.values.map { device => + DeviceDB.toDevice(device, taggedDevicesMap.getOrElse(device.uuid, Seq.empty).toMap) + })) } diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Errors.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Errors.scala index f8fd89a9..0da176d7 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Errors.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Errors.scala @@ -14,7 +14,12 @@ import com.advancedtelematic.director.db.deviceregistry.SystemInfoRepository.Sys import com.advancedtelematic.director.deviceregistry.data.DataType.PackageListItem import com.advancedtelematic.director.deviceregistry.data.Device.DeviceOemId import com.advancedtelematic.director.deviceregistry.data.GroupType.GroupType -import com.advancedtelematic.director.deviceregistry.data.{DeviceName, Group, GroupExpression, GroupName} +import com.advancedtelematic.director.deviceregistry.data.{ + DeviceName, + Group, + GroupExpression, + GroupName +} import com.advancedtelematic.libats.data.ErrorCode import com.advancedtelematic.libats.http.Errors.{EntityAlreadyExists, MissingEntity, RawError} diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/GroupsResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/GroupsResource.scala index 740d32f5..5680e248 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/GroupsResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/GroupsResource.scala @@ -18,7 +18,11 @@ import akka.stream.scaladsl.Framing.FramingException import akka.stream.scaladsl.{Framing, Sink, Source} import akka.util.ByteString import cats.syntax.either.* -import com.advancedtelematic.director.db.deviceregistry.{DeviceRepository, GroupInfoRepository, GroupMemberRepository} +import com.advancedtelematic.director.db.deviceregistry.{ + DeviceRepository, + GroupInfoRepository, + GroupMemberRepository +} import com.advancedtelematic.director.deviceregistry.data.* import com.advancedtelematic.director.deviceregistry.data.Codecs.* import com.advancedtelematic.director.deviceregistry.data.DataType.UpdateHibernationStatusRequest diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResource.scala index 2aadfaf0..dae94e45 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResource.scala @@ -5,7 +5,10 @@ import akka.http.scaladsl.server.* import akka.http.scaladsl.server.Directives.* import com.advancedtelematic.director.db.deviceregistry.PackageListItemRepository import com.advancedtelematic.director.deviceregistry.data.Codecs.* -import com.advancedtelematic.director.deviceregistry.data.DataType.{PackageListItem, PackageListItemCount} +import com.advancedtelematic.director.deviceregistry.data.DataType.{ + PackageListItem, + PackageListItemCount +} import com.advancedtelematic.director.deviceregistry.data.PackageId import com.advancedtelematic.libats.data.DataType.Namespace import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport.* diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PublicCredentialsResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PublicCredentialsResource.scala index a5f4c650..a2e352be 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PublicCredentialsResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/PublicCredentialsResource.scala @@ -12,12 +12,18 @@ import akka.http.scaladsl.marshalling.Marshaller.* import akka.http.scaladsl.server.Directives.* import akka.http.scaladsl.server.{Directive1, Route} import akka.http.scaladsl.util.FastFuture -import com.advancedtelematic.director.db.deviceregistry.{DeviceRepository, PublicCredentialsRepository} +import com.advancedtelematic.director.db.deviceregistry.{ + DeviceRepository, + PublicCredentialsRepository +} import com.advancedtelematic.director.deviceregistry.data.Codecs.* import com.advancedtelematic.director.deviceregistry.data.CredentialsType import com.advancedtelematic.director.deviceregistry.data.CredentialsType.CredentialsType import com.advancedtelematic.director.deviceregistry.data.DataType.DeviceT -import com.advancedtelematic.director.deviceregistry.messages.{DeviceCreated, DevicePublicCredentialsSet} +import com.advancedtelematic.director.deviceregistry.messages.{ + DeviceCreated, + DevicePublicCredentialsSet +} import com.advancedtelematic.libats.data.DataType.Namespace import com.advancedtelematic.libats.messaging.MessageBusPublisher import com.advancedtelematic.libats.messaging_datatype.DataType.DeviceId diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/SystemInfoResource.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/SystemInfoResource.scala index e50d6c2f..cfc5dace 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/SystemInfoResource.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/SystemInfoResource.scala @@ -24,7 +24,10 @@ import com.advancedtelematic.libats.http.Errors.RawError import com.advancedtelematic.libats.http.UUIDKeyAkka.* import com.advancedtelematic.libats.messaging.MessageBusPublisher import com.advancedtelematic.libats.messaging_datatype.DataType.DeviceId -import com.advancedtelematic.libats.messaging_datatype.Messages.{AktualizrConfigChanged, DeviceSystemInfoChanged} +import com.advancedtelematic.libats.messaging_datatype.Messages.{ + AktualizrConfigChanged, + DeviceSystemInfoChanged +} import io.circe.Json import io.circe.generic.auto.* import slick.jdbc.MySQLProfile.api.* diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/TomlSupport.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/TomlSupport.scala index 21f96c0c..58f49107 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/TomlSupport.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/TomlSupport.scala @@ -5,6 +5,8 @@ import akka.http.scaladsl.model.HttpCharsets.`UTF-8` import akka.http.scaladsl.model.MediaType object TomlSupport { + val `application/toml`: WithFixedCharset = MediaType.applicationWithFixedCharset("toml", `UTF-8`).toContentType + } diff --git a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Unmarshallers.scala b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Unmarshallers.scala index aff9c8f0..abc031df 100644 --- a/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Unmarshallers.scala +++ b/src/main/scala/com/advancedtelematic/director/http/deviceregistry/Unmarshallers.scala @@ -4,10 +4,12 @@ import akka.http.scaladsl.unmarshalling.{PredefinedFromStringUnmarshallers, Unma import akka.http.scaladsl.util.FastFuture object Unmarshallers { + val nonNegativeLong: Unmarshaller[String, Long] = PredefinedFromStringUnmarshallers.longFromStringUnmarshaller .flatMap { _ => _ => value => if (value < 0) FastFuture.failed(new IllegalArgumentException("Value cannot be negative")) else FastFuture.successful(value) } + } diff --git a/src/test/scala/com/advancedtelematic/director/db/deviceregistry/EventJournalSpec.scala b/src/test/scala/com/advancedtelematic/director/db/deviceregistry/EventJournalSpec.scala index 14f39073..6cd350f1 100644 --- a/src/test/scala/com/advancedtelematic/director/db/deviceregistry/EventJournalSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/db/deviceregistry/EventJournalSpec.scala @@ -17,7 +17,10 @@ import com.advancedtelematic.libats.codecs.CirceCodecs.* import com.advancedtelematic.libats.data.DataType.{CampaignId, CorrelationId, MultiTargetUpdateId} import com.advancedtelematic.libats.messaging_datatype.DataType.{Event, EventType} import com.advancedtelematic.libats.messaging_datatype.MessageCodecs.* -import com.advancedtelematic.libats.messaging_datatype.Messages.{DeleteDeviceRequest, DeviceEventMessage} +import com.advancedtelematic.libats.messaging_datatype.Messages.{ + DeleteDeviceRequest, + DeviceEventMessage +} import EventJournalSpec.EventPayload import com.advancedtelematic.director.deviceregistry.daemon.DeviceEventListener import com.advancedtelematic.director.deviceregistry.data.DataType.DeviceT diff --git a/src/test/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceInstallationReportListenerSpec.scala b/src/test/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceInstallationReportListenerSpec.scala index 9ab40a88..8674b59a 100644 --- a/src/test/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceInstallationReportListenerSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/deviceregistry/daemon/DeviceInstallationReportListenerSpec.scala @@ -1,9 +1,15 @@ package com.advancedtelematic.director.deviceregistry.daemon import com.advancedtelematic.director.db.deviceregistry.InstallationReportRepository -import com.advancedtelematic.director.deviceregistry.data.DataType.{DeviceInstallationResult, EcuInstallationResult} +import com.advancedtelematic.director.deviceregistry.data.DataType.{ + DeviceInstallationResult, + EcuInstallationResult +} import com.advancedtelematic.director.deviceregistry.data.GeneratorOps.* -import com.advancedtelematic.director.deviceregistry.data.{DeviceStatus, InstallationReportGenerators} +import com.advancedtelematic.director.deviceregistry.data.{ + DeviceStatus, + InstallationReportGenerators +} import com.advancedtelematic.director.http.LogDeviceSeen import com.advancedtelematic.director.http.deviceregistry.{DeviceRequests, ResourcePropSpec} import com.advancedtelematic.director.util.DirectorSpec diff --git a/src/test/scala/com/advancedtelematic/director/deviceregistry/data/DeviceGenerators.scala b/src/test/scala/com/advancedtelematic/director/deviceregistry/data/DeviceGenerators.scala index c410622e..4d542c82 100644 --- a/src/test/scala/com/advancedtelematic/director/deviceregistry/data/DeviceGenerators.scala +++ b/src/test/scala/com/advancedtelematic/director/deviceregistry/data/DeviceGenerators.scala @@ -86,6 +86,7 @@ object DeviceGenerators { } object InvalidDeviceGenerators { + import DeviceGenerators.* import DeviceIdGenerators.* diff --git a/src/test/scala/com/advancedtelematic/director/deviceregistry/data/GroupExpressionParserSpec.scala b/src/test/scala/com/advancedtelematic/director/deviceregistry/data/GroupExpressionParserSpec.scala index ae92139c..e4c96324 100644 --- a/src/test/scala/com/advancedtelematic/director/deviceregistry/data/GroupExpressionParserSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/deviceregistry/data/GroupExpressionParserSpec.scala @@ -387,9 +387,10 @@ class GroupExpressionRunSpec extends DirectorSpec with BeforeAndAfterAll with My } test("returns matching 'deviceid position is not'") { - runGroupExpression( - s"deviceid position(1) is not x" - ) should contain only (device0.uuid.get, device1.uuid.get) + runGroupExpression(s"deviceid position(1) is not x") should contain only ( + device0.uuid.get, + device1.uuid.get + ) runGroupExpression(s"deviceid position(8) is not B") should contain only device1.uuid.get } @@ -406,9 +407,10 @@ class GroupExpressionRunSpec extends DirectorSpec with BeforeAndAfterAll with My } test("returns matching 'deviceid position is' is case-insensitive") { - runGroupExpression( - s"deviceid position(1) is D" - ) should contain only (device0.uuid.get, device1.uuid.get) + runGroupExpression(s"deviceid position(1) is D") should contain only ( + device0.uuid.get, + device1.uuid.get + ) runGroupExpression(s"deviceid position(8) is b") should contain only device0.uuid.get } diff --git a/src/test/scala/com/advancedtelematic/director/http/DeviceResourceSpec.scala b/src/test/scala/com/advancedtelematic/director/http/DeviceResourceSpec.scala index fd2c1dc6..dc09c38d 100644 --- a/src/test/scala/com/advancedtelematic/director/http/DeviceResourceSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/DeviceResourceSpec.scala @@ -5,25 +5,60 @@ import cats.syntax.option.* import cats.syntax.show.* import com.advancedtelematic.director.daemon.UpdateSchedulerDaemon import com.advancedtelematic.director.data.AdminDataType -import com.advancedtelematic.director.data.AdminDataType.{EcuInfoResponse, MultiTargetUpdate, QueueResponse, RegisterDevice, TargetUpdate} +import com.advancedtelematic.director.data.AdminDataType.{ + EcuInfoResponse, + MultiTargetUpdate, + QueueResponse, + RegisterDevice, + TargetUpdate +} import com.advancedtelematic.director.data.Codecs.* import com.advancedtelematic.director.data.DataType.* -import com.advancedtelematic.director.data.DeviceRequest.{DeviceManifest, EcuManifest, EcuManifestCustom, InstallationReport, InstallationReportEntity, MissingInstallationReport, OperationResult} +import com.advancedtelematic.director.data.DeviceRequest.{ + DeviceManifest, + EcuManifest, + EcuManifestCustom, + InstallationReport, + InstallationReportEntity, + MissingInstallationReport, + OperationResult +} import com.advancedtelematic.director.data.GeneratorOps.* import com.advancedtelematic.director.data.Generators.* import com.advancedtelematic.director.data.Messages.DeviceManifestReported import com.advancedtelematic.director.data.UptaneDataType.{FileInfo, Hashes, Image} -import com.advancedtelematic.director.db.{AssignmentsRepositorySupport, EcuRepositorySupport, UpdateSchedulerDBIO} +import com.advancedtelematic.director.db.{ + AssignmentsRepositorySupport, + EcuRepositorySupport, + UpdateSchedulerDBIO +} import com.advancedtelematic.director.manifest.ResultCodes import com.advancedtelematic.director.util.* -import com.advancedtelematic.libats.data.DataType.{CorrelationId, HashMethod, MultiTargetUpdateId, Namespace, ResultCode, ResultDescription} +import com.advancedtelematic.libats.data.DataType.{ + CorrelationId, + HashMethod, + MultiTargetUpdateId, + Namespace, + ResultCode, + ResultDescription +} import com.advancedtelematic.libats.data.ErrorRepresentation import com.advancedtelematic.libats.messaging.test.MockMessageBus import com.advancedtelematic.libats.messaging_datatype.DataType.{DeviceId, InstallationResult} import com.advancedtelematic.libats.messaging_datatype.DataType.DeviceId.* -import com.advancedtelematic.libats.messaging_datatype.Messages.{DeviceSeen, DeviceUpdateCompleted, *} +import com.advancedtelematic.libats.messaging_datatype.Messages.{ + DeviceSeen, + DeviceUpdateCompleted, + * +} import com.advancedtelematic.libtuf.data.ClientCodecs.* -import com.advancedtelematic.libtuf.data.ClientDataType.{RootRole, SnapshotRole, TargetsRole, TimestampRole, TufRole} +import com.advancedtelematic.libtuf.data.ClientDataType.{ + RootRole, + SnapshotRole, + TargetsRole, + TimestampRole, + TufRole +} import com.advancedtelematic.libtuf.data.TufCodecs.* import com.advancedtelematic.libtuf.data.TufDataType.SignedPayload import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport.* diff --git a/src/test/scala/com/advancedtelematic/director/http/OfflineUpdatesRoutesSpec.scala b/src/test/scala/com/advancedtelematic/director/http/OfflineUpdatesRoutesSpec.scala index f635e579..a9536dd5 100644 --- a/src/test/scala/com/advancedtelematic/director/http/OfflineUpdatesRoutesSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/OfflineUpdatesRoutesSpec.scala @@ -12,7 +12,12 @@ import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport.* import com.advancedtelematic.director.data.GeneratorOps.* import com.advancedtelematic.libats.data.DataType.Namespace import com.advancedtelematic.libats.data.ErrorRepresentation -import com.advancedtelematic.libtuf.data.ClientDataType.{OfflineSnapshotRole, OfflineUpdatesRole, TufRole, ValidMetaPath} +import com.advancedtelematic.libtuf.data.ClientDataType.{ + OfflineSnapshotRole, + OfflineUpdatesRole, + TufRole, + ValidMetaPath +} import com.advancedtelematic.libtuf.data.TufDataType.SignedPayload import com.advancedtelematic.libtuf_server.crypto.Sha256Digest import eu.timepit.refined.api.Refined diff --git a/src/test/scala/com/advancedtelematic/director/http/RemoteSessionsRoutesSpec.scala b/src/test/scala/com/advancedtelematic/director/http/RemoteSessionsRoutesSpec.scala index 229a7545..e9ba432f 100644 --- a/src/test/scala/com/advancedtelematic/director/http/RemoteSessionsRoutesSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/RemoteSessionsRoutesSpec.scala @@ -10,7 +10,12 @@ import com.advancedtelematic.libats.data.ErrorRepresentation import com.advancedtelematic.libats.messaging_datatype.DataType.DeviceId import com.advancedtelematic.libtuf.crypt.TufCrypto import com.advancedtelematic.libtuf.data.ClientCodecs.* -import com.advancedtelematic.libtuf.data.ClientDataType.{RemoteSessionsPayload, RemoteSessionsRole, RootRole, SshSessionProperties} +import com.advancedtelematic.libtuf.data.ClientDataType.{ + RemoteSessionsPayload, + RemoteSessionsRole, + RootRole, + SshSessionProperties +} import com.advancedtelematic.libtuf.data.TufCodecs.* import com.advancedtelematic.libtuf.data.TufDataType.{RoleType, SignedPayload} import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport.* diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceRegistryResourceUri.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceRegistryResourceUri.scala index ec26c0ff..bd3efd5c 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceRegistryResourceUri.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceRegistryResourceUri.scala @@ -15,4 +15,4 @@ object DeviceRegistryResourceUri { Uri.Empty.withPath(pathSuffixes.foldLeft(BasePath)(_ / _)) } -} \ No newline at end of file +} diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceResourceSpec.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceResourceSpec.scala index 11cb1f4e..2d1214ed 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceResourceSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/DeviceResourceSpec.scala @@ -78,7 +78,8 @@ class DeviceResourceSpec private def logDeviceSeen(uuid: DeviceId, lastSeen: Instant = Instant.now(), namespace: Namespace = defaultNs): Unit = - LogDeviceSeen.logDevice(namespace, uuid, lastSeen) + LogDeviceSeen + .logDevice(namespace, uuid, lastSeen) .recover { case Errors.MissingDevice => println("could not log device seen, missing device") } diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/GroupRequests.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/GroupRequests.scala index be1f42d8..ee03ee37 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/GroupRequests.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/GroupRequests.scala @@ -99,7 +99,10 @@ trait GroupRequests { Map("filename" -> "vins.csv") ) ) - Post(DeviceRegistryResourceUri.uri(groupsApi).withQuery(Query("groupName" -> groupName.value)), multipartForm) + Post( + DeviceRegistryResourceUri.uri(groupsApi).withQuery(Query("groupName" -> groupName.value)), + multipartForm + ) } def createStaticGroupOk(name: GroupName = genGroupName().sample.get): GroupId = diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResourceSpec.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResourceSpec.scala index 1da4621a..73cc5328 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResourceSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/PackageListsResourceSpec.scala @@ -3,8 +3,15 @@ package com.advancedtelematic.director.http.deviceregistry import akka.http.scaladsl.model.HttpRequest import akka.http.scaladsl.model.StatusCodes.{Created, NoContent, NotFound, OK} import cats.syntax.show.* -import com.advancedtelematic.director.deviceregistry.data.Codecs.{packageListItemCodec, packageListItemCountCodec} -import com.advancedtelematic.director.deviceregistry.data.DataType.{DeviceT, PackageListItem, PackageListItemCount} +import com.advancedtelematic.director.deviceregistry.data.Codecs.{ + packageListItemCodec, + packageListItemCountCodec +} +import com.advancedtelematic.director.deviceregistry.data.DataType.{ + DeviceT, + PackageListItem, + PackageListItemCount +} import com.advancedtelematic.director.deviceregistry.data.GeneratorOps.* import com.advancedtelematic.director.deviceregistry.data.PackageId import com.advancedtelematic.director.http.deviceregistry.DeviceRegistryResourceUri.uri diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/ResourcePropSpec.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/ResourcePropSpec.scala index 1aef8d0c..3231984e 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/ResourcePropSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/ResourcePropSpec.scala @@ -23,4 +23,3 @@ trait ResourcePropSpec PropertyCheckConfiguration(minSuccessful = 1, minSize = 3) } - diff --git a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/SearchResourceSpec.scala b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/SearchResourceSpec.scala index 392ff2c5..58615bfd 100644 --- a/src/test/scala/com/advancedtelematic/director/http/deviceregistry/SearchResourceSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/http/deviceregistry/SearchResourceSpec.scala @@ -50,7 +50,10 @@ trait SearchRequests { ) } - def searchDevice(regex: String, offset: Long = 0, limit: Long = 50, ns: Namespace = defaultNs): HttpRequest = + def searchDevice(regex: String, + offset: Long = 0, + limit: Long = 50, + ns: Namespace = defaultNs): HttpRequest = Get( DeviceRegistryResourceUri .uri(api) @@ -241,15 +244,23 @@ class SearchResourceSpec val csvRows = Seq( Seq(first.deviceId.underlying, "Germany", "Premium"), - Seq(second.deviceId.underlying, "China", "Deluxe"), + Seq(second.deviceId.underlying, "China", "Deluxe") ) postDeviceTags(csvRows, ns = ns) ~> routes ~> check { status shouldBe NoContent - db.run(TaggedDeviceRepository.fetchForDevice(firstId)).futureValue - .map { case (k, v) => k.value -> v } should contain only("market" -> "Germany", "trim" -> "Premium") - db.run(TaggedDeviceRepository.fetchForDevice(secondId)).futureValue - .map { case (k, v) => k.value -> v } should contain only("market" -> "China", "trim" -> "Deluxe") + db.run(TaggedDeviceRepository.fetchForDevice(firstId)) + .futureValue + .map { case (k, v) => k.value -> v } should contain only ( + "market" -> "Germany", + "trim" -> "Premium" + ) + db.run(TaggedDeviceRepository.fetchForDevice(secondId)) + .futureValue + .map { case (k, v) => k.value -> v } should contain only ( + "market" -> "China", + "trim" -> "Deluxe" + ) db.run(TaggedDeviceRepository.fetchForDevice(thirdId)).futureValue shouldBe empty } @@ -260,10 +271,16 @@ class SearchResourceSpec result.values.length shouldBe 3 val firstIndex = result.values.indexWhere(_.uuid == firstId) - result.values(firstIndex).attributes shouldEqual Map(TagId("market") -> "Germany", TagId("trim") -> "Premium") + result.values(firstIndex).attributes shouldEqual Map( + TagId("market") -> "Germany", + TagId("trim") -> "Premium" + ) val secondIndex = result.values.indexWhere(_.uuid == secondId) - result.values(secondIndex).attributes shouldEqual Map(TagId("market") -> "China", TagId("trim") -> "Deluxe") + result.values(secondIndex).attributes shouldEqual Map( + TagId("market") -> "China", + TagId("trim") -> "Deluxe" + ) val thirdIndex = result.values.indexWhere(_.uuid == thirdId) result.values(thirdIndex).attributes shouldBe empty diff --git a/src/test/scala/com/advancedtelematic/director/util/DirectorSpec.scala b/src/test/scala/com/advancedtelematic/director/util/DirectorSpec.scala index 789a7bd2..5ec43732 100644 --- a/src/test/scala/com/advancedtelematic/director/util/DirectorSpec.scala +++ b/src/test/scala/com/advancedtelematic/director/util/DirectorSpec.scala @@ -45,7 +45,7 @@ abstract class DirectorSpec def testWithNamespace(testName: String, testArgs: Tag*)(testFun: Namespace => Any)( implicit pos: Position): Unit = - test(testName, testArgs *)(withRandomNamespace(testFun))(pos = pos) + test(testName, testArgs*)(withRandomNamespace(testFun))(pos = pos) } From 41dbb102ccf528b1492a2225c04eccebeeaf5d6a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 25 Jun 2024 09:51:08 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.2' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 8e0df941..0fbaab8e 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,4 +1,6 @@ # more scalafmt 038c8c5a2b9dc039b97c3c8e34337c165da0052b # initial scalafmt -4e224a6ff898ddf989d9a69b95ea6349f605ec90 \ No newline at end of file +4e224a6ff898ddf989d9a69b95ea6349f605ec90 +# Scala Steward: Reformat with scalafmt 3.8.2 +c980f5875ba856d02ca8da6162f54f44793dcd16