Produced by Araxis Merge on 6/9/2017 3:51:09 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:51:09 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-server\src\test\java\gov\va\nvap\server\announce | BatchAnnouncerTest.java | Fri Apr 21 20:03:28 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 252 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /* | |||||
| 2 | * To chan ge this te mplate, ch oose Tools | Templat es | |||||
| 3 | * and ope n the temp late in th e editor. | |||||
| 4 | */ | |||||
| 5 | package go v.va.nvap. server.ann ounce; | |||||
| 6 | ||||||
| 7 | import gov .va.nvap.s erver.anno unce.Annou ncerImpl; | |||||
| 8 | import gov .va.nvap.s erver.anno unce.jpa.A nnouncemen tJpaContro ller; | |||||
| 9 | import gov .va.nvap.s vc.consent mgmt.PIPIn terface; | |||||
| 10 | import gov .va.nvap.s vc.consent mgmt.Polic yInformati onPoint; | |||||
| 11 | import gov .va.nvap.s vc.consent mgmt.jpa.C onsentDire ctiveJpaCo ntroller; | |||||
| 12 | import gov .va.nvap.s vc.consent mgmt.jpa.O rganizatio nsJpaContr oller; | |||||
| 13 | import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce ment; | |||||
| 14 | import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce mentBatchS ummary; | |||||
| 15 | import gov .va.nvap.s vc.consent mgmt.stub. adapter.an nounce.dat a.Announce rInterface ; | |||||
| 16 | import gov .va.nvap.s vc.consent mgmt.stub. data.Organ ization; | |||||
| 17 | ||||||
| 18 | import jav a.util.Arr ayList; | |||||
| 19 | import jav a.util.Col lection; | |||||
| 20 | import jav a.util.Col lections; | |||||
| 21 | import jav a.util.Dat e; | |||||
| 22 | import jav a.util.Lis t; | |||||
| 23 | ||||||
| 24 | import jav ax.persist ence.Entit yManager; | |||||
| 25 | import jav ax.persist ence.Entit yManagerFa ctory; | |||||
| 26 | import jav ax.persist ence.NoRes ultExcepti on; | |||||
| 27 | import jav ax.persist ence.Persi stence; | |||||
| 28 | import jav ax.persist ence.Query ; | |||||
| 29 | ||||||
| 30 | import jun it.framewo rk.Assert; | |||||
| 31 | ||||||
| 32 | import org .junit.Aft er; | |||||
| 33 | import org .junit.Aft erClass; | |||||
| 34 | import org .junit.Bef ore; | |||||
| 35 | import org .junit.Tes t; | |||||
| 36 | ||||||
| 37 | /** | |||||
| 38 | * | |||||
| 39 | * @author vhaislegb erb | |||||
| 40 | */ | |||||
| 41 | public cla ss BatchAn nouncerTes t { | |||||
| 42 | ||||||
| 43 | privat e static E ntityManag erFactory emf = Pers istence.cr eateEntity ManagerFac tory("nwhi n_vap_pip" ); | |||||
| 44 | privat e EntityMa nager em = null; | |||||
| 45 | privat e Announce rInterface patientAn nouncer; | |||||
| 46 | privat e PIPInter face pip; | |||||
| 47 | privat e static S tring batc hId; | |||||
| 48 | privat e static O rganizatio n testOrg; | |||||
| 49 | ||||||
| 50 | @Befor e | |||||
| 51 | public void setU p() throws Exception { | |||||
| 52 | ||||||
| 53 | th is.em = em f.createEn tityManage r(); | |||||
| 54 | pi p = new Po licyInform ationPoint (); | |||||
| 55 | ||||||
| 56 | An nouncement JpaControl ler announ cementCont roller = n ew Announc ementJpaCo ntroller() ; | |||||
| 57 | an nouncement Controller .setEntity Manager(em ); | |||||
| 58 | ||||||
| 59 | an nouncement Controller .setPip(pi p); | |||||
| 60 | ||||||
| 61 | Or ganization sJpaContro ller organ izationCon troller = new Organi zationsJpa Controller (); | |||||
| 62 | or ganization Controller .setEntity Manager(em ); | |||||
| 63 | ||||||
| 64 | Co nsentDirec tiveJpaCon troller co nsentDirec tiveContro ller = new ConsentDi rectiveJpa Controller (); | |||||
| 65 | co nsentDirec tiveContro ller.setEn tityManage r(em); | |||||
| 66 | ||||||
| 67 | pa tientAnnou ncer = new Announcer Impl(); | |||||
| 68 | (( AnnouncerI mpl)patien tAnnouncer ).setPatie ntAnnounce Controller (announcem entControl ler); | |||||
| 69 | ||||||
| 70 | (( PolicyInfo rmationPoi nt)pip).se tOrganizat ionsContro ller(organ izationCon troller); | |||||
| 71 | (( PolicyInfo rmationPoi nt)pip).se tConsentDi rectiveCon troller(co nsentDirec tiveContro ller); | |||||
| 72 | ||||||
| 73 | // add an or ganization to batch announce t o | |||||
| 74 | te stOrg = ge tOrganizat ion("New O rganizatio n 1"); | |||||
| 75 | if (null == testOrg) | |||||
| 76 | { | |||||
| 77 | ||||||
| 78 | Organiza tion org = new Organ ization(); | |||||
| 79 | org.setA ctive('Y') ; | |||||
| 80 | org.setO rgCommunit yIdPrefix( "NEW"); | |||||
| 81 | org.setO rgContact( "ORG CONTA CT"); | |||||
| 82 | org.setO rgDomain(" NEW.ORG.DO MAIN.1"); | |||||
| 83 | org.setO rgName("Ne w Organiza tion 1"); | |||||
| 84 | org.setO rgNumber(" 200NEW"); | |||||
| 85 | org.setO rgOid("2.1 6.840.1.11 3883.3.555 "); | |||||
| 86 | org.setO rgPhoneNum ber("555-5 55-5555"); | |||||
| 87 | ||||||
| 88 | this.em. getTransac tion().beg in(); | |||||
| 89 | pip.stor eOrganizat ion(org); | |||||
| 90 | this.em. getTransac tion().com mit(); | |||||
| 91 | } | |||||
| 92 | ||||||
| 93 | } | |||||
| 94 | ||||||
| 95 | @After | |||||
| 96 | public void tear Down() | |||||
| 97 | { | |||||
| 98 | if ( this.em != null) | |||||
| 99 | { | |||||
| 100 | this.em. close(); | |||||
| 101 | this.em = null; | |||||
| 102 | } | |||||
| 103 | } | |||||
| 104 | ||||||
| 105 | privat e Organiza tion getOr ganization (String or gName) | |||||
| 106 | { | |||||
| 107 | if (null == testOrg) { | |||||
| 108 | Query q = em.creat eNamedQuer y("Organiz ation.find ByOrgName" ); | |||||
| 109 | q.setPar ameter("or gName", or gName); | |||||
| 110 | try | |||||
| 111 | { | |||||
| 112 | Long id = ((Or ganization ) q.getSin gleResult( )).getOrgI d(); | |||||
| 113 | test Org = pip. getOrganiz ationById( id); | |||||
| 114 | } catch (NoResultE xception e ) | |||||
| 115 | { | |||||
| 116 | // t he testOrg hasn't be en created yet. | |||||
| 117 | } | |||||
| 118 | } | |||||
| 119 | re turn testO rg; | |||||
| 120 | } | |||||
| 121 | ||||||
| 122 | @Test | |||||
| 123 | public void test CreateAnno uncementsB atch() { | |||||
| 124 | // This has to be done to start off the te st case. I t is antic ipated tha t | |||||
| 125 | // the GUIs that are t riggering the capabi lity could provide t he Long | |||||
| 126 | // identifie r of the o rganzation that is b eing targe ted, so, t his lookup | |||||
| 127 | // step coul d be repla ced. | |||||
| 128 | Or ganization targetedO rg = getOr ganization ("New Orga nization 1 "); | |||||
| 129 | if (null == targetedOr g) { | |||||
| 130 | Assert.f ail("Expec ted organi zation wit h ORG_ID: 10 does no t exist in persitent store."); | |||||
| 131 | } | |||||
| 132 | ||||||
| 133 | em .getTransa ction().be gin(); | |||||
| 134 | ba tchId = pa tientAnnou ncer.creat eAnnouncem entsBatch( targetedOr g, "testUs er", null, null, fal se); | |||||
| 135 | Co llection<A nnouncemen t> announc ements = p atientAnno uncer.getU nscheduled Announceme ntsByBatch Id(batchId , 2, 0); | |||||
| 136 | fo r (Announc ement anno uncement : announcem ents) { | |||||
| 137 | announce ment.setSc heduledTs( new Date() ); | |||||
| 138 | em.persi st(announc ement); | |||||
| 139 | } | |||||
| 140 | em .getTransa ction().co mmit(); | |||||
| 141 | ||||||
| 142 | As sert.asser tNotNull(a nnouncemen ts); | |||||
| 143 | As sert.asser tTrue(anno uncements. size() == 2); | |||||
| 144 | } | |||||
| 145 | ||||||
| 146 | @Test | |||||
| 147 | public void test GetBatchSu mmary() | |||||
| 148 | { | |||||
| 149 | Li st<String> batchIds = new Arra yList<Stri ng>(); | |||||
| 150 | ba tchIds.add (batchId); | |||||
| 151 | Li st<Announc ementBatch Summary> s ummaries = patientAn nouncer.ge tBatchSumm ary(batchI ds); | |||||
| 152 | As sert.asser tNotNull(s ummaries); | |||||
| 153 | As sert.asser tTrue(summ aries.size () == 1); | |||||
| 154 | As sert.asser tTrue("New Organizat ion 1".equ als(summar ies.get(0) .getTarget Organizati onName())) ; | |||||
| 155 | As sert.asser tTrue(3 == summaries .get(0).ge tBatchSize ()); | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | @Test | |||||
| 159 | public void test GetBatchSu mmaryByDat es() | |||||
| 160 | { | |||||
| 161 | Or ganization targetedO rg = getOr ganization ("New Orga nization 1 "); | |||||
| 162 | An nouncement announcem ent = new Announceme nt(); | |||||
| 163 | an nouncement .setTarget Organizati on(targete dOrg); | |||||
| 164 | an nouncement .setCreate dTs(new Da te()); | |||||
| 165 | an nouncement .setUserId ("SYSTEM") ; | |||||
| 166 | an nouncement .setPatien tConsentDi r(pip.getA ctiveConse ntDirectiv e(Collecti ons.single tonList("1 23457"), p ip.getCons entTypeByN ame("NwHIN Authoriza tion"))); | |||||
| 167 | ||||||
| 168 | th is.em.getT ransaction ().begin() ; | |||||
| 169 | pa tientAnnou ncer.store Announceme nt(announc ement); | |||||
| 170 | th is.em.getT ransaction ().commit( ); | |||||
| 171 | ||||||
| 172 | Li st<Announc ementBatch Summary> s ummaries = patientAn nouncer.ge tBatchSumm aryByDateR ange(null, null); | |||||
| 173 | As sert.asser tNotNull(s ummaries); | |||||
| 174 | As sert.asser tTrue(summ aries.size () == 1); | |||||
| 175 | As sert.asser tTrue("New Organizat ion 1".equ als(summar ies.get(0) .getTarget Organizati onName())) ; | |||||
| 176 | As sert.asser tTrue(3 == summaries .get(0).ge tBatchSize ()); | |||||
| 177 | ||||||
| 178 | Da te createT s = summar ies.get(0) .getCreate dDate(); | |||||
| 179 | // startDate == tomorr ow; it sho uldn't ret urn any su mmaries. | |||||
| 180 | Da te startDa te = new D ate(create Ts.getTime () + 86400 000L); | |||||
| 181 | su mmaries = patientAnn ouncer.get BatchSumma ryByDateRa nge(startD ate, null) ; | |||||
| 182 | As sert.asser tNotNull(s ummaries); | |||||
| 183 | As sert.asser tTrue(summ aries.isEm pty()); | |||||
| 184 | ||||||
| 185 | // should fi nd the sam e as when param == n ull | |||||
| 186 | su mmaries = patientAnn ouncer.get BatchSumma ryByDateRa nge(null, createTs); | |||||
| 187 | As sert.asser tNotNull(s ummaries); | |||||
| 188 | As sert.asser tTrue(summ aries.size () == 1); | |||||
| 189 | As sert.asser tTrue("New Organizat ion 1".equ als(summar ies.get(0) .getTarget Organizati onName())) ; | |||||
| 190 | As sert.asser tTrue(3 == summaries .get(0).ge tBatchSize ()); | |||||
| 191 | ||||||
| 192 | // should fi nd the sam e as when param == n ull | |||||
| 193 | // endDate i s tomorrow | |||||
| 194 | Da te endDate = startDa te; | |||||
| 195 | // startDate is yester day | |||||
| 196 | st artDate = new Date(c reateTs.ge tTime() - 86400000L) ; | |||||
| 197 | su mmaries = patientAnn ouncer.get BatchSumma ryByDateRa nge(startD ate, endDa te); | |||||
| 198 | As sert.asser tNotNull(s ummaries); | |||||
| 199 | As sert.asser tTrue(summ aries.size () == 1); | |||||
| 200 | As sert.asser tTrue("New Organizat ion 1".equ als(summar ies.get(0) .getTarget Organizati onName())) ; | |||||
| 201 | As sert.asser tTrue(3 == summaries .get(0).ge tBatchSize ()); | |||||
| 202 | } | |||||
| 203 | ||||||
| 204 | @Test | |||||
| 205 | public void test RemoveBatc hByBatchId () | |||||
| 206 | { | |||||
| 207 | Li st<String> batchIds = new Arra yList<Stri ng>(); | |||||
| 208 | ba tchIds.add (batchId); | |||||
| 209 | ||||||
| 210 | em .getTransa ction().be gin(); | |||||
| 211 | pa tientAnnou ncer.remov eAnnouncem entBatches (batchIds) ; | |||||
| 212 | em .getTransa ction().co mmit(); | |||||
| 213 | ||||||
| 214 | Co llection<A nnouncemen t> announc ements = p atientAnno uncer.getU nscheduled Announceme ntsByBatch Id(this.ba tchId, 100 0, 0); | |||||
| 215 | As sert.asser tTrue(anno uncements == null || announcem ents.isEmp ty()); | |||||
| 216 | } | |||||
| 217 | ||||||
| 218 | @After Class | |||||
| 219 | public static vo id afterCl ass() thro ws Excepti on | |||||
| 220 | { | |||||
| 221 | En tityManage r em = nul l; | |||||
| 222 | ||||||
| 223 | tr y { | |||||
| 224 | em = emf .createEnt ityManager (); | |||||
| 225 | em.getTr ansaction( ).begin(); | |||||
| 226 | ||||||
| 227 | // delet e all of t he announc ements tha t were add ed during the testin g | |||||
| 228 | Query q = em.creat eQuery("fr om Announc ement a"); | |||||
| 229 | List<Ann ouncement> announcem ents = q.g etResultLi st(); | |||||
| 230 | for(Anno uncement a : announc ements) { | |||||
| 231 | em.r emove(a); | |||||
| 232 | } | |||||
| 233 | ||||||
| 234 | // delet e the new organizati on that wa s added du ring testi ng. | |||||
| 235 | q = em.c reateNamed Query("Org anization. findByOrgN ame"); | |||||
| 236 | q.setPar ameter("or gName", "N ew Organiz ation 1"); | |||||
| 237 | List<Org anization> orgs = q. getResultL ist(); | |||||
| 238 | ||||||
| 239 | for(Orga nization o rg : orgs) | |||||
| 240 | { | |||||
| 241 | em.r emove(org) ; | |||||
| 242 | } | |||||
| 243 | ||||||
| 244 | } finally { | |||||
| 245 | if(em != null) | |||||
| 246 | { | |||||
| 247 | em.g etTransact ion().comm it(); | |||||
| 248 | em.c lose(); | |||||
| 249 | } | |||||
| 250 | } | |||||
| 251 | } | |||||
| 252 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.