Search in sources :

Example 1 with User

use of uk.gov.hmcts.reform.idam.client.models.User in project nfdiv-case-api by hmcts.

the class CaseworkerGeneralEmailTest method shouldSetGeneralEmailDetailsAndSendEmailNotificationWhenExistingGeneralEmailsIsNull.

@Test
void shouldSetGeneralEmailDetailsAndSendEmailNotificationWhenExistingGeneralEmailsIsNull() {
    setMockClock(clock);
    final CaseData caseData = caseData();
    caseData.setGeneralEmail(GeneralEmail.builder().generalEmailParties(APPLICANT).generalEmailDetails("some details").build());
    final CaseDetails<CaseData, State> details = new CaseDetails<>();
    details.setId(TEST_CASE_ID);
    details.setData(caseData);
    when(httpServletRequest.getHeader(AUTHORIZATION)).thenReturn(TEST_AUTHORIZATION_TOKEN);
    when(idamService.retrieveUser(TEST_AUTHORIZATION_TOKEN)).thenReturn(new User(TEST_AUTHORIZATION_TOKEN, UserDetails.builder().forename("forename").surname("lastname").build()));
    AboutToStartOrSubmitResponse<CaseData, State> response = generalEmail.aboutToSubmit(details, details);
    assertThat(response.getData().getGeneralEmails()).extracting("value").extracting("generalEmailDateTime", "generalEmailParties", "generalEmailCreatedBy", "generalEmailBody").contains(tuple(getExpectedLocalDateTime(), APPLICANT, "forename lastname", "some details"));
    verify(generalEmailNotification).send(caseData, TEST_CASE_ID);
}
Also used : CaseData(uk.gov.hmcts.divorce.divorcecase.model.CaseData) User(uk.gov.hmcts.reform.idam.client.models.User) State(uk.gov.hmcts.divorce.divorcecase.model.State) CaseDetails(uk.gov.hmcts.ccd.sdk.api.CaseDetails) Test(org.junit.jupiter.api.Test)

Example 2 with User

use of uk.gov.hmcts.reform.idam.client.models.User in project nfdiv-case-api by hmcts.

the class CcdAccessServiceTest method shouldNotThrowAnyExceptionWhenAddApplicant1RoleIsInvoked.

@Test
public void shouldNotThrowAnyExceptionWhenAddApplicant1RoleIsInvoked() {
    User solicitorUser = getIdamUser(APP_1_SOL_AUTH_TOKEN, SOLICITOR_USER_ID, TEST_SOL_USER_EMAIL);
    User systemUpdateUser = getIdamUser(SYSTEM_UPDATE_AUTH_TOKEN, SYSTEM_USER_USER_ID, TEST_SYSTEM_UPDATE_USER_EMAIL);
    when(idamService.retrieveUser(APP_1_SOL_AUTH_TOKEN)).thenReturn(solicitorUser);
    when(idamService.retrieveSystemUpdateUserDetails()).thenReturn(systemUpdateUser);
    when(authTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);
    when(caseAssignmentApi.removeCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class))).thenReturn(CaseAssignmentUserRolesResponse.builder().build());
    when(caseAssignmentApi.addCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class))).thenReturn(CaseAssignmentUserRolesResponse.builder().build());
    assertThatCode(() -> ccdAccessService.addApplicant1SolicitorRole(APP_1_SOL_AUTH_TOKEN, TEST_CASE_ID, "1")).doesNotThrowAnyException();
    verify(idamService).retrieveUser(APP_1_SOL_AUTH_TOKEN);
    verify(idamService).retrieveSystemUpdateUserDetails();
    verify(authTokenGenerator).generate();
    verify(caseAssignmentApi).removeCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class));
    verify(caseAssignmentApi).addCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class));
    verifyNoMoreInteractions(idamService, authTokenGenerator, caseAssignmentApi);
}
Also used : User(uk.gov.hmcts.reform.idam.client.models.User) CaseAssignmentUserRolesRequest(uk.gov.hmcts.reform.ccd.client.model.CaseAssignmentUserRolesRequest) Test(org.junit.jupiter.api.Test)

Example 3 with User

use of uk.gov.hmcts.reform.idam.client.models.User in project nfdiv-case-api by hmcts.

the class CcdAccessServiceTest method shouldThrowInvalidTokenExceptionWhenServiceAuthTokenGenerationFails.

@Test
public void shouldThrowInvalidTokenExceptionWhenServiceAuthTokenGenerationFails() {
    User solicitorUser = getIdamUser(APP_1_SOL_AUTH_TOKEN, SOLICITOR_USER_ID, TEST_SOL_USER_EMAIL);
    User systemUpdateUser = getIdamUser(SYSTEM_UPDATE_AUTH_TOKEN, SYSTEM_USER_USER_ID, TEST_SYSTEM_UPDATE_USER_EMAIL);
    when(idamService.retrieveUser(APP_1_SOL_AUTH_TOKEN)).thenReturn(solicitorUser);
    when(idamService.retrieveSystemUpdateUserDetails()).thenReturn(systemUpdateUser);
    doThrow(new InvalidTokenException("s2s secret is invalid")).when(authTokenGenerator).generate();
    assertThatThrownBy(() -> ccdAccessService.addApplicant1SolicitorRole(APP_1_SOL_AUTH_TOKEN, TEST_CASE_ID, null)).isExactlyInstanceOf(InvalidTokenException.class).hasMessageContaining("s2s secret is invalid");
    verify(idamService).retrieveUser(APP_1_SOL_AUTH_TOKEN);
    verify(idamService).retrieveSystemUpdateUserDetails();
    verifyNoMoreInteractions(idamService);
}
Also used : InvalidTokenException(uk.gov.hmcts.reform.authorisation.exceptions.InvalidTokenException) User(uk.gov.hmcts.reform.idam.client.models.User) Test(org.junit.jupiter.api.Test)

