use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testSubmitEthicsTraining_success.
@Test
public void testSubmitEthicsTraining_success() throws Exception {
createUser();
Profile profile = profileController.completeEthicsTraining().getBody();
assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
assertThat(profile.getBlockscoreIdVerificationStatus()).isEqualTo(BlockscoreIdVerificationStatus.UNVERIFIED);
assertThat(profile.getDemographicSurveyCompletionTime()).isNull();
assertThat(profile.getTermsOfServiceCompletionTime()).isNull();
assertThat(profile.getEthicsTrainingCompletionTime()).isEqualTo(NOW.toEpochMilli());
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_secondCallInitializesProject.
@Test
public void testMe_secondCallInitializesProject() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
// Simulate FC "Ready".
org.pmiops.workbench.firecloud.model.BillingProjectMembership membership = new org.pmiops.workbench.firecloud.model.BillingProjectMembership();
membership.setCreationStatus(CreationStatusEnum.READY);
membership.setProjectName(BILLING_PROJECT_NAME);
when(fireCloudService.getBillingProjectMemberships()).thenReturn(ImmutableList.of(membership));
profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.READY);
verify(fireCloudService).grantGoogleRoleToUser(BILLING_PROJECT_NAME, FireCloudService.BIGQUERY_JOB_USER_GOOGLE_ROLE, PRIMARY_EMAIL);
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_successDevProjectConflict.
@Test
public void testMe_successDevProjectConflict() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
String projectName = BILLING_PROJECT_PREFIX + PRIMARY_EMAIL.hashCode();
doThrow(new ApiException(HttpStatus.CONFLICT.value(), "conflict")).when(fireCloudService).createAllOfUsBillingProject(projectName);
// When a conflict occurs in dev, log the exception but continue.
assertProfile(profile, PRIMARY_EMAIL, CONTACT_EMAIL, FAMILY_NAME, GIVEN_NAME, DataAccessLevel.UNREGISTERED, TIMESTAMP, projectName, true);
verify(fireCloudService).registerUser(CONTACT_EMAIL, GIVEN_NAME, FAMILY_NAME);
verify(fireCloudService).createAllOfUsBillingProject(projectName);
verify(fireCloudService).addUserToBillingProject(PRIMARY_EMAIL, projectName);
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_success.
@Test
public void testMe_success() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
assertProfile(profile, PRIMARY_EMAIL, CONTACT_EMAIL, FAMILY_NAME, GIVEN_NAME, DataAccessLevel.UNREGISTERED, TIMESTAMP, BILLING_PROJECT_NAME, true);
verify(fireCloudService).registerUser(CONTACT_EMAIL, GIVEN_NAME, FAMILY_NAME);
verify(fireCloudService).createAllOfUsBillingProject(BILLING_PROJECT_NAME);
verify(fireCloudService).addUserToBillingProject(PRIMARY_EMAIL, BILLING_PROJECT_NAME);
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_secondCallErrorsProject.
@Test
public void testMe_secondCallErrorsProject() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
// Simulate FC "Error".
org.pmiops.workbench.firecloud.model.BillingProjectMembership membership = new org.pmiops.workbench.firecloud.model.BillingProjectMembership();
membership.setCreationStatus(CreationStatusEnum.ERROR);
membership.setProjectName(BILLING_PROJECT_NAME);
when(fireCloudService.getBillingProjectMemberships()).thenReturn(ImmutableList.of(membership));
profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.ERROR);
verify(fireCloudService, never()).grantGoogleRoleToUser(any(), any(), any());
}
Aggregations