Skip to content

Commit

Permalink
Scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyhappydan committed Jan 17, 2024
1 parent c987e9a commit 7ecbd2e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ import scala.jdk.CollectionConverters._

class HandlebarsExpander {

private val handleBars = new Handlebars().`with`(EscapingStrategy.NOOP).registerHelper("empty", new Helper[Iterable[_]] {
override def apply(context: Iterable[_], options: Options): CharSequence = {
context.iterator.isEmpty match {
case true => options.fn()
case false => options.inverse()
private val handleBars = new Handlebars()
.`with`(EscapingStrategy.NOOP)
.registerHelper(
"empty",
new Helper[Iterable[_]] {
override def apply(context: Iterable[_], options: Options): CharSequence = {
context.iterator.isEmpty match {
case true => options.fn()
case false => options.inverse()
}
}
}
}
})
)

def expand(templateText: String,attributes: Map[String, Any]) = {
def expand(templateText: String, attributes: Map[String, Any]) = {
if (attributes.isEmpty) {
templateText
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit

test("successfully perform disk copy") {
val events = ListBuffer.empty[Event]
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val (user, aclCheck) = userAuthorizedOnProjectStorage(sourceStorage.value)

val batchCopy = mkBatchCopy(
Expand Down Expand Up @@ -74,7 +75,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit

test("successfully perform remote disk copy") {
val events = ListBuffer.empty[Event]
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, remoteVal, Some(stubbedFileMetadata))
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, remoteVal, Some(stubbedFileMetadata))
val (user, aclCheck) = userAuthorizedOnProjectStorage(sourceStorage.value)

val batchCopy = mkBatchCopy(
Expand Down Expand Up @@ -110,7 +112,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit

test("fail if a source storage is different to destination storage") {
val events = ListBuffer.empty[Event]
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val (user, aclCheck) = userAuthorizedOnProjectStorage(sourceStorage.value)

val batchCopy = mkBatchCopy(
Expand All @@ -129,7 +132,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit

test("fail if user does not have read access on a source file's storage") {
val events = ListBuffer.empty[Event]
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata))
val user = genUser()
val aclCheck = AclSimpleCheck((user, AclAddress.fromProject(sourceProj.ref), Set())).accepted

Expand All @@ -148,7 +152,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit

test("fail if a single source file exceeds max size for destination storage") {
val events = ListBuffer.empty[Event]
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata), 1000L)
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata), 1000L)
val (user, aclCheck) = userAuthorizedOnProjectStorage(sourceStorage.value)

val batchCopy = mkBatchCopy(
Expand All @@ -172,7 +177,8 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit
val capacity = 10L
val statEntry = StorageStatEntry(files = 10L, spaceUsed = 1L)
val spaceLeft = capacity - statEntry.spaceUsed
val (sourceFileRes, sourceStorage) = genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata), fileSize)
val (sourceFileRes, sourceStorage) =
genFileResourceAndStorage(sourceFileId, sourceProj.context, diskVal, Some(stubbedFileMetadata), fileSize)
val (user, aclCheck) = userAuthorizedOnProjectStorage(sourceStorage.value)

val batchCopy = mkBatchCopy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import ch.epfl.bluebrain.nexus.delta.kernel.http.MediaTypeDetectorConfig
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ResourcesSearchParams.FileUserMetadata
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.Digest.ComputedDigest
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.{FileAttributes, FileId, FileRejection}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.{FileFixtures, Files, FilesConfig, permissions, contexts => fileContexts}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.{contexts => fileContexts, permissions, FileFixtures, Files, FilesConfig}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{StorageRejection, StorageStatEntry, StorageType}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.remote.client.RemoteDiskStorageClient
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.{StorageFixtures, Storages, StoragesConfig, StoragesStatistics, contexts => storageContexts, permissions => storagesPermissions}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.{contexts => storageContexts, permissions => storagesPermissions, StorageFixtures, Storages, StoragesConfig, StoragesStatistics}
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.RdfMediaTypes.`application/ld+json`
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary
Expand Down Expand Up @@ -681,15 +681,17 @@ object FilesRoutesSpec extends CirceLiteral {
createdBy: Subject,
updatedBy: Subject
)(implicit baseUri: BaseUri): Json = {
val self = ResourceUris("files", project, id).accessUri
val self = ResourceUris("files", project, id).accessUri
val keywordsJson: Json = userMetadata match {
case Some(meta) =>
Json.obj(
"keywords" -> JsonObject.fromIterable(
meta.keywords.map {
case (k, v) => k.value -> v.asJson
}
).toJson
"keywords" -> JsonObject
.fromIterable(
meta.keywords.map { case (k, v) =>
k.value -> v.asJson
}
)
.toJson
)
case None => Json.obj()
}
Expand Down Expand Up @@ -730,6 +732,6 @@ object FilesRoutesSpec extends CirceLiteral {
}
"""

mainJson deepMerge(keywordsJson)
mainJson deepMerge (keywordsJson)
}
}

0 comments on commit 7ecbd2e

Please sign in to comment.