package com.oguerreiro.resilient.web.rest;

import static com.oguerreiro.resilient.domain.OrganizationTypeAsserts.*;
import static com.oguerreiro.resilient.web.rest.TestUtil.createUpdateProxyForBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.*;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.oguerreiro.resilient.IntegrationTest;
import com.oguerreiro.resilient.domain.OrganizationType;
import com.oguerreiro.resilient.domain.enumeration.OrganizationNature;
import com.oguerreiro.resilient.repository.OrganizationTypeRepository;
import com.oguerreiro.resilient.service.OrganizationTypeService;
import com.oguerreiro.resilient.service.dto.OrganizationTypeDTO;
import com.oguerreiro.resilient.service.mapper.OrganizationTypeMapper;
import jakarta.persistence.EntityManager;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

/**
 * Integration tests for the {@link OrganizationTypeResource} REST controller.
 */
@IntegrationTest
@ExtendWith(MockitoExtension.class)
@AutoConfigureMockMvc
@WithMockUser
class OrganizationTypeResourceIT {

    private static final String DEFAULT_CODE = "AAAAAAAAAA";
    private static final String UPDATED_CODE = "BBBBBBBBBB";

    private static final String DEFAULT_NAME = "AAAAAAAAAA";
    private static final String UPDATED_NAME = "BBBBBBBBBB";

    private static final String DEFAULT_DESCRIPTION = "AAAAAAAAAA";
    private static final String UPDATED_DESCRIPTION = "BBBBBBBBBB";

    private static final OrganizationNature DEFAULT_NATURE = OrganizationNature.ORGANIZATION;
    private static final OrganizationNature UPDATED_NATURE = OrganizationNature.PERSON;

    private static final byte[] DEFAULT_ICON = TestUtil.createByteArray(1, "0");
    private static final byte[] UPDATED_ICON = TestUtil.createByteArray(1, "1");
    private static final String DEFAULT_ICON_CONTENT_TYPE = "image/jpg";
    private static final String UPDATED_ICON_CONTENT_TYPE = "image/png";

    private static final Integer DEFAULT_VERSION = 1;
    private static final Integer UPDATED_VERSION = 2;

