Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4869

Should not be able to set birth or death dates later than present date

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.1.0
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      Description

      In Person.java there is an instance in which a Person can have a birthdate or deathdate set to a date that has not yet occurred. This leaves room for user error and should throw an exception. The follow tests below fail and exploit the bug:

      /**
       * Tests if you can set a user's birthday to a date that has not yet occured. This test passed,
       * thus this is an issue.  
       *
       * @throws Exception
       */
      @Test(expected = APIException.class)
      @Verifies(value = "should throw APIException if birthdate is set after present date", method = "setBirthdate(Date)")
      public void setBirthdayToFuture() throws Exception {
      	
      	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
      	Person p = new Person();
      	
      	Date date = new Date();
      	df.format(date);
      	Date futureDate = new Date(3000, 10, 26);
      	p.setBirthdate(futureDate); //should throw exception here
      }
      
      /**
       * Tests if you can set a user's death date to a date that has not yet occured. This test passed,
       * thus this is an issue.  
       *
       * @throws Exception
       */
      @Test(expected = APIException.class)
      @Verifies(value = "should throw APIException if deathdate is set after present date", method = "setDeathDate(Date)")
      public void setDeathtoFuture() throws Exception {
      	
      	DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
      	Person p = new Person();
      	
      	Date date = new Date();
      	df.format(date);
      	Date futureDate = new Date(3000, 10, 26);
      	p.setDeathDate(futureDate); //should throw exception here
      }
      

        Attachments

          Activity

            People

            • Assignee:
              sashu2014 Sam Shuster
              Reporter:
              dkayiwa Daniel Kayiwa
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h