Search in sources :

Example 6 with ParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO 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 7 with ParticipantDTO

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

the class ParticipantLinkToParticipantExtendedDTOConverter method convert.

@Override
public ParticipantExtendedDTO convert(ParticipantLink participantLink) {
    final ParticipantExtendedDTO participantDTO = new ParticipantExtendedDTO();
    ParticipantRole role = participantLink.getRole();
    final IUser user = participantLink.getUser();
    participantDTO.setId(user.getUuid());
    participantDTO.setFullName(user.getFullName());
    participantDTO.setRole(new OptionDTO(role.name(), role.toString()));
    participantDTO.setStatus(participantLink.getStatus().toString());
    participantDTO.setAffilation(user.getAffiliation());
    participantDTO.setProfessionalType(user.getProfessionalType());
    return participantDTO;
}
Also used : IUser(com.odysseusinc.arachne.portal.model.IUser) OptionDTO(com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO) ParticipantExtendedDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Example 8 with ParticipantDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO 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)6 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)6 Test (org.junit.Test)6 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)6 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 OptionDTO (com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO)2 AddStudyParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.AddStudyParticipantDTO)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)2 DataOwnerParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataOwnerParticipantDTO)1 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)1 DataSource (com.odysseusinc.arachne.portal.model.DataSource)1 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)1