Skip to content

Commit

Permalink
[JN-1403] basic merge service (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
devonbush authored Oct 10, 2024
1 parent 083d10d commit 80c26d2
Show file tree
Hide file tree
Showing 74 changed files with 1,157 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.SuperuserOnly;
import bio.terra.pearl.api.admin.service.auth.context.PortalStudyEnvAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.AdminUserFactory;
import bio.terra.pearl.core.model.EnvironmentName;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void allMethodsAuthed(TestInfo info) {
@Test
@Transactional
public void populatesNewEnrolleeType(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.live);
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
populateExtService.populateEnrollee(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.context.PortalEnrolleeAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.*;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class EnforcePortalEnrolleePermissionTest extends BaseSpringBootTest {
@Test
@Transactional
public void testEnforceEnrollee(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand All @@ -59,7 +60,7 @@ public void testEnforceEnrollee(TestInfo info) {
@Test
@Transactional
public void testWrongEnvironmentThrows(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand Down Expand Up @@ -87,7 +88,7 @@ public void testWrongEnvironmentThrows(TestInfo info) {
@Test
@Transactional
public void testEnrolleeInDifferentPortalThrows(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand All @@ -113,7 +114,7 @@ public void testEnrolleeInDifferentPortalThrows(TestInfo info) {
@Test
@Transactional
public void testAdminNotInPortal(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand All @@ -140,7 +141,7 @@ public void testAdminNotInPortal(TestInfo info) {
@Test
@Transactional
public void testBasePermAdminInPortal(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand All @@ -163,7 +164,7 @@ public void testBasePermAdminInPortal(TestInfo info) {
@Test
@Transactional
public void testAdminDoesNotHavePermission(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand Down Expand Up @@ -193,7 +194,7 @@ public void testAdminDoesNotHavePermission(TestInfo info) {
@Test
@Transactional
public void testUserInPortalWithPermission(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

String portalShortcode = bundle.getPortal().getShortcode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import static org.hamcrest.Matchers.equalTo;

import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.PortalAdminUserFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeBundle;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
import bio.terra.pearl.core.model.EnvironmentName;
import bio.terra.pearl.core.model.admin.AdminUser;
Expand All @@ -28,13 +30,13 @@ public class EnrolleeExtServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testFindById(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);
AdminUser operator =
portalAdminUserFactory
.buildPersistedWithPortals(getTestName(info), List.of(bundle.getPortal()))
.user();
EnrolleeFactory.EnrolleeBundle enrollee1 =
EnrolleeBundle enrollee1 =
enrolleeFactory.buildWithPortalUser(
getTestName(info), bundle.getPortalEnv(), bundle.getStudyEnv());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import bio.terra.pearl.api.admin.AuthTestUtils;
import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.context.PortalStudyEnvAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.AdminUserFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeAndProxy;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
import bio.terra.pearl.core.factory.participant.FamilyFactory;
import bio.terra.pearl.core.model.EnvironmentName;
Expand Down Expand Up @@ -48,13 +50,13 @@ public void testAuthentication() {
@Transactional
public void testFindRelationsForTargetEnrolleeOnlyInCorrectStudyEnv(TestInfo info) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);
EnrolleeFactory.EnrolleeAndProxy enrolleeAndProxy =
EnrolleeAndProxy enrolleeAndProxy =
enrolleeFactory.buildProxyAndGovernedEnrollee(
getTestName(info), studyEnvBundle.getPortalEnv(), studyEnvBundle.getStudyEnv());

StudyEnvironmentFactory.StudyEnvironmentBundle otherStudyEnv =
StudyEnvironmentBundle otherStudyEnv =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

List<EnrolleeRelation> relations =
Expand Down Expand Up @@ -95,7 +97,7 @@ public void testFindRelationsForTargetEnrolleeOnlyInCorrectStudyEnv(TestInfo inf
@Transactional
public void testCannotCreateBetweenDifferentStudyEnvs(TestInfo info) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);
Enrollee enrollee1 =
enrolleeFactory.buildPersisted(getTestName(info), studyEnvBundle.getStudyEnv());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.AuthUtilService;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.PortalAdminUserFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeBundle;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
import bio.terra.pearl.core.factory.participant.ParticipantTaskFactory;
import bio.terra.pearl.core.model.EnvironmentName;
Expand Down Expand Up @@ -37,16 +39,16 @@ public class ParticipantTaskExtServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testUpdateTasksForSurvey(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);
AdminUser operator =
portalAdminUserFactory
.buildPersistedWithPortals(getTestName(info), List.of(bundle.getPortal()))
.user();
EnrolleeFactory.EnrolleeBundle enrollee1 =
EnrolleeBundle enrollee1 =
enrolleeFactory.buildWithPortalUser(
getTestName(info), bundle.getPortalEnv(), bundle.getStudyEnv());
EnrolleeFactory.EnrolleeBundle enrollee2 =
EnrolleeBundle enrollee2 =
enrolleeFactory.buildWithPortalUser(
getTestName(info), bundle.getPortalEnv(), bundle.getStudyEnv());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import bio.terra.pearl.api.admin.AuthTestUtils;
import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.context.PortalStudyEnvAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.AdminUserFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
Expand Down Expand Up @@ -63,9 +64,9 @@ public void testAuthentication() {
@Transactional
public void testFindOnlyInCorrectStudyEnv(TestInfo info) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);
StudyEnvironmentFactory.StudyEnvironmentBundle otherBundle =
StudyEnvironmentBundle otherBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

StudyEnvironment studyEnv = bundle.getStudyEnv();
Expand Down Expand Up @@ -129,7 +130,7 @@ public void testFindOnlyInCorrectStudyEnv(TestInfo info) {
@Transactional
public void testAddMemberOnlyInCorrectStudyEnv(TestInfo info) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

Enrollee enrollee =
Expand Down Expand Up @@ -170,7 +171,7 @@ public void testAddMemberOnlyInCorrectStudyEnv(TestInfo info) {
@Transactional
public void createAlsoAddsProbandToFamily(TestInfo info) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(info), true);
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.sandbox);

Enrollee enrollee =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import bio.terra.pearl.api.admin.service.auth.SandboxOnly;
import bio.terra.pearl.api.admin.service.auth.context.PortalAuthContext;
import bio.terra.pearl.api.admin.service.auth.context.PortalStudyEnvAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.AdminUserBundle;
import bio.terra.pearl.core.factory.admin.AdminUserFactory;
Expand Down Expand Up @@ -97,7 +98,7 @@ public void getRequiresSurveyMatchedToPortal(TestInfo info) {
@Transactional
public void replaceStudyEnvSurvey(TestInfo testInfo) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(testInfo), true);
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);
Survey survey1 = surveyFactory.buildPersisted(getTestName(testInfo));
Survey survey2 = surveyService.createNewVersion(bundle.getPortal().getId(), survey1);
Expand Down Expand Up @@ -133,7 +134,7 @@ public void replaceStudyEnvSurvey(TestInfo testInfo) {
@Transactional
public void updateConfiguredSurveys(TestInfo testInfo) {
AdminUser operator = adminUserFactory.buildPersisted(getTestName(testInfo), true);
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);
Survey survey1 =
surveyFactory.buildPersisted(getTestName(testInfo), bundle.getPortal().getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.core.factory.notification.TriggerFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeBundle;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
import bio.terra.pearl.core.model.EnvironmentName;
import bio.terra.pearl.core.model.admin.AdminUser;
Expand Down Expand Up @@ -43,8 +44,7 @@ public class NotificationExtServiceTests extends BaseSpringBootTest {
@Transactional
public void testSendAdHocNotification(TestInfo info) throws Exception {
AdminUser user = AdminUser.builder().superuser(true).build();
EnrolleeFactory.EnrolleeBundle enrolleeBundle =
enrolleeFactory.buildWithPortalUser(getTestName(info));
EnrolleeBundle enrolleeBundle = enrolleeFactory.buildWithPortalUser(getTestName(info));
Portal portal = portalService.find(enrolleeBundle.portalId()).get();
Study study =
studyService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.notification.NotificationFactory;
import bio.terra.pearl.core.factory.notification.TriggerFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeBundle;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
import bio.terra.pearl.core.factory.portal.PortalEnvironmentFactory;
import bio.terra.pearl.core.model.notification.*;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void testCorrelationSingleEvent(TestInfo info) {
PortalEnvironment portalEnv = portalEnvironmentFactory.buildPersisted(getTestName(info));
StudyEnvironment studyEnv =
studyEnvironmentFactory.buildPersisted(portalEnv, getTestName(info));
EnrolleeFactory.EnrolleeBundle enrolleeBundle =
EnrolleeBundle enrolleeBundle =
enrolleeFactory.buildWithPortalUser(getTestName(info), portalEnv, studyEnv);

Trigger trigger =
Expand Down Expand Up @@ -88,7 +89,7 @@ public void testCorrelationBatchedEvents(TestInfo info) {
PortalEnvironment portalEnv = portalEnvironmentFactory.buildPersisted(getTestName(info));
StudyEnvironment studyEnv =
studyEnvironmentFactory.buildPersisted(portalEnv, getTestName(info));
EnrolleeFactory.EnrolleeBundle enrolleeBundle =
EnrolleeBundle enrolleeBundle =
enrolleeFactory.buildWithPortalUser(getTestName(info), portalEnv, studyEnv);

Trigger trigger =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.context.PortalStudyEnvAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.notification.NotificationFactory;
import bio.terra.pearl.core.factory.notification.TriggerFactory;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class TriggerExtServiceTests extends BaseSpringBootTest {
@Test
@Transactional
public void testNotificationConfigReplace(TestInfo testInfo) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);
Trigger oldConfig =
triggerFactory.buildPersisted(
Expand Down Expand Up @@ -75,7 +76,7 @@ public void testNotificationConfigReplace(TestInfo testInfo) {
@Test
@Transactional
public void testDeleteNotificationConfigNotFound(TestInfo testInfo) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);

AdminUser user = AdminUser.builder().superuser(true).build();
Expand All @@ -95,7 +96,7 @@ public void testDeleteNotificationConfigNotFound(TestInfo testInfo) {
@Test
@Transactional
public void testDeleteNotificationConfigMustBeAuthenticated(TestInfo testInfo) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);

Trigger config =
Expand Down Expand Up @@ -128,7 +129,7 @@ public void testDeleteNotificationConfigMustBeAuthenticated(TestInfo testInfo) {
@Test
@Transactional
public void testDeleteNotificationConfig(TestInfo testInfo) {
StudyEnvironmentFactory.StudyEnvironmentBundle bundle =
StudyEnvironmentBundle bundle =
studyEnvironmentFactory.buildBundle(getTestName(testInfo), EnvironmentName.sandbox);

Trigger config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import bio.terra.pearl.api.admin.AuthTestUtils;
import bio.terra.pearl.api.admin.BaseSpringBootTest;
import bio.terra.pearl.api.admin.service.auth.context.PortalEnrolleeAuthContext;
import bio.terra.pearl.core.factory.StudyEnvironmentBundle;
import bio.terra.pearl.core.factory.StudyEnvironmentFactory;
import bio.terra.pearl.core.factory.admin.AdminUserFactory;
import bio.terra.pearl.core.factory.participant.EnrolleeFactory;
Expand Down Expand Up @@ -44,7 +45,7 @@ public void testAllAuthenticated() {
@Test
@Transactional
public void testUpdateProfileForEnrolleeFailsIfAdminNotInPortal(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee enrollee =
Expand All @@ -71,7 +72,7 @@ public void testUpdateProfileForEnrolleeFailsIfAdminNotInPortal(TestInfo info) {
@Test
@Transactional
public void testUpdateProfileForEnrolleeFailsIfEnrolleeNotInPortal(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee wrongStudyEnv = enrolleeFactory.buildPersisted(getTestName(info));
Expand All @@ -96,7 +97,7 @@ public void testUpdateProfileForEnrolleeFailsIfEnrolleeNotInPortal(TestInfo info
@Test
@Transactional
public void testUpdateProfileForEnrolleeFailsIfWrongEnvironment(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee enrollee =
Expand All @@ -123,7 +124,7 @@ public void testUpdateProfileForEnrolleeFailsIfWrongEnvironment(TestInfo info) {
@Test
@Transactional
public void testUpdateProfileForEnrolleeDoesNotUpdateWrongProfile(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee enrollee =
Expand All @@ -132,7 +133,7 @@ public void testUpdateProfileForEnrolleeDoesNotUpdateWrongProfile(TestInfo info)
studyEnvBundle.getStudyEnv(),
Profile.builder().mailingAddress(MailingAddress.builder().build()).build());

StudyEnvironmentFactory.StudyEnvironmentBundle wrongStudyEnvBundle =
StudyEnvironmentBundle wrongStudyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee wrongStudyEnv =
Expand Down Expand Up @@ -184,7 +185,7 @@ public void testUpdateProfileForEnrolleeDoesNotUpdateWrongProfile(TestInfo info)
@Test
@Transactional
public void testUpdateProfileForEnrollee(TestInfo info) {
StudyEnvironmentFactory.StudyEnvironmentBundle studyEnvBundle =
StudyEnvironmentBundle studyEnvBundle =
studyEnvironmentFactory.buildBundle(getTestName(info), EnvironmentName.irb);

Enrollee enrollee =
Expand Down
Loading

0 comments on commit 80c26d2

Please sign in to comment.