-
Notifications
You must be signed in to change notification settings - Fork 226
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
HTML-715 EnrollInProgramTag to support program attributes from 2.2. #167
base: master
Are you sure you want to change the base?
Conversation
@OpenmrsProfile(openmrsPlatformVersion = "2.2.*") | ||
public class EnrollInPogramTagHandlerSupport2_2 implements EnrollInPogramTagHandlerSupport { | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe javadocs could be added here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure,will add them
|
||
public void setPatientProgrmAttributes(FormEntryContext context, Map<String, String> parameters) { | ||
|
||
if ("true".equalsIgnoreCase(parameters.get("patientprogramattributes"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gitcliff what does the HTML Tag usage look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @ssmusoke i did expand the existing <enrollInProgram/>
tag to add program attributes to a patient already enrolled
|
||
@RunWith(PowerMockRunner.class) | ||
@PrepareForTest(Context.class) | ||
public class EnrollInProgramTagTest2_2 { | ||
|
||
EnrollInProgramElement2_2 element; | ||
|
||
private MockHttpServletRequest request; | ||
|
||
private Map<String, String> parameters; | ||
|
||
|
||
private TextFieldWidget patientprogramattrWidget; | ||
|
||
|
||
@Mock | ||
private FormEntrySession session; | ||
|
||
@Mock | ||
private FormEntryContext context; | ||
|
||
@Mock | ||
private ProgramWorkflowService programWorkflowService; | ||
|
||
@Mock | ||
private PatientService ps; | ||
|
||
@Before | ||
public void setup() { | ||
// Stub services | ||
mockStatic(Context.class); | ||
when(Context.getProgramWorkflowService()).thenReturn(programWorkflowService); | ||
|
||
// Setup html form session context | ||
when(context.getMode()).thenReturn(Mode.ENTER); | ||
request = new MockHttpServletRequest(); | ||
when(session.getContext()).thenReturn(context); | ||
|
||
|
||
// setup condition element | ||
element = spy(new EnrollInProgramElement2_2(context, parameters)); | ||
|
||
} | ||
|
||
@Test | ||
public void enrollInProgram_shouldGetPatientProgrmAttribute() throws Exception { | ||
//set up | ||
when(patientprogramattrWidget.getValue(context, request)).thenReturn("d7477c21-bfc3-4922-9591-e89d8b9c8efb"); | ||
|
||
//replay | ||
element.setPatientProgrmAttributes(context, parameters); | ||
|
||
Assert.assertNotNull( | ||
programWorkflowService.getPatientProgramAttributeByUuid("d7477c21-bfc3-4922-9591-e89d8b9c8efb")); | ||
|
||
//verify | ||
verify(programWorkflowService, times(1)) | ||
.getPatientProgramAttributeByUuid("d7477c21-bfc3-4922-9591-e89d8b9c8efb"); | ||
|
||
} | ||
|
||
@Test | ||
public void enrollInProgram_shouldGetPatientProgrmAttributeWithAnInvalidUuid() throws Exception { | ||
// set up | ||
when(patientprogramattrWidget.getValue(context, request)).thenReturn("sjnjfrjvjnwejnfjsbdladmojervje"); | ||
|
||
// replay | ||
element.setPatientProgrmAttributes(context, parameters); | ||
|
||
Assert.assertNull(programWorkflowService.getPatientProgramAttributeByUuid("sjnjfrjvjnwejnfjsbdladmojervje")); | ||
|
||
} | ||
|
||
@Test | ||
public void handleSubmission_shouldNotCreatePatientProgramAttributeInViewMode() { | ||
// setup | ||
when(context.getMode()).thenReturn(Mode.VIEW); | ||
|
||
// replay | ||
element.handleSubmission(session, request); | ||
|
||
// verify | ||
verify(programWorkflowService, never()) | ||
.getPatientProgramAttributeByUuid("d7477c21-bfc3-4922-9591-e89d8b9c8efb"); | ||
} | ||
|
||
@Test | ||
public void handleSubmission_shouldNotAddPatientProgramAttributeToAPatientWhoIsNull() { | ||
// setup | ||
when(context.getExistingPatient()).thenReturn(null); | ||
|
||
// replay | ||
element.handleSubmission(session, request); | ||
|
||
// verify | ||
verify(ps, never()).savePatient(any(Patient.class)); | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mks-d thanks,,let me adopt that
import org.openmrs.module.htmlformentry.element.EnrollInProgramElement; | ||
|
||
@OpenmrsProfile(openmrsPlatformVersion = "2.2.*") | ||
public class EnrollInPogramTagHandlerSupport2_2 implements EnrollInPogramTagHandlerSupport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo → EnrollInProgramTagHandlerSupport2_2
(the typo is "Pogram
").
7e5133e
to
646c762
Compare
f5e5373
to
b0195ce
Compare
@gitcliff we would like to finish up this work. Can you address the conflicts, and then ask for a reviewer? (You're also welcome to unassign yourself if you have too much other work right now, or ask for help.) |
https://issues.openmrs.org/browse/HTML-715