Skip to content

Commit

Permalink
chore: Prefer the more fluent infix variant of shouldNotBeNull
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 22, 2025
1 parent 7a00318 commit 9c8ffa2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ClearlyDefinedServiceFunTest : WordSpec({
ClearlyDefinedService.JSON.decodeFromStream<Curation>(it)
}

curation.described?.facets.shouldNotBeNull {
curation.described?.facets shouldNotBeNull {
dev.shouldNotBeNull() should beEmpty()
tests.shouldNotBeNull() should beEmpty()
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class ClearlyDefinedServiceFunTest : WordSpec({

val summary = service.putCuration(ContributionPatch(info, listOf(patch)))

summary.shouldNotBeNull {
summary shouldNotBeNull {
prNumber shouldBeGreaterThan 0
url shouldStartWith "${Server.DEVELOPMENT.projectUrl}/pull/"
}
Expand All @@ -142,7 +142,7 @@ class ClearlyDefinedServiceFunTest : WordSpec({
val curations = service.getDefinitions(listOf(coordinates))

curations shouldHaveSize 1
curations[coordinates]?.files?.get(11)?.facets.shouldNotBeNull {
curations[coordinates]?.files?.get(11)?.facets shouldNotBeNull {
this shouldContain "tests"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FossId2021dot2Test : StringSpec({
// Recreate the version as the service caches it.
service = FossIdServiceWithVersion.create(service)

service.checkScanStatus("", "", SCAN_CODE_2021_2).shouldNotBeNull {
service.checkScanStatus("", "", SCAN_CODE_2021_2) shouldNotBeNull {
checkResponse("get scan status")

data.shouldNotBeNull().status shouldBe ScanStatus.FINISHED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class FossId2023dot1Test : StringSpec({
// Recreate the version as the service caches it.
service = FossIdServiceWithVersion.create(service)

service.deleteScan("", "", SCAN_CODE_2021_2).shouldNotBeNull {
service.deleteScan("", "", SCAN_CODE_2021_2) shouldNotBeNull {
checkResponse("delete scan")

data.shouldNotBeNull().value shouldBe 522415
Expand Down
36 changes: 18 additions & 18 deletions clients/fossid-webapp/src/test/kotlin/FossIdClientNewProjectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ class FossIdClientNewProjectTest : StringSpec({
}

"Projects can be listed when there is none" {
service.getProject("", "", PROJECT_CODE).shouldNotBeNull {
service.getProject("", "", PROJECT_CODE) shouldNotBeNull {
status shouldBe 0
data should beNull()
}
}

"Project can be created" {
service.createProject("", "", PROJECT_CODE, PROJECT_CODE).shouldNotBeNull {
service.createProject("", "", PROJECT_CODE, PROJECT_CODE) shouldNotBeNull {
checkResponse("create project")
data.shouldNotBeNull() shouldContain("project_id" to "405")
}
}

"Scans for project can be listed when there is no scan" {
service.listScansForProject("", "", PROJECT_CODE).shouldNotBeNull {
service.listScansForProject("", "", PROJECT_CODE) shouldNotBeNull {
checkResponse("list scans")
data.shouldNotBeNull() should beEmpty()
}
Expand All @@ -99,26 +99,26 @@ class FossIdClientNewProjectTest : StringSpec({
}

"Download from Git can be triggered" {
service.downloadFromGit("", "", SCAN_CODE).shouldNotBeNull {
service.downloadFromGit("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("download data from Git", false)
}
}

"Download status can be queried" {
service.checkDownloadStatus("", "", SCAN_CODE).shouldNotBeNull {
service.checkDownloadStatus("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("check download status")
data shouldBe DownloadStatus.FINISHED
}
}

"A scan can be run" {
service.runScan("", "", SCAN_CODE).shouldNotBeNull {
service.runScan("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("trigger scan", false)
}
}

"A scan can be deleted" {
service.deleteScan("", "", SCAN_CODE).shouldNotBeNull {
service.deleteScan("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("delete scan")

data?.value shouldBe 2976
Expand All @@ -127,30 +127,30 @@ class FossIdClientNewProjectTest : StringSpec({
}

"Scan status can be queried" {
service.checkScanStatus("", "", SCAN_CODE).shouldNotBeNull {
service.checkScanStatus("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("get scan status")

data.shouldNotBeNull().status shouldBe ScanStatus.FINISHED
}
}

"Scan results can be listed" {
service.listScanResults("", "", SCAN_CODE).shouldNotBeNull {
service.listScanResults("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("list scan results")
data.shouldNotBeNull {
data shouldNotBeNull {
size shouldBe 58
last().localPath shouldBe "pom.xml"
}
}
}

"Identified files can be listed" {
service.listIdentifiedFiles("", "", SCAN_CODE).shouldNotBeNull {
service.listIdentifiedFiles("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("list identified files")
data.shouldNotBeNull {
data shouldNotBeNull {
size shouldBe 40
last().should {
it.file.shouldNotBeNull {
it.file shouldNotBeNull {
path shouldBe "LICENSE.md"
licenseIdentifier shouldBe "MIT"
licenseIsFoss shouldBe true
Expand All @@ -164,16 +164,16 @@ class FossIdClientNewProjectTest : StringSpec({
}

"Marked files can be listed when there are none" {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE).shouldNotBeNull {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("list marked as identified files")
data.shouldNotBeNull() should beEmpty()
}
}

"Ignored files can be listed" {
service.listIgnoredFiles("", "", SCAN_CODE).shouldNotBeNull {
service.listIgnoredFiles("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("list ignored files")
data.shouldNotBeNull {
data shouldNotBeNull {
size shouldBe 32
first() should { ignoredFile ->
ignoredFile.path shouldBe ".git/hooks/fsmonitor-watchman.sample"
Expand All @@ -184,9 +184,9 @@ class FossIdClientNewProjectTest : StringSpec({
}

"Pending files can be listed" {
service.listPendingFiles("", "", SCAN_CODE).shouldNotBeNull {
service.listPendingFiles("", "", SCAN_CODE) shouldNotBeNull {
checkResponse("list pending files")
data.shouldNotBeNull {
data shouldNotBeNull {
size shouldBe 2
first() shouldBe "src/extra_file.txt"
}
Expand Down
66 changes: 33 additions & 33 deletions clients/fossid-webapp/src/test/kotlin/FossIdClientReturnTypeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,50 +72,50 @@ class FossIdClientReturnTypeTest : StringSpec({
}

"Single scan can be queried" {
service.getScan("", "", SCAN_CODE_2).shouldNotBeNull {
service.getScan("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("get scan")
data.shouldBeTypeOf<Scan>()
}
}

"Scans for project can be listed when there is none" {
service.listScansForProject("", "", PROJECT_CODE_1).shouldNotBeNull {
service.listScansForProject("", "", PROJECT_CODE_1) shouldNotBeNull {
checkResponse("list scans")
data.shouldNotBeNull() should beEmpty()
}
}

"Scans for project can be listed when there is exactly one" {
service.listScansForProject("", "", PROJECT_CODE_3).shouldNotBeNull {
service.listScansForProject("", "", PROJECT_CODE_3) shouldNotBeNull {
checkResponse("list scans")
data.shouldNotBeNull {
data shouldNotBeNull {
size shouldBe 1
first().shouldBeTypeOf<Scan>()
}
}
}

"Scans for project can be listed when there is some" {
service.listScansForProject("", "", PROJECT_CODE_2).shouldNotBeNull {
service.listScansForProject("", "", PROJECT_CODE_2) shouldNotBeNull {
checkResponse("list scans")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
first().shouldBeTypeOf<Scan>()
}
}
}

"Scan results can be listed when there is none" {
service.listScanResults("", "", SCAN_CODE_1).shouldNotBeNull {
service.listScanResults("", "", SCAN_CODE_1) shouldNotBeNull {
checkResponse("list scan results")
data.shouldNotBeNull() should beEmpty()
}
}

"Scan results can be listed when there is some" {
service.listScanResults("", "", SCAN_CODE_2).shouldNotBeNull {
service.listScanResults("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("list scan results")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<FossIdScanResult>()
Expand All @@ -130,9 +130,9 @@ class FossIdClientReturnTypeTest : StringSpec({
"",
SCAN_CODE_2,
"src/main/java/com/vdurmont/semver4j/Requirement.java"
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("list snippets")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<Snippet>()
Expand All @@ -147,9 +147,9 @@ class FossIdClientReturnTypeTest : StringSpec({
"",
SCAN_CODE_1,
"src/main/java/com/vdurmont/semver4j/Requirement.java"
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("list snippets")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<Snippet>()
Expand All @@ -165,26 +165,26 @@ class FossIdClientReturnTypeTest : StringSpec({
SCAN_CODE_2,
"src/main/java/com/vdurmont/semver4j/Requirement.java",
119
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("list matched lines")
data.shouldNotBeNull {
data shouldNotBeNull {
localFile shouldNot beEmpty()
mirrorFile shouldNot beEmpty()
}
}
}

"Identified files can be listed when there is none" {
service.listIdentifiedFiles("", "", SCAN_CODE_1).shouldNotBeNull {
service.listIdentifiedFiles("", "", SCAN_CODE_1) shouldNotBeNull {
checkResponse("list identified files")
data.shouldNotBeNull() should beEmpty()
}
}

"Identified files can be listed when there is some" {
service.listIdentifiedFiles("", "", SCAN_CODE_2).shouldNotBeNull {
service.listIdentifiedFiles("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("list identified files")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<IdentifiedFile>()
Expand All @@ -194,16 +194,16 @@ class FossIdClientReturnTypeTest : StringSpec({
}

"Marked as identified files can be listed when there is none" {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE_1).shouldNotBeNull {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE_1) shouldNotBeNull {
checkResponse("list marked as identified files")
data.shouldNotBeNull() should beEmpty()
}
}

"Marked as identified files can be listed when there is some" {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE_2).shouldNotBeNull {
service.listMarkedAsIdentifiedFiles("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("list marked as identified files")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<MarkedAsIdentifiedFile>()
Expand All @@ -213,16 +213,16 @@ class FossIdClientReturnTypeTest : StringSpec({
}

"Ignored files can be listed when there is none" {
service.listIgnoredFiles("", "", SCAN_CODE_1).shouldNotBeNull {
service.listIgnoredFiles("", "", SCAN_CODE_1) shouldNotBeNull {
checkResponse("list ignored files")
data.shouldNotBeNull() should beEmpty()
}
}

"Ignored files can be listed when there is some" {
service.listIgnoredFiles("", "", SCAN_CODE_2).shouldNotBeNull {
service.listIgnoredFiles("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("list ignored files")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<IgnoredFile>()
Expand All @@ -232,16 +232,16 @@ class FossIdClientReturnTypeTest : StringSpec({
}

"Pending files can be listed when there is none" {
service.listPendingFiles("", "", SCAN_CODE_1).shouldNotBeNull {
service.listPendingFiles("", "", SCAN_CODE_1) shouldNotBeNull {
checkResponse("list pending files")
data.shouldNotBeNull() should beEmpty()
}
}

"Pending files can be listed when there is some" {
service.listPendingFiles("", "", SCAN_CODE_2).shouldNotBeNull {
service.listPendingFiles("", "", SCAN_CODE_2) shouldNotBeNull {
checkResponse("list pending files")
data.shouldNotBeNull {
data shouldNotBeNull {
this shouldNot beEmpty()
forEach {
it.shouldBeTypeOf<String>()
Expand All @@ -251,7 +251,7 @@ class FossIdClientReturnTypeTest : StringSpec({
}

"When the scan to delete does not exist, no exception is thrown" {
service.deleteScan("", "", SCAN_CODE_1).shouldNotBeNull {
service.deleteScan("", "", SCAN_CODE_1) shouldNotBeNull {
error shouldBe "Classes.TableRepository.row_not_found"
}
}
Expand All @@ -263,7 +263,7 @@ class FossIdClientReturnTypeTest : StringSpec({
SCAN_CODE_1,
"src/main/java/com/vdurmont/semver4j/Range.java",
false
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("mark file as identified")
}
}
Expand All @@ -275,7 +275,7 @@ class FossIdClientReturnTypeTest : StringSpec({
SCAN_CODE_1,
"src/main/java/com/vdurmont/semver4j/Range.java",
false
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("unmark file as identified")
}
}
Expand All @@ -289,7 +289,7 @@ class FossIdClientReturnTypeTest : StringSpec({
"Apache-2.0",
LicenseMatchType.SNIPPET,
false
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("add license identification")
}
}
Expand All @@ -304,7 +304,7 @@ class FossIdClientReturnTypeTest : StringSpec({
"3.0.0",
isDirectory = false,
preserveExistingIdentifications = false
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("add component identification")
}
}
Expand All @@ -316,7 +316,7 @@ class FossIdClientReturnTypeTest : StringSpec({
SCAN_CODE_1,
"src/main/java/com/vdurmont/semver4j/Range.java",
"TestORT"
).shouldNotBeNull {
) shouldNotBeNull {
checkResponse("add file comment")
}
}
Expand Down
Loading

0 comments on commit 9c8ffa2

Please sign in to comment.