Search in sources :

Example 1 with UpdateParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateContributorRoleToDatasetOwner.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-before-changing-role.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToDatasetOwner() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(DATA_SET_OWNER.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + 2L).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(VALIDATION_ERROR.getCode()));
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 2 with UpdateParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateContributorRoleToLeadInvestigator.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-2-leaders.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToLeadInvestigator() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(LEAD_INVESTIGATOR.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(2L)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(NO_ERROR_CODE).andReturn();
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 3 with UpdateParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateContributorRoleToContributor.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-with-2-leaders-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-contributor-and-leader.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToContributor() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(CONTRIBUTOR.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(ADMIN_ID)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(NO_ERROR_CODE).andReturn();
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 4 with UpdateParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateContributorRoleForLastLeadInvestigator.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-before-changing-role.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleForLastLeadInvestigator() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(CONTRIBUTOR.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(ADMIN_ID)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(VALIDATION_ERROR.getCode()));
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Aggregations

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)4 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)4 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 Test (org.junit.Test)4 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)4