Пример #1
0
 private NewForm expectedForm(MotherCase motherCase, Flw flw) {
   NewForm expectedForm = new NewForm();
   expectedForm.setDateModified(
       new DateTime(2012, 7, 21, 12, 2, 59, 923, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   expectedForm.setFullName(
       "गायत्री देवी");
   expectedForm.setHusbandName(
       "दिनेश मुखिया");
   expectedForm.setHhNumber(165);
   expectedForm.setFamilyNumber(5);
   expectedForm.setDobKnown("no");
   expectedForm.setCaste("other");
   expectedForm.setAgeCalc(null);
   expectedForm.setInstanceId("e34707f8-80c8-4198-bf99-c11c90ba5c98");
   expectedForm.setMotherCase(motherCase);
   expectedForm.setFlw(flw);
   expectedForm.setTimeStart(
       new DateTime(2012, 7, 21, 11, 59, 31, 76, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   expectedForm.setTimeEnd(
       new DateTime(2012, 7, 21, 12, 2, 59, 923, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   return expectedForm;
 }
Пример #2
0
  @Test
  public void shouldNotDeleteEarlierFormIfNewerMotherFormWithSameInstanceIdHasOldDate() {
    NewForm persistedForm = new NewForm();
    persistedForm.setInstanceId("e34707f8-80c8-4198-bf99-c11c90ba5c98");
    final Date oldFormModifiedDate = DateTime.parse("2012-07-20T12:02:59.923+05:30").toDate();
    persistedForm.setServerDateModified(oldFormModifiedDate);
    persistedForm.setDateModified(oldFormModifiedDate);
    template.save(persistedForm);

    final String newFormModifiedOn = "2012-07-10T12:02:59.923+05:30";

    Map<String, String> motherFormValues =
        new HashMap<String, String>() {
          {
            put("caseId", "94d5374f-290e-409f-bc57-86c2e4bcc43f");
            put("dateModified", newFormModifiedOn);
            put("serverDateModified", newFormModifiedOn);
            put("userId", "89fda0284e008d2e0c980fb13fa0e5bb");
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/new");
            put("instanceId", "e34707f8-80c8-4198-bf99-c11c90ba5c98");
          }
        };

    careService.processAndSaveForms(motherFormValues, new ArrayList<Map<String, String>>());

    List<NewForm> newFormsFromDb = template.loadAll(NewForm.class);
    assertEquals(1, newFormsFromDb.size());
    assertEquals(oldFormModifiedDate, newFormsFromDb.get(0).getDateModified());
  }