Skip to content

Commit

Permalink
#813 - fixed ignored test
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Nov 21, 2024
1 parent 6067970 commit c08c11e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.avni.server.dao;

import jakarta.persistence.EntityManager;
import jakarta.persistence.Query;
import org.hibernate.query.sql.internal.NativeQueryImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class GeneralRepository {
private final EntityManager entityManager;

@Autowired
public GeneralRepository(EntityManager entityManager) {
this.entityManager = entityManager;
}

public long execute(String sql) {
Query query = entityManager.createNativeQuery(sql);
NativeQueryImpl nativeQuery = (NativeQueryImpl) query;
return nativeQuery.getResultCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class TransactionDataSyncTest extends AbstractControllerIntegrationTest {
private TestDataSetupService testDataSetupService;
@Autowired
private UserSubjectAssignmentService userSubjectAssignmentService;
@Autowired
private GeneralRepository generalRepository;

private TestDataSetupService.TestOrganisationData organisationData;
private TestDataSetupService.TestCatchmentData catchmentData;
Expand All @@ -74,6 +76,7 @@ public class TransactionDataSyncTest extends AbstractControllerIntegrationTest {
private SubjectType subjectTypeWithNoAccess;
private Program programWithNoAccess;
private GroupRole groupRoleForGroupSubjectTypeWithCatchmentBasedSync;
private GroupRole groupRoleForGroupSubjectTypeWithDirectAssignment;
private Concept conceptForAttributeBasedSync;
private SubjectType subjectTypeWithSyncAttributeBasedSync;
private SubjectType groupSubjectTypeWithSyncAttributeBasedSync;
Expand Down Expand Up @@ -167,6 +170,13 @@ public void setup() {

groupRoleRepository.save(new TestGroupRoleBuilder().withMandatoryFieldsForNewEntity().withGroupSubjectType(groupSubjectTypeForDirectAssignment).withMemberSubjectType(subjectTypeForDirectAssignment).build());

groupRoleForGroupSubjectTypeWithDirectAssignment = groupRoleRepository.save(
new TestGroupRoleBuilder()
.withMandatoryFieldsForNewEntity()
.withGroupSubjectType(groupSubjectTypeForDirectAssignment)
.withMemberSubjectType(subjectTypeForDirectAssignment)
.build());

testGroupService.giveViewSubjectPrivilegeTo(organisationData.getGroup(), subjectTypeWithCatchmentBasedSync, subjectTypeForDirectAssignment, subjectTypeWithSyncAttributeBasedSync, groupSubjectTypeWithSyncAttributeBasedSync, groupSubjectTypeForCatchmentBasedSync, groupSubjectTypeForDirectAssignment);
testGroupService.giveViewProgramPrivilegeTo(organisationData.getGroup(), subjectTypeWithCatchmentBasedSync, programWithCatchmentBasedSync);
testGroupService.giveViewProgramPrivilegeTo(organisationData.getGroup(), subjectTypeForDirectAssignment, programForDirectAssignment);
Expand All @@ -175,7 +185,6 @@ public void setup() {

@Test
@Transactional
@Ignore
public void sync() throws Exception {
// Catchment tx entities
Individual inTheCatchment = testSubjectService.save(new SubjectBuilder().withMandatoryFieldsForNewEntity().withSubjectType(subjectTypeWithCatchmentBasedSync).withLocation(catchmentData.getAddressLevel1()).build());
Expand Down Expand Up @@ -282,7 +291,7 @@ public void sync() throws Exception {
assertTrue(hasEntity(enrolmentAssignedNow, enrolments));
// Group Subject
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());
GroupSubject groupSubjectInDirectAssignment = testGroupSubjectService.save(new TestGroupSubjectBuilder().withGroupRole(groupRoleForGroupSubjectTypeWithDirectAssignment).withMember(assigned).withGroup(assignedGroupSubject).build());
userSubjectAssignmentService.assignSubjects(organisationData.getUser(), Collections.singletonList(assignedGroupSubject), false);

groupSubjects = getGroupSubjects(groupSubjectTypeForDirectAssignment);
Expand Down

0 comments on commit c08c11e

Please sign in to comment.