    private static final String ENTITY_API_URL = "/api/organization-types";
    private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}";

    private static Random random = new Random();
    private static AtomicLong longCount = new AtomicLong(random.nextInt() + (2 * Integer.MAX_VALUE));

    @Autowired
    private ObjectMapper om;

    @Autowired
    private OrganizationTypeRepository organizationTypeRepository;

    @Mock
    private OrganizationTypeRepository organizationTypeRepositoryMock;

    @Autowired
    private OrganizationTypeMapper organizationTypeMapper;

    @Mock
    private OrganizationTypeService organizationTypeServiceMock;

    @Autowired
    private EntityManager em;

    @Autowired
    private MockMvc restOrganizationTypeMockMvc;

    private OrganizationType organizationType;

    private OrganizationType insertedOrganizationType;

    /**
     * Create an entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static OrganizationType createEntity(EntityManager em) {
        OrganizationType organizationType = new OrganizationType()
            .code(DEFAULT_CODE)
            .name(DEFAULT_NAME)
            .description(DEFAULT_DESCRIPTION)
            .nature(DEFAULT_NATURE)
            .icon(DEFAULT_ICON)
            .iconContentType(DEFAULT_ICON_CONTENT_TYPE)
            .version(DEFAULT_VERSION);
        return organizationType;
    }

    /**
     * Create an updated entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static OrganizationType createUpdatedEntity(EntityManager em) {
        OrganizationType organizationType = new OrganizationType()
            .code(UPDATED_CODE)
            .name(UPDATED_NAME)
            .description(UPDATED_DESCRIPTION)
            .nature(UPDATED_NATURE)
            .icon(UPDATED_ICON)
            .iconContentType(UPDATED_ICON_CONTENT_TYPE)
            .version(UPDATED_VERSION);
        return organizationType;
    }

    @BeforeEach
    public void initTest() {
        organizationType = createEntity(em);
    }

    @AfterEach
    public void cleanup() {
        if (insertedOrganizationType != null) {
            organizationTypeRepository.delete(insertedOrganizationType);
            insertedOrganizationType = null;
        }
    }

    @Test
    @Transactional
    void createOrganizationType() throws Exception {
        long databaseSizeBeforeCreate = getRepositoryCount();
        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);
        var returnedOrganizationTypeDTO = om.readValue(
            restOrganizationTypeMockMvc
                .perform(
                    post(ENTITY_API_URL)
                        .with(csrf())
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(om.writeValueAsBytes(organizationTypeDTO))
                )
                .andExpect(status().isCreated())
                .andReturn()
                .getResponse()
                .getContentAsString(),
            OrganizationTypeDTO.class
        );

        // Validate the OrganizationType in the database
        assertIncrementedRepositoryCount(databaseSizeBeforeCreate);
        var returnedOrganizationType = organizationTypeMapper.toEntity(returnedOrganizationTypeDTO);
        assertOrganizationTypeUpdatableFieldsEquals(returnedOrganizationType, getPersistedOrganizationType(returnedOrganizationType));

        insertedOrganizationType = returnedOrganizationType;
    }

    @Test
    @Transactional
    void createOrganizationTypeWithExistingId() throws Exception {
        // Create the OrganizationType with an existing ID
        organizationType.setId(1L);
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        long databaseSizeBeforeCreate = getRepositoryCount();

        // An entity with an existing ID cannot be created, so this API call must fail
        restOrganizationTypeMockMvc
            .perform(
                post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeCreate);
    }

    @Test
    @Transactional
    void checkCodeIsRequired() throws Exception {
        long databaseSizeBeforeTest = getRepositoryCount();
        // set the field null
        organizationType.setCode(null);

        // Create the OrganizationType, which fails.
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        restOrganizationTypeMockMvc
            .perform(
                post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        assertSameRepositoryCount(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    void checkNameIsRequired() throws Exception {
        long databaseSizeBeforeTest = getRepositoryCount();
        // set the field null
        organizationType.setName(null);

        // Create the OrganizationType, which fails.
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        restOrganizationTypeMockMvc
            .perform(
                post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        assertSameRepositoryCount(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    void checkDescriptionIsRequired() throws Exception {
        long databaseSizeBeforeTest = getRepositoryCount();
        // set the field null
        organizationType.setDescription(null);

        // Create the OrganizationType, which fails.
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        restOrganizationTypeMockMvc
            .perform(
                post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        assertSameRepositoryCount(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    void checkNatureIsRequired() throws Exception {
        long databaseSizeBeforeTest = getRepositoryCount();
        // set the field null
        organizationType.setNature(null);

        // Create the OrganizationType, which fails.
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        restOrganizationTypeMockMvc
            .perform(
                post(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        assertSameRepositoryCount(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    void getAllOrganizationTypes() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        // Get all the organizationTypeList
        restOrganizationTypeMockMvc
            .perform(get(ENTITY_API_URL + "?sort=id,desc"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(organizationType.getId().intValue())))
            .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE)))
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME)))
            .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION)))
            .andExpect(jsonPath("$.[*].nature").value(hasItem(DEFAULT_NATURE.toString())))
            .andExpect(jsonPath("$.[*].iconContentType").value(hasItem(DEFAULT_ICON_CONTENT_TYPE)))
            .andExpect(jsonPath("$.[*].icon").value(hasItem(Base64.getEncoder().encodeToString(DEFAULT_ICON))))
            .andExpect(jsonPath("$.[*].version").value(hasItem(DEFAULT_VERSION)));
    }

    @SuppressWarnings({ "unchecked" })
    void getAllOrganizationTypesWithEagerRelationshipsIsEnabled() throws Exception {
        when(organizationTypeServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));

        restOrganizationTypeMockMvc.perform(get(ENTITY_API_URL + "?eagerload=true")).andExpect(status().isOk());

        verify(organizationTypeServiceMock, times(1)).findAllWithEagerRelationships(any());
    }

    @SuppressWarnings({ "unchecked" })
    void getAllOrganizationTypesWithEagerRelationshipsIsNotEnabled() throws Exception {
        when(organizationTypeServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));

        restOrganizationTypeMockMvc.perform(get(ENTITY_API_URL + "?eagerload=false")).andExpect(status().isOk());
        verify(organizationTypeRepositoryMock, times(1)).findAll(any(Pageable.class));
    }

    @Test
    @Transactional
    void getOrganizationType() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        // Get the organizationType
        restOrganizationTypeMockMvc
            .perform(get(ENTITY_API_URL_ID, organizationType.getId()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.id").value(organizationType.getId().intValue()))
            .andExpect(jsonPath("$.code").value(DEFAULT_CODE))
            .andExpect(jsonPath("$.name").value(DEFAULT_NAME))
            .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION))
            .andExpect(jsonPath("$.nature").value(DEFAULT_NATURE.toString()))
            .andExpect(jsonPath("$.iconContentType").value(DEFAULT_ICON_CONTENT_TYPE))
            .andExpect(jsonPath("$.icon").value(Base64.getEncoder().encodeToString(DEFAULT_ICON)))
            .andExpect(jsonPath("$.version").value(DEFAULT_VERSION));
    }

    @Test
    @Transactional
    void getNonExistingOrganizationType() throws Exception {
        // Get the organizationType
        restOrganizationTypeMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound());
    }

    @Test
    @Transactional
    void putExistingOrganizationType() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        long databaseSizeBeforeUpdate = getRepositoryCount();

        // Update the organizationType
        OrganizationType updatedOrganizationType = organizationTypeRepository.findById(organizationType.getId()).orElseThrow();
        // Disconnect from session so that the updates on updatedOrganizationType are not directly saved in db
        em.detach(updatedOrganizationType);
        updatedOrganizationType
            .code(UPDATED_CODE)
            .name(UPDATED_NAME)
            .description(UPDATED_DESCRIPTION)
            .nature(UPDATED_NATURE)
            .icon(UPDATED_ICON)
            .iconContentType(UPDATED_ICON_CONTENT_TYPE)
            .version(UPDATED_VERSION);
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(updatedOrganizationType);

        restOrganizationTypeMockMvc
            .perform(
                put(ENTITY_API_URL_ID, organizationTypeDTO.getId())
                    .with(csrf())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isOk());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
        assertPersistedOrganizationTypeToMatchAllProperties(updatedOrganizationType);
    }

    @Test
    @Transactional
    void putNonExistingOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                put(ENTITY_API_URL_ID, organizationTypeDTO.getId())
                    .with(csrf())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithIdMismatchOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                put(ENTITY_API_URL_ID, longCount.incrementAndGet())
                    .with(csrf())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithMissingIdPathParamOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                put(ENTITY_API_URL).with(csrf()).contentType(MediaType.APPLICATION_JSON).content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void partialUpdateOrganizationTypeWithPatch() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        long databaseSizeBeforeUpdate = getRepositoryCount();

        // Update the organizationType using partial update
        OrganizationType partialUpdatedOrganizationType = new OrganizationType();
        partialUpdatedOrganizationType.setId(organizationType.getId());

        partialUpdatedOrganizationType.code(UPDATED_CODE);

        restOrganizationTypeMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedOrganizationType.getId())
                    .with(csrf())
                    .contentType("application/merge-patch+json")
                    .content(om.writeValueAsBytes(partialUpdatedOrganizationType))
            )
            .andExpect(status().isOk());

        // Validate the OrganizationType in the database

        assertSameRepositoryCount(databaseSizeBeforeUpdate);
        assertOrganizationTypeUpdatableFieldsEquals(
            createUpdateProxyForBean(partialUpdatedOrganizationType, organizationType),
            getPersistedOrganizationType(organizationType)
        );
    }

    @Test
    @Transactional
    void fullUpdateOrganizationTypeWithPatch() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        long databaseSizeBeforeUpdate = getRepositoryCount();

        // Update the organizationType using partial update
        OrganizationType partialUpdatedOrganizationType = new OrganizationType();
        partialUpdatedOrganizationType.setId(organizationType.getId());

        partialUpdatedOrganizationType
            .code(UPDATED_CODE)
            .name(UPDATED_NAME)
            .description(UPDATED_DESCRIPTION)
            .nature(UPDATED_NATURE)
            .icon(UPDATED_ICON)
            .iconContentType(UPDATED_ICON_CONTENT_TYPE)
            .version(UPDATED_VERSION);

        restOrganizationTypeMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedOrganizationType.getId())
                    .with(csrf())
                    .contentType("application/merge-patch+json")
                    .content(om.writeValueAsBytes(partialUpdatedOrganizationType))
            )
            .andExpect(status().isOk());

        // Validate the OrganizationType in the database

        assertSameRepositoryCount(databaseSizeBeforeUpdate);
        assertOrganizationTypeUpdatableFieldsEquals(
            partialUpdatedOrganizationType,
            getPersistedOrganizationType(partialUpdatedOrganizationType)
        );
    }

    @Test
    @Transactional
    void patchNonExistingOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, organizationTypeDTO.getId())
                    .with(csrf())
                    .contentType("application/merge-patch+json")
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithIdMismatchOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, longCount.incrementAndGet())
                    .with(csrf())
                    .contentType("application/merge-patch+json")
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithMissingIdPathParamOrganizationType() throws Exception {
        long databaseSizeBeforeUpdate = getRepositoryCount();
        organizationType.setId(longCount.incrementAndGet());

        // Create the OrganizationType
        OrganizationTypeDTO organizationTypeDTO = organizationTypeMapper.toDto(organizationType);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restOrganizationTypeMockMvc
            .perform(
                patch(ENTITY_API_URL)
                    .with(csrf())
                    .contentType("application/merge-patch+json")
                    .content(om.writeValueAsBytes(organizationTypeDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the OrganizationType in the database
        assertSameRepositoryCount(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void deleteOrganizationType() throws Exception {
        // Initialize the database
        insertedOrganizationType = organizationTypeRepository.saveAndFlush(organizationType);

        long databaseSizeBeforeDelete = getRepositoryCount();

        // Delete the organizationType
        restOrganizationTypeMockMvc
            .perform(delete(ENTITY_API_URL_ID, organizationType.getId()).with(csrf()).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent());

        // Validate the database contains one less item
        assertDecrementedRepositoryCount(databaseSizeBeforeDelete);
    }

    protected long getRepositoryCount() {
        return organizationTypeRepository.count();
    }

    protected void assertIncrementedRepositoryCount(long countBefore) {
        assertThat(countBefore + 1).isEqualTo(getRepositoryCount());
    }

    protected void assertDecrementedRepositoryCount(long countBefore) {
        assertThat(countBefore - 1).isEqualTo(getRepositoryCount());
    }

    protected void assertSameRepositoryCount(long countBefore) {
        assertThat(countBefore).isEqualTo(getRepositoryCount());
    }

    protected OrganizationType getPersistedOrganizationType(OrganizationType organizationType) {
        return organizationTypeRepository.findById(organizationType.getId()).orElseThrow();
    }

    protected void assertPersistedOrganizationTypeToMatchAllProperties(OrganizationType expectedOrganizationType) {
        assertOrganizationTypeAllPropertiesEquals(expectedOrganizationType, getPersistedOrganizationType(expectedOrganizationType));
    }

    protected void assertPersistedOrganizationTypeToMatchUpdatableProperties(OrganizationType expectedOrganizationType) {
        assertOrganizationTypeAllUpdatablePropertiesEquals(
            expectedOrganizationType,
            getPersistedOrganizationType(expectedOrganizationType)
        );
    }
}
