@Test public void testUpdateDOB() throws Exception { createLocationData(); Long msisdn = subscriptionHelper.makeNumber(); String childId = "0123456789"; DateTime originalDOB = DateTime.now(); DateTime updatedDOB = originalDOB.minusDays(100); subscriptionHelper.mksub( SubscriptionOrigin.MCTS_IMPORT, originalDOB, SubscriptionPackType.CHILD, msisdn); Subscriber subscriber = subscriberDataService.findByCallingNumber(msisdn); subscriber.setDateOfBirth(originalDOB); MctsChild child = new MctsChild(childId); child.setState(stateDataService.findByCode(21L)); child.setDistrict(districtService.findByStateAndCode(child.getState(), 3L)); subscriber.setChild(child); subscriberDataService.update(subscriber); // this updates the db with the new data (DOB) Reader reader = createUpdateReaderWithHeaders( "1," + childId + ",," + getDateString(updatedDOB) + ",,,,,,,,,,,"); mctsBeneficiaryUpdateService.updateBeneficiaryData(reader); // This query should return the updated subscriber information (but it doesn't...causing the // assert to fail) Subscriber updatedSubscriber = subscriberDataService.findByCallingNumber(msisdn); assertEquals(getDateString(updatedDOB), getDateString(updatedSubscriber.getDateOfBirth())); Subscription updatedSubscription = updatedSubscriber.getActiveAndPendingSubscriptions().iterator().next(); assertEquals(getDateString(updatedDOB), getDateString(updatedSubscription.getStartDate())); assertEquals(SubscriptionStatus.ACTIVE, updatedSubscription.getStatus()); }
private void makeMctsSubscription( MctsBeneficiary beneficiary, DateTime startDate, SubscriptionPackType packType, Long number) { subscriptionHelper.mksub(SubscriptionOrigin.MCTS_IMPORT, startDate, packType, number); Subscriber subscriber = subscriberDataService.findByCallingNumber(number); if (packType == SubscriptionPackType.CHILD) { subscriber.setChild((MctsChild) beneficiary); subscriber.setDateOfBirth(startDate); } else { subscriber.setMother((MctsMother) beneficiary); subscriber.setLastMenstrualPeriod(startDate.minusDays(90)); } subscriberDataService.update(subscriber); }