Search in sources :

Example 1 with VersionedMetadataBundle

use of org.openmrs.module.metadatadeploy.bundle.VersionedMetadataBundle in project openmrs-module-pihcore by PIH.

the class PihCoreActivatorTest method testMetadataBundles.

@Test
public void testMetadataBundles() throws Exception {
    deployService.installBundle(conceptsFromMetadataSharing);
    deployService.installBundle(haitiMetadataBundle);
    // test a few random concepts
    assertThat(MetadataUtils.existing(Concept.class, CommonConcepts.Concepts.YES).getName().getName(), is("Oui"));
    Concept mainActivity = MetadataUtils.existing(Concept.class, SocioEconomicConcepts.Concepts.MAIN_ACTIVITY);
    assertThat(mainActivity.getDatatype().getName(), is("Coded"));
    assertThat(mainActivity.getAnswers().size(), greaterThan(5));
    Concept construct = MetadataUtils.existing(Concept.class, ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_CONSTRUCT);
    assertThat(construct.getUuid(), is(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_CONSTRUCT));
    assertThat(construct.getConceptSets().size(), is(3));
    construct = MetadataUtils.existing(Concept.class, ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_CONSTRUCT);
    assertThat(construct.getUuid(), is(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_CONSTRUCT));
    assertThat(construct.getConceptSets().size(), is(4));
    // make sure everything installed at the version we expect
    for (Class<? extends MetadataBundle> bundleType : getExpectedBundles(haitiMetadataBundle.getClass())) {
        if (VersionedMetadataBundle.class.isAssignableFrom(bundleType)) {
            VersionedMetadataBundle bundle = (VersionedMetadataBundle) Context.getRegisteredComponents(bundleType).get(0);
            String gpValue = administrationService.getGlobalProperty("metadatadeploy.bundle.version." + bundle.getClass().getName());
            assertThat(gpValue, is("" + bundle.getVersion()));
        }
    }
}
Also used : Concept(org.openmrs.Concept) VersionedMetadataBundle(org.openmrs.module.metadatadeploy.bundle.VersionedMetadataBundle) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Concept (org.openmrs.Concept)1 VersionedMetadataBundle (org.openmrs.module.metadatadeploy.bundle.VersionedMetadataBundle)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1