@@ -6,7 +6,6 @@ import com.cosmotech.api.home.Constants.PLATFORM_ADMIN_EMAIL
66import com.cosmotech.api.home.ControllerTestBase
77import com.cosmotech.api.home.ControllerTestUtils.OrganizationUtils.constructOrganizationCreateRequest
88import com.cosmotech.api.home.ControllerTestUtils.OrganizationUtils.createOrganizationAndReturnId
9- import com.cosmotech.api.home.organization.OrganizationConstants.Errors.emptyNameOrganizationCreationRequestError
109import com.cosmotech.api.home.organization.OrganizationConstants.NEW_ORGANIZATION_NAME
1110import com.cosmotech.api.home.organization.OrganizationConstants.NEW_USER_ID
1211import com.cosmotech.api.home.organization.OrganizationConstants.NEW_USER_ROLE
@@ -21,7 +20,6 @@ import com.cosmotech.api.home.withPlatformAdminHeader
2120import com.cosmotech.common.rbac.ROLE_ADMIN
2221import com.cosmotech.common.rbac.ROLE_NONE
2322import com.cosmotech.common.rbac.ROLE_VIEWER
24- import kotlin.test.assertEquals
2523import org.json.JSONObject
2624import org.junit.jupiter.api.Test
2725import 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
0 commit comments