Example 4 with User

use of uk.gov.hmcts.reform.idam.client.models.User in project nfdiv-case-api by hmcts.

the class CcdAccessServiceTest method shouldReturnTrueWhenUserHasCreatorRole.

@Test
public void shouldReturnTrueWhenUserHasCreatorRole() {
    User user = new User(TEST_SERVICE_AUTH_TOKEN, UserDetails.builder().id("user-id").build());
    when(idamService.retrieveUser(SYSTEM_UPDATE_AUTH_TOKEN)).thenReturn(user);
    when(authTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);
    when(caseAssignmentApi.getUserRoles(SYSTEM_UPDATE_AUTH_TOKEN, TEST_SERVICE_AUTH_TOKEN, List.of(TEST_CASE_ID.toString()), List.of("user-id"))).thenReturn(CaseAssignmentUserRolesResource.builder().caseAssignmentUserRoles(List.of(CaseAssignmentUserRole.builder().caseRole(CREATOR.getRole()).build())).build());
    boolean expected = ccdAccessService.isApplicant1(SYSTEM_UPDATE_AUTH_TOKEN, TEST_CASE_ID);
    assertThat(expected).isTrue();
}
Also used : User(uk.gov.hmcts.reform.idam.client.models.User) Test(org.junit.jupiter.api.Test)

Example 5 with User

use of uk.gov.hmcts.reform.idam.client.models.User in project nfdiv-case-api by hmcts.

the class CcdAccessServiceTest method shouldNotThrowAnyExceptionWhenLinkApplicant2ToApplicationIsInvoked.

@Test
public void shouldNotThrowAnyExceptionWhenLinkApplicant2ToApplicationIsInvoked() {
    User systemUpdateUser = getIdamUser(SYSTEM_UPDATE_AUTH_TOKEN, CASEWORKER_USER_ID, TEST_CASEWORKER_USER_EMAIL);
    when(idamService.retrieveUser(SYSTEM_UPDATE_AUTH_TOKEN)).thenReturn(systemUpdateUser);
    when(authTokenGenerator.generate()).thenReturn(TEST_SERVICE_AUTH_TOKEN);
    when(caseAssignmentApi.addCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class))).thenReturn(any());
    assertThatCode(() -> ccdAccessService.linkRespondentToApplication(SYSTEM_UPDATE_AUTH_TOKEN, TEST_CASE_ID, APP_2_CITIZEN_USER_ID)).doesNotThrowAnyException();
    verify(idamService).retrieveUser(SYSTEM_UPDATE_AUTH_TOKEN);
    verify(authTokenGenerator).generate();
    verify(caseAssignmentApi).addCaseUserRoles(eq(SYSTEM_UPDATE_AUTH_TOKEN), eq(TEST_SERVICE_AUTH_TOKEN), any(CaseAssignmentUserRolesRequest.class));
    verifyNoMoreInteractions(idamService, authTokenGenerator, caseAssignmentApi);
}
Also used : User(uk.gov.hmcts.reform.idam.client.models.User) CaseAssignmentUserRolesRequest(uk.gov.hmcts.reform.ccd.client.model.CaseAssignmentUserRolesRequest) Test(org.junit.jupiter.api.Test)

Aggregations

User (uk.gov.hmcts.reform.idam.client.models.User)153 Test (org.junit.jupiter.api.Test)93 CaseData (uk.gov.hmcts.divorce.divorcecase.model.CaseData)40 CaseDetails (uk.gov.hmcts.reform.ccd.client.model.CaseDetails)35 BulkActionCaseData (uk.gov.hmcts.divorce.bulkaction.data.BulkActionCaseData)33 ListValue (uk.gov.hmcts.ccd.sdk.type.ListValue)31 BulkActionState (uk.gov.hmcts.divorce.bulkaction.ccd.BulkActionState)30 CaseDetails (uk.gov.hmcts.ccd.sdk.api.CaseDetails)28 State (uk.gov.hmcts.divorce.divorcecase.model.State)25 BeforeEach (org.junit.jupiter.api.BeforeEach)22 BulkListCaseDetails (uk.gov.hmcts.divorce.bulkaction.data.BulkListCaseDetails)22 StartEventResponse (uk.gov.hmcts.reform.ccd.client.model.StartEventResponse)22 CaseDataContent (uk.gov.hmcts.reform.ccd.client.model.CaseDataContent)20 HashMap (java.util.HashMap)19 CcdSearchCaseException (uk.gov.hmcts.divorce.systemupdate.service.CcdSearchCaseException)19 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)18 CaseTask (uk.gov.hmcts.divorce.divorcecase.task.CaseTask)17 ConfidentialDivorceDocument (uk.gov.hmcts.divorce.document.model.ConfidentialDivorceDocument)12 CcdConflictException (uk.gov.hmcts.divorce.systemupdate.service.CcdConflictException)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11