Skip to content

Commit

Permalink
BAH-3439 | Added birthtime property in the openmrs webservice.rest mo…
Browse files Browse the repository at this point in the history
…dule. (#593)

* Added birthtime property in the openmrs webservice.rest module.

* Override getUpdatableProperties in PersonResource1_10 and add birthtime

* Add testcase for update a person's birthtime.

* BAH-3439 || Move testcase which is for update a person's birthtime to other class.

* BAH-3439 || remove the commented part from PersonController2_2Test.java

* BAH-3439 ||  Add an assertion that the birthtime was updated to the new value

* BAH-3439 ||  Add an assertion that the birthtime was updated to the new value

* BAH-3349 || Change timezone

* BAH-3439 || Added space between methods in PersonController2_2Test.java

* BAH-3439 ||  Add an assertion that the birthtime was updated to the new value

* BAH-3439 ||  Add an updated assertion that the birthtime was updated to the new value.
  • Loading branch information
harshkumar8789 authored Jan 5, 2024
1 parent 2c89d75 commit 417b277
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonResource1_8;

/**
Expand Down Expand Up @@ -46,12 +47,19 @@ public DelegatingResourceDescription getCreatableProperties() {
description.addProperty("birthtime");
return description;
}



/**
* @throws org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties()
*/
@Override
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = super.getUpdatableProperties();
description.addProperty("birthtime");
return description;
}
@Override
public Model getGETModel(Representation rep) {
return addNewProperties(super.getGETModel(rep), rep);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.openmrs.module.webservices.rest.web.v1_0.RestTestConstants2_2;
import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest;

import java.text.SimpleDateFormat;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -75,6 +77,19 @@ public void shouldEditAPerson() throws Exception {
assertTrue(person.isDead());
assertNotNull(person.getCauseOfDeathNonCoded());
}

@Test
public void shouldEditAPersonBirthTime() throws Exception {
Person person = service.getPersonByUuid(getUuid());
assertNull(person.getBirthtime());
String json = "{\"birthtime\": \"1971-02-08T20:20:00.000\"}";
SimpleObject response = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json)));
assertNotNull(response);
Object responsePersonContents = PropertyUtils.getProperty(response, "person");
assertNotNull(person.getBirthtime());
assertNotNull(responsePersonContents);
assertEquals("1971-02-08 08:20:00", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(person.getBirthtime()));
}

@Test
public void shouldCreatePersonWithBirthtime() throws Exception {
Expand Down

0 comments on commit 417b277

Please sign in to comment.