-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to provide content type for S3 file registration
- Loading branch information
1 parent
54fe6bc
commit d8f9525
Showing
5 changed files
with
58 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 8 additions & 29 deletions
37
delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/FileMatchers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,19 @@ | ||
package ch.epfl.bluebrain.nexus.testkit.scalatest | ||
|
||
import ch.epfl.bluebrain.nexus.testkit.scalatest.JsonMatchers.field | ||
import io.circe.Json | ||
import org.scalatest.matchers.{HavePropertyMatchResult, HavePropertyMatcher} | ||
import org.scalatest.matchers.HavePropertyMatcher | ||
|
||
object FileMatchers { | ||
|
||
def keywords(expected: (String, String)*): HavePropertyMatcher[Json, Map[String, String]] = keywords(expected.toMap) | ||
|
||
def keywords(expected: Map[String, String]): HavePropertyMatcher[Json, Map[String, String]] = HavePropertyMatcher { | ||
json => | ||
val actual = json.hcursor.downField("_keywords").as[Map[String, String]].toOption | ||
HavePropertyMatchResult( | ||
actual.contains(expected), | ||
"keywords", | ||
expected, | ||
actual.orNull | ||
) | ||
} | ||
def keywords(expected: Map[String, String]): HavePropertyMatcher[Json, Map[String, String]] = | ||
field("_keywords", expected) | ||
|
||
def description(expected: String): HavePropertyMatcher[Json, String] = HavePropertyMatcher { json => | ||
val actual = json.hcursor.downField("description").as[String].toOption | ||
HavePropertyMatchResult( | ||
actual.contains(expected), | ||
"description", | ||
expected, | ||
actual.orNull | ||
) | ||
} | ||
def description(expected: String): HavePropertyMatcher[Json, String] = field("description", expected) | ||
|
||
def name(expected: String): HavePropertyMatcher[Json, String] = HavePropertyMatcher { json => | ||
val actual = json.hcursor.downField("name").as[String].toOption | ||
HavePropertyMatchResult( | ||
actual.contains(expected), | ||
"name", | ||
expected, | ||
actual.orNull | ||
) | ||
} | ||
def name(expected: String): HavePropertyMatcher[Json, String] = field("name", expected) | ||
|
||
def mediaType(expected: String): HavePropertyMatcher[Json, String] = field("_mediaType", expected) | ||
} |
20 changes: 20 additions & 0 deletions
20
delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/JsonMatchers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ch.epfl.bluebrain.nexus.testkit.scalatest | ||
|
||
import io.circe.{Decoder, Json} | ||
import org.scalatest.matchers.{HavePropertyMatchResult, HavePropertyMatcher} | ||
|
||
import scala.reflect.ClassTag | ||
|
||
object JsonMatchers { | ||
def field[A: Decoder: ClassTag](key: String, expectedValue: A)(implicit | ||
ev: Null <:< A | ||
): HavePropertyMatcher[Json, A] = HavePropertyMatcher { json => | ||
val actual = json.hcursor.downField(key).as[A].toOption | ||
HavePropertyMatchResult( | ||
actual.contains(expectedValue), | ||
key, | ||
expectedValue, | ||
actual.orNull | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters