diff --git a/avni-server-api/src/main/java/org/avni/server/service/ChecklistService.java b/avni-server-api/src/main/java/org/avni/server/service/ChecklistService.java index 57aaf2464..36f0e3793 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/ChecklistService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/ChecklistService.java @@ -30,16 +30,6 @@ public Set findChecklistsByIndividual(Individual individual) { return checklistRepository.findByProgramEnrolmentIndividual(individual); } - @Transactional(Transactional.TxType.REQUIRED) - public ChecklistItem findChecklistItem(String checklistUUID, String checklistItemDetailUUID) { - return checklistItemRepository.findByChecklistUuidAndChecklistItemDetailUuid(checklistUUID, checklistItemDetailUUID); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void saveItem(ChecklistItem checklistItem) { - checklistItemRepository.saveEntity(checklistItem); - } - @Override public boolean isScopeEntityChanged(DateTime lastModifiedDateTime, String checklistDetailUuid) { ChecklistDetail checklistDetail = checklistDetailRepository.findByUuid(checklistDetailUuid); diff --git a/avni-server-api/src/main/java/org/avni/server/service/FormMappingService.java b/avni-server-api/src/main/java/org/avni/server/service/FormMappingService.java index 4ff28c8fc..67a22008d 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/FormMappingService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/FormMappingService.java @@ -188,7 +188,6 @@ private void setSubjectTypeIfRequired(FormMapping formMapping, String requestSub formMapping.setSubjectType(subjectType); } - @Transactional(readOnly = true) public LinkedHashMap getAllFormElementsAndDecisionMap(String subjectTypeUUID, String programUUID, String encounterTypeUUID, FormType formType) { return getEntityConceptMap(formMappingRepository.getRequiredFormMapping(subjectTypeUUID, programUUID, encounterTypeUUID, formType), false); } diff --git a/avni-server-api/src/main/java/org/avni/server/service/SubjectSyncResponseBuilderService.java b/avni-server-api/src/main/java/org/avni/server/service/SubjectSyncResponseBuilderService.java index 547036c48..421595a6d 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/SubjectSyncResponseBuilderService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/SubjectSyncResponseBuilderService.java @@ -14,7 +14,6 @@ import java.util.stream.Collectors; @Service -@Transactional public class SubjectSyncResponseBuilderService { private IndividualRepository individualRepository; private ChecklistService checklistService; diff --git a/avni-server-api/src/test/java/org/avni/server/service/OrganisationConfigServiceTest.java b/avni-server-api/src/test/java/org/avni/server/service/OrganisationConfigServiceTest.java index 510e77ffc..2160d86ff 100644 --- a/avni-server-api/src/test/java/org/avni/server/service/OrganisationConfigServiceTest.java +++ b/avni-server-api/src/test/java/org/avni/server/service/OrganisationConfigServiceTest.java @@ -9,11 +9,9 @@ import org.avni.server.domain.UserContext; import org.avni.server.framework.security.UserContextHolder; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import java.util.Optional; @@ -22,11 +20,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith(PowerMockRunner.class) @PrepareForTest({UserContextHolder.class}) @Transactional public class OrganisationConfigServiceTest { - @Test public void shouldRetrieveOptionalObjectFromOrganisationSettings() { OrganisationConfigRepository organisationRepository = mock(OrganisationConfigRepository.class); @@ -49,11 +45,12 @@ public void shouldRetrieveOptionalObjectFromOrganisationSettings() { @Test public void shouldCheckIfMessagingFeatureEnabled() { OrganisationConfigRepository organisationConfigRepository = mock(OrganisationConfigRepository.class); - PowerMockito.mockStatic(UserContextHolder.class); - UserContext userContext = mock(UserContext.class); long organisationId = 25l; - when(userContext.getOrganisationId()).thenReturn(organisationId); - Mockito.when(UserContextHolder.getUserContext()).thenReturn(userContext); + UserContext context = new UserContext(); + Organisation organisation = new Organisation(); + organisation.setId(organisationId); + context.setOrganisation(organisation); + UserContextHolder.create(context); OrganisationConfig organisationConfigWithoutMessagingEnabled = new OrganisationConfig(); organisationConfigWithoutMessagingEnabled.setSettings(new JsonObject()); diff --git a/avni-server-api/src/test/java/org/avni/server/web/TransactionDataSyncTest.java b/avni-server-api/src/test/java/org/avni/server/web/TransactionDataSyncTest.java index cef74519c..83289b8b1 100644 --- a/avni-server-api/src/test/java/org/avni/server/web/TransactionDataSyncTest.java +++ b/avni-server-api/src/test/java/org/avni/server/web/TransactionDataSyncTest.java @@ -2,9 +2,7 @@ import jakarta.transaction.Transactional; import org.avni.server.common.AbstractControllerIntegrationTest; -import org.avni.server.dao.GroupRoleRepository; -import org.avni.server.dao.UserRepository; -import org.avni.server.dao.UserSubjectAssignmentRepository; +import org.avni.server.dao.*; import org.avni.server.dao.sync.SyncEntityName; import org.avni.server.domain.*; import org.avni.server.domain.factory.TestUserSyncSettingsBuilder; @@ -284,7 +282,8 @@ public void sync() throws Exception { Individual assignedGroupSubject = testSubjectService.save(new SubjectBuilder().withMandatoryFieldsForNewEntity().withSubjectType(groupSubjectTypeForDirectAssignment).withLocation(catchmentData.getAddressLevel1()).build()); GroupSubject groupSubjectInDirectAssignment = testGroupSubjectService.save(new TestGroupSubjectBuilder().withGroupRole(groupRoleForGroupSubjectTypeWithCatchmentBasedSync).withMember(assigned).withGroup(assignedGroupSubject).build()); userSubjectAssignmentService.assignSubjects(organisationData.getUser(), Collections.singletonList(assignedGroupSubject), false); - groupSubjects = getGroupSubjects(groupSubjectTypeForCatchmentBasedSync); + + groupSubjects = getGroupSubjects(groupSubjectTypeForDirectAssignment); assertTrue(hasEntity(groupSubjectInDirectAssignment, groupSubjects)); } diff --git a/avni-server-api/src/test/resources/application.properties b/avni-server-api/src/test/resources/application.properties index eaaa29b33..f832fa915 100644 --- a/avni-server-api/src/test/resources/application.properties +++ b/avni-server-api/src/test/resources/application.properties @@ -22,7 +22,7 @@ spring.flyway.baseline-on-migrate=false server.tomcat.accesslog.max-days=90 # JPA, Hibernate and Spring Data -spring.jpa.show-sql=false +spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=none #spring.jpa.properties.jadira.usertype.databaseZone=jvm #spring.jpa.properties.jadira.usertype.javaZone=jvm