Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#277 - CSV parser should save cached objects once file has been loaded. #278

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ public void load_shouldLoadPaymentModesAccordingToCsvFiles() {
{
PaymentMode paymentMode = paymentModeService.getByUuid("e168c141-f5fd-4eec-bd3e-633bed1c9606");
assertNotNull(paymentMode);
assertEquals("Paypal", paymentMode.getName());

paymentMode.getAttributeTypes().forEach(attributeType -> {
if (attributeType.getName().equals("Maximum")) {
assertEquals("Numeric", attributeType.getFormat());
assertTrue(attributeType.getRequired());
} else {
assertEquals("Minimum", attributeType.getName());
}
});
assertEquals("Nutrition Cash Item", paymentMode.getName());
Ruhanga marked this conversation as resolved.
Show resolved Hide resolved
}

// Verify edition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uuid, Void/Retire, name, attributes
526bf278-ba81-4436-b867-c2f6641d060a, , Visa card edited,
2b1b9aae-5d35-43dd-9214-3fd370fd7737, true, Bank transfer,
e168c141-f5fd-4eec-bd3e-633bed1c9606, , Paypal, Maximum::Numeric::::True;Minimum
uuid,Void/Retire,name,attributes
526bf278-ba81-4436-b867-c2f6641d060a,,Visa card edited,
2b1b9aae-5d35-43dd-9214-3fd370fd7737,true,Bank transfer,
fd0ff4ff-dec2-47f5-bb19-5c93b400e94c,,Paypal,Maximum::Numeric::::True;Minimum
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public CsvFailingLines process(List<String[]> lines) {
}
}

Context.flushSession();
Context.clearSession();

Ruhanga marked this conversation as resolved.
Show resolved Hide resolved
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.openmrs.module.initializer.api;

import java.util.Arrays;
import java.util.Collections;
import java.util.Locale;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.Concept;
import org.openmrs.ConceptDescription;
import org.openmrs.ConceptName;
import org.openmrs.ProgramWorkflow;
import org.openmrs.ProgramWorkflowState;
Expand Down Expand Up @@ -50,6 +53,7 @@ public void setup() {
{
Concept c = new Concept();
c.setShortName(new ConceptName("Active treatment (initial)", Locale.ENGLISH));
c.setDescriptions(Collections.singleton(new ConceptDescription("Active treatment (initial)", Locale.ENGLISH)));
c.setConceptClass(cs.getConceptClassByName("State"));
c.setDatatype(cs.getConceptDatatypeByName("Text"));
c = cs.saveConcept(c);
Expand Down Expand Up @@ -124,8 +128,8 @@ public void load_shouldLoadProgramWorkflowStatesAccordingToCsvFiles() {
Assert.assertEquals(wf, state.getProgramWorkflow());

Assert.assertEquals(cs.getConceptByName("Active treatment (initial)"), state.getConcept());
Assert.assertEquals("Active treatment (initial)", state.getName());
Assert.assertEquals("Active treatment (initial)", state.getDescription());
Assert.assertEquals("Active treatment (initial)", state.getConcept().getName().getName());
Assert.assertEquals("Active treatment (initial)", state.getConcept().getDescription().getDescription());
Assert.assertFalse(state.isRetired());
Assert.assertTrue(state.getInitial());
Assert.assertFalse(state.getTerminal());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.openmrs.module.initializer.api;

import java.util.Collections;
import java.util.Locale;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.Concept;
import org.openmrs.ConceptDescription;
import org.openmrs.ConceptName;
import org.openmrs.Program;
import org.openmrs.ProgramWorkflow;
Expand Down Expand Up @@ -39,6 +41,8 @@ public static void setupWorkflows(ConceptService cs, ProgramWorkflowService pws)
{
Concept c = new Concept();
c.setShortName(new ConceptName("TB Treatment Status (workflow)", Locale.ENGLISH));
c.setDescriptions(
Collections.singleton(new ConceptDescription("TB Treatment Status (workflow)", Locale.ENGLISH)));
c.setConceptClass(cs.getConceptClassByName("Workflow"));
c.setDatatype(cs.getConceptDatatypeByName("Text"));
c = cs.saveConcept(c);
Expand Down Expand Up @@ -133,8 +137,8 @@ public void load_shouldLoadProgramWorkflowsAccordingToCsvFiles() {
Program prog = pws.getProgramByName("TB Program");
Assert.assertEquals(prog, wf.getProgram());
Assert.assertEquals(cs.getConceptByName("TB Treatment Status (workflow)"), wf.getConcept());
Assert.assertEquals("TB Treatment Status (workflow)", wf.getName());
Assert.assertEquals("TB Treatment Status (workflow)", wf.getDescription());
Assert.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getName().getName());
Assert.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getDescription().getDescription());
Assert.assertFalse(wf.isRetired());
Assert.assertEquals(wf, prog.getWorkflow(wf.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void load_shouldLoadRelationshipTypesAccordingToCsvFiles() {
{
RelationshipType rt = ps.getRelationshipTypeByUuid("c86d9979-b8ac-4d8c-85cf-cc04e7f16315");
Assert.assertNotNull(rt);
Assert.assertEquals("Uncle/Nephew", rt.getName());
Assert.assertEquals("Uncle/Nephew", rt.toString());
Ruhanga marked this conversation as resolved.
Show resolved Hide resolved
Assert.assertEquals("A relationship of an uncle and his nephew", rt.getDescription());
Assert.assertEquals("Uncle", rt.getaIsToB());
Assert.assertEquals("Nephew", rt.getbIsToA());
Expand All @@ -41,7 +41,7 @@ public void load_shouldLoadRelationshipTypesAccordingToCsvFiles() {
{
RelationshipType rt = ps.getRelationshipTypeByUuid("53d8a8f3-0084-4a52-8666-c655f5bd2689");
Assert.assertNotNull(rt);
Assert.assertEquals("Supervisor/Supervisee", rt.getName());
Assert.assertEquals("Supervisor/Supervisee", rt.toString());
Ruhanga marked this conversation as resolved.
Show resolved Hide resolved
Assert.assertEquals("A new description for supervisor to supervisee relationship", rt.getDescription());
}

Expand Down