Skip to content

Commit 39b371b

Browse files
committed
chore: simplify and clean up detekt report tasks and unused test error validation logic
1 parent 5c83951 commit 39b371b

3 files changed

Lines changed: 13 additions & 45 deletions

File tree

api/src/integrationTest/kotlin/com/cosmotech/api/home/organization/OrganizationConstants.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,5 @@ object OrganizationConstants {
2828
"""{"id":"$NEW_USER_ID","role":"$NEW_USER_ROLE"}"""
2929
}
3030

31-
object Errors {
32-
val emptyNameOrganizationCreationRequestError =
33-
"""{"type":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400","title":"Bad Request","status":400,"detail":"name: cannot be empty","instance":"/organizations"}"""
34-
}
31+
object Errors {}
3532
}

api/src/integrationTest/kotlin/com/cosmotech/api/home/organization/OrganizationControllerTests.kt

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.cosmotech.api.home.Constants.PLATFORM_ADMIN_EMAIL
66
import com.cosmotech.api.home.ControllerTestBase
77
import com.cosmotech.api.home.ControllerTestUtils.OrganizationUtils.constructOrganizationCreateRequest
88
import com.cosmotech.api.home.ControllerTestUtils.OrganizationUtils.createOrganizationAndReturnId
9-
import com.cosmotech.api.home.organization.OrganizationConstants.Errors.emptyNameOrganizationCreationRequestError
109
import com.cosmotech.api.home.organization.OrganizationConstants.NEW_ORGANIZATION_NAME
1110
import com.cosmotech.api.home.organization.OrganizationConstants.NEW_USER_ID
1211
import com.cosmotech.api.home.organization.OrganizationConstants.NEW_USER_ROLE
@@ -21,7 +20,6 @@ import com.cosmotech.api.home.withPlatformAdminHeader
2120
import com.cosmotech.common.rbac.ROLE_ADMIN
2221
import com.cosmotech.common.rbac.ROLE_NONE
2322
import com.cosmotech.common.rbac.ROLE_VIEWER
24-
import kotlin.test.assertEquals
2523
import org.json.JSONObject
2624
import org.junit.jupiter.api.Test
2725
import org.slf4j.LoggerFactory
@@ -378,44 +376,18 @@ class OrganizationControllerTests : ControllerTestBase() {
378376

379377
@Test
380378
fun create_organization_with_empty_name() {
381-
val responseContent =
382-
JSONObject(
383-
mvc.perform(
384-
post("/organizations")
385-
.contentType(MediaType.APPLICATION_JSON)
386-
.withPlatformAdminHeader()
387-
.content(EMPTY_NAME_ORGANIZATION_REQUEST_CREATION)
388-
.accept(MediaType.APPLICATION_JSON)
389-
.with(csrf())
390-
)
391-
.andExpect(status().is4xxClientError)
392-
.andExpect(status().isBadRequest)
393-
.andDo(MockMvcResultHandlers.print())
394-
.andReturn()
395-
.response
396-
.contentAsString
379+
mvc.perform(
380+
post("/organizations")
381+
.contentType(MediaType.APPLICATION_JSON)
382+
.withPlatformAdminHeader()
383+
.content(EMPTY_NAME_ORGANIZATION_REQUEST_CREATION)
384+
.accept(MediaType.APPLICATION_JSON)
385+
.with(csrf())
397386
)
398-
399-
assertEquals(
400-
JSONObject(emptyNameOrganizationCreationRequestError).get("detail"),
401-
responseContent.get("detail"),
402-
)
403-
assertEquals(
404-
JSONObject(emptyNameOrganizationCreationRequestError).get("title"),
405-
responseContent.get("title"),
406-
)
407-
assertEquals(
408-
JSONObject(emptyNameOrganizationCreationRequestError).get("status"),
409-
responseContent.get("status"),
410-
)
411-
assertEquals(
412-
JSONObject(emptyNameOrganizationCreationRequestError).get("instance"),
413-
responseContent.get("instance"),
414-
)
415-
assertEquals(
416-
JSONObject(emptyNameOrganizationCreationRequestError).get("type"),
417-
responseContent.get("type"),
418-
)
387+
.andExpect(status().is4xxClientError)
388+
.andExpect(status().isBadRequest)
389+
.andExpect(jsonPath("$.detail").value("name: cannot be empty"))
390+
.andDo(MockMvcResultHandlers.print())
419391
}
420392

421393
@Test

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,9 @@ tasks.getByName("spotlessKotlinGradle") {
615615
val copySubProjectsDetektReportsTasks =
616616
subprojects.flatMap { subProject ->
617617
listOf("html", "xml", "txt", "sarif").map { format ->
618-
val formatCapitalized = format
619618
val copyTask =
620619
tasks.register<Copy>(
621-
"detektCopy${formatCapitalized}ReportFor" +
620+
"detektCopy${format}ReportFor" +
622621
"${subProject.projectDir.relativeTo(rootDir)}".replace("/", "_")
623622
) {
624623
group = "detekt"

0 commit comments

Comments
 (0)