-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1185 - supporting classes for the integration test for report cards.
- Loading branch information
1 parent
e72ae6c
commit 8c89012
Showing
12 changed files
with
166 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/openchs-android/integrationTest/ReportCardServiceIntegrationTest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import BaseIntegrationTest from "./BaseIntegrationTest"; | ||
import { | ||
EntityApprovalStatus, | ||
AddressLevel, | ||
Concept, | ||
Form, | ||
StandardReportCardType, | ||
FormElement, | ||
FormElementGroup, | ||
FormMapping, | ||
Gender, | ||
Individual, | ||
OrganisationConfig, | ||
Settings, | ||
SubjectType, | ||
CustomFilter, | ||
ReportCard | ||
} from "openchs-models"; | ||
import TestConceptFactory from "../test/model/TestConceptFactory"; | ||
import TestAddressLevelFactory from "../test/model/TestAddressLevelFactory"; | ||
import TestGenderFactory from "../test/model/TestGenderFactory"; | ||
import TestSettingsFactory from "../test/model/user/TestSettingsFactory"; | ||
import TestSubjectTypeFactory from "../test/model/TestSubjectTypeFactory"; | ||
import TestFormFactory from "../test/model/form/TestFormFactory"; | ||
import TestFormElementGroupFactory from "../test/model/form/TestFormElementGroupFactory"; | ||
import TestFormElementFactory from "../test/model/form/TestFormElementFactory"; | ||
import TestKeyValueFactory from "../test/model/TestKeyValueFactory"; | ||
import TestFormMappingFactory from "../test/model/form/TestFormMappingFactory"; | ||
import TestOrganisationConfigFactory from "../test/model/TestOrganisationConfigFactory"; | ||
import TestSubjectFactory from "../test/model/txn/TestSubjectFactory"; | ||
import TestObsFactory from "../test/model/TestObsFactory"; | ||
import TestEntityApprovalStatusFactory from "../test/model/TestEntityApprovalStatusFactory"; | ||
import ReportCardService from "../src/service/customDashboard/ReportCardService"; | ||
import TestStandardReportCardTypeFactory from "../test/model/reportNDashboard/TestStandardReportCardTypeFactory"; | ||
import TestReportCardFactory from "../test/model/reportNDashboard/TestReportCardFactory"; | ||
import TestDashboardReportRuleInputFactory from "../test/model/reportNDashboard/TestDashboardReportRuleInputFactory"; | ||
import TestDashboardReportFilterRuleInputFactory from "../test/model/reportNDashboard/TestDashboardReportFilterRuleInputFactory"; | ||
|
||
class ReportCardServiceIntegrationTest extends BaseIntegrationTest { | ||
approvedCard; subjectType; | ||
|
||
setup() { | ||
super.setup(); | ||
this.executeInWrite((db) => { | ||
this.concept = db.create(Concept, TestConceptFactory.createWithDefaults({dataType: Concept.dataType.Text})); | ||
this.addressLevel = db.create(AddressLevel, TestAddressLevelFactory.createWithDefaults({level: 1})); | ||
this.gender = db.create(Gender, TestGenderFactory.createWithDefaults({name: "Male"})); | ||
db.create(Settings, TestSettingsFactory.createWithDefaults({})); | ||
|
||
this.subjectType = db.create(SubjectType, TestSubjectTypeFactory.createWithDefaults({type: SubjectType.types.Person, name: 'Beneficiary'})); | ||
const form = db.create(Form, TestFormFactory.createWithDefaults({formType: Form.formTypes.IndividualProfile})); | ||
const formElementGroup = db.create(FormElementGroup, TestFormElementGroupFactory.create({form: form})); | ||
db.create(FormElement, TestFormElementFactory.create({ | ||
uuid: "FOO", | ||
concept: this.concept, | ||
displayOrder: 1, | ||
formElementGroup: formElementGroup, | ||
mandatory: true, | ||
keyValues: [TestKeyValueFactory.create({key: "unique", value: "true"})] | ||
})); | ||
db.create(FormMapping, TestFormMappingFactory.createWithDefaults({subjectType: this.subjectType, form: form})); | ||
db.create(OrganisationConfig, TestOrganisationConfigFactory.createWithDefaults({})); | ||
const subject = db.create(Individual, TestSubjectFactory.createWithDefaults({subjectType: this.subjectType, address: this.addressLevel, firstName: "foo", lastName: "bar", observations: [TestObsFactory.create({concept: this.concept, valueJSON: JSON.stringify(this.concept.getValueWrapperFor("ABC"))})]})); | ||
db.create(EntityApprovalStatus, TestEntityApprovalStatusFactory.create({entityType: EntityApprovalStatus.entityType.Subject, entityUUID: subject.uuid, entityTypeUuid: this.subjectType.uuid})); | ||
|
||
const approvedCardType = db.create(StandardReportCardType, TestStandardReportCardTypeFactory.create({name: StandardReportCardType.type.Approved})); | ||
this.approvedCard = db.create(ReportCard, TestReportCardFactory.create({name: "foo", standardReportCardType: approvedCardType})); | ||
}); | ||
} | ||
|
||
getResultForApprovalCardsType() { | ||
const dashboardReportRuleInput = TestDashboardReportRuleInputFactory.create({filterValues: [TestDashboardReportFilterRuleInputFactory.create({type: CustomFilter.type.Concept, filterValue: [this.addressLevel]})]}); | ||
this.getService(ReportCardService).getReportCardCount(this.approvedCard, dashboardReportRuleInput); | ||
} | ||
} | ||
|
||
export default ReportCardServiceIntegrationTest; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/openchs-android/test/model/TestEntityApprovalStatusFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {EntityApprovalStatus} from 'openchs-models'; | ||
import General from "../../src/utility/General"; | ||
|
||
class TestEntityApprovalStatusFactory { | ||
static create({uuid = General.randomUUID(), entityType, entityUUID, entityTypeUuid, statusDateTime = new Date()}) { | ||
const entityApprovalStatus = new EntityApprovalStatus(); | ||
entityApprovalStatus.uuid = uuid; | ||
entityApprovalStatus.entityUUID = entityUUID; | ||
entityApprovalStatus.entityType = entityType; | ||
entityApprovalStatus.entityTypeUuid = entityTypeUuid; | ||
entityApprovalStatus.statusDateTime = statusDateTime; | ||
return entityApprovalStatus; | ||
} | ||
} | ||
|
||
export default TestEntityApprovalStatusFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
.../openchs-android/test/model/reportNDashboard/TestDashboardReportFilterRuleInputFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {DashboardReportFilterRuleInput} from "../../../src/model/DashboardReportRuleInput"; | ||
|
||
class TestDashboardReportFilterRuleInputFactory { | ||
static create({type, dataType, subjectType, groupSubjectTypeFilter, observationBasedFilter, filterValue}) { | ||
const dashboardReportFilterRuleInput = new DashboardReportFilterRuleInput(); | ||
dashboardReportFilterRuleInput.type = type; | ||
dashboardReportFilterRuleInput.dataType = dataType; | ||
dashboardReportFilterRuleInput.subjectType = subjectType; | ||
dashboardReportFilterRuleInput.groupSubjectTypeFilter = groupSubjectTypeFilter; | ||
dashboardReportFilterRuleInput.observationBasedFilter = observationBasedFilter; | ||
dashboardReportFilterRuleInput.filterValue = filterValue; | ||
return dashboardReportFilterRuleInput; | ||
} | ||
} | ||
|
||
export default TestDashboardReportFilterRuleInputFactory; |
11 changes: 11 additions & 0 deletions
11
packages/openchs-android/test/model/reportNDashboard/TestDashboardReportRuleInputFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import DashboardReportRuleInput from "../../../src/model/DashboardReportRuleInput"; | ||
|
||
class TestDashboardReportRuleInputFactory { | ||
static create({filterValues = []}) { | ||
const dashboardReportRuleInput = new DashboardReportRuleInput(); | ||
dashboardReportRuleInput.filterValues = filterValues; | ||
return dashboardReportRuleInput; | ||
} | ||
} | ||
|
||
export default TestDashboardReportRuleInputFactory; |
15 changes: 15 additions & 0 deletions
15
packages/openchs-android/test/model/reportNDashboard/TestReportCardFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {ReportCard} from 'openchs-models'; | ||
import General from "../../../src/utility/General"; | ||
|
||
class TestReportCardFactory { | ||
static create({uuid = General.randomUUID(), name, standardReportCardType, colour = "red"}) { | ||
const reportCard = new ReportCard(); | ||
reportCard.uuid = uuid; | ||
reportCard.name = name; | ||
reportCard.standardReportCardType = standardReportCardType; | ||
reportCard.colour = colour; | ||
return reportCard; | ||
} | ||
} | ||
|
||
export default TestReportCardFactory; |
13 changes: 13 additions & 0 deletions
13
packages/openchs-android/test/model/reportNDashboard/TestStandardReportCardTypeFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {StandardReportCardType} from 'openchs-models'; | ||
import General from "../../../src/utility/General"; | ||
|
||
class TestStandardReportCardTypeFactory { | ||
static create({name, uuid = General.randomUUID()}) { | ||
const standardReportCardType = new StandardReportCardType(); | ||
standardReportCardType.uuid = uuid; | ||
standardReportCardType.name = name; | ||
return standardReportCardType; | ||
} | ||
} | ||
|
||
export default TestStandardReportCardTypeFactory; |