Produced by Araxis Merge on 12/13/2018 10:35:36 AM Eastern Standard 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 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\test\java\gov\va\med\ccht\persistent\hibernate | SecurityDAOIntTest.java | Fri Dec 7 17:36:42 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\test\java\gov\va\med\ccht\persistent\hibernate | SecurityDAOIntTest.java | Wed Dec 12 22:14:53 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 436 |
| Changed | 2 | 6 |
| Inserted | 0 | 0 |
| 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 | /*package gov.va.med .ccht.pers istent.hib ernate; | |
| 2 | ||
| 3 | import sta tic org.ju nit.Assert .assertEqu als; | |
| 4 | import sta tic org.ju nit.Assert .assertFal se; | |
| 5 | import sta tic org.ju nit.Assert .assertNot Null; | |
| 6 | import sta tic org.ju nit.Assert .assertNul l; | |
| 7 | import sta tic org.ju nit.Assert .assertTru e; | |
| 8 | ||
| 9 | import jav a.util.Arr ayList; | |
| 10 | import jav a.util.Cal endar; | |
| 11 | import jav a.util.Dat e; | |
| 12 | import jav a.util.Has hSet; | |
| 13 | import jav a.util.Lis t; | |
| 14 | import jav a.util.Map ; | |
| 15 | import jav a.util.Set ; | |
| 16 | ||
| 17 | import org .junit.Aft er; | |
| 18 | import org .junit.Bef ore; | |
| 19 | import org .junit.Tes t; | |
| 20 | import org .junit.run ner.RunWit h; | |
| 21 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 22 | import org .springfra mework.tes t.context. ContextCon figuration ; | |
| 23 | import org .springfra mework.tes t.context. junit4.Spr ingJUnit4C lassRunner ; | |
| 24 | ||
| 25 | import gov .va.med.cc ht.model.S impleUser; | |
| 26 | import gov .va.med.cc ht.model.U ser; | |
| 27 | import gov .va.med.cc ht.model.t erminology .Registrat ionStatus; | |
| 28 | import gov .va.med.cc ht.persist ent.Securi tyDAO; | |
| 29 | import gov .va.med.fw .model.lda p.SearchCr iteria; | |
| 30 | import gov .va.med.fw .persisten t.DAOExcep tion; | |
| 31 | import gov .va.med.fw .security. Permission ; | |
| 32 | import gov .va.med.fw .security. Role; | |
| 33 | import gov .va.med.fw .security. SimpleRole ; | |
| 34 | import gov .va.med.fw .security. UserPrinci pal; | |
| 35 | ||
| 36 | @ContextCo nfiguratio n(location s = "class path:appli cation-con text-test. xml") | |
| 37 | @RunWith(S pringJUnit 4ClassRunn er.class) | |
| 38 | public cla ss Securit yDAOIntTes t { | |
| 39 | ||
| 40 | pr ivate stat ic final S tring TEST _PERMISSIO N_NAME = " testPermis sion"; | |
| 41 | pr ivate stat ic final S tring TEST _DESCRIPTI ON = "test Descriptio n"; | |
| 42 | pr ivate stat ic final S tring TEST _ROLE_NAME = "testUs erRole"; | |
| 43 | pr ivate stat ic final S tring TEST _USER_NAME = "testUs er"; | |
| 44 | pr ivate stat ic final D ate TEST_D ATE = Cale ndar.getIn stance().g etTime(); | |
| 45 | ||
| 46 | @A utowired | |
| 47 | Se curityDAO securityDa o; | |
| 48 | ||
| 49 | @B efore | |
| 50 | pu blic void setup() { | |
| 51 | ||
| 52 | } | |
| 53 | ||
| 54 | @A fter | |
| 55 | pu blic void teardown() { | |
| 56 | fina l Role rol e = new Ro le(); | |
| 57 | role .setName(T EST_ROLE_N AME); | |
| 58 | secu rityDao.re move(role) ; | |
| 59 | } | |
| 60 | ||
| 61 | @T est | |
| 62 | pu blic void testDAONot Null() { | |
| 63 | asse rtNotNull( securityDa o); | |
| 64 | } | |
| 65 | ||
| 66 | @T est | |
| 67 | pu blic void testGetUse rByNameNot Empty() th rows DAOEx ception { | |
| 68 | fina l User use r = securi tyDao.getU serByName( "ihtaAdmin "); | |
| 69 | asse rtNotNull( user); | |
| 70 | asse rtEquals(" ihtaadmin" , user.get FirstName( )); | |
| 71 | } | |
| 72 | ||
| 73 | @T est | |
| 74 | pu blic void testGetSub mittedRegi strations( ) { | |
| 75 | fina l List<Use r> regList NoIds = se curityDao. getSubmitt edRegistra tions(null , null); | |
| 76 | asse rtNotNull( regListNoI ds); | |
| 77 | asse rtTrue(reg ListNoIds. size() > 0 ); | |
| 78 | // Assumes that D N S is not ap proved. | |
| 79 | assertTrue (regListNo Ids.contai ns(new Use r(" D N S "))); | |
| 80 | for( int i = 0; i < regLi stNoIds.si ze(); i++) { | |
| 81 | assert True(!regL istNoIds.g et(i).getR egistratio nStatus(). equals(Reg istrationS tatus.APPR OVED)); | |
| 82 | } | |
| 83 | ||
| 84 | fina l List<Use r> regList Fac = secu rityDao.ge tSubmitted Registrati ons(null, new Intege r(1)); | |
| 85 | asse rtNotNull( regListFac ); | |
| 86 | asse rtTrue(reg ListFac.si ze() == 1) ; | |
| 87 | assertTrue (regListFa c.contains (new User( " D N S "))); | |
| 88 | asse rtTrue(!re gListFac.g et(0).getR egistratio nStatus(). equals(Reg istrationS tatus.APPR OVED)); | |
| 89 | } | |
| 90 | ||
| 91 | @T est | |
| 92 | pu blic void testCreate RemoveRole () { | |
| 93 | fina l Role new UserRole = new Role( ); | |
| 94 | newU serRole.se tName(TEST _ROLE_NAME ); | |
| 95 | newU serRole.se tRecordCre atedBy(TES T_USER_NAM E); | |
| 96 | newU serRole.se tRecordCre atedDate(T EST_DATE); | |
| 97 | newU serRole.se tRecordMod ifiedBy(TE ST_USER_NA ME); | |
| 98 | newU serRole.se tRecordMod ifiedDate( TEST_DATE) ; | |
| 99 | newU serRole.se tRecordMod ifiedCount ((short) 1 ); | |
| 100 | secu rityDao.pe rsist(newU serRole); | |
| 101 | fina l Role ret rievedRole = securit yDao.getRo leByName(T EST_ROLE_N AME); | |
| 102 | asse rtNotNull( retrievedR ole); | |
| 103 | asse rtEquals(T EST_ROLE_N AME, retri evedRole.g etName()); | |
| 104 | ||
| 105 | secu rityDao.re move(retri evedRole); | |
| 106 | asse rtNull(sec urityDao.g etRoleByNa me(TEST_RO LE_NAME)); | |
| 107 | } | |
| 108 | ||
| 109 | @T est | |
| 110 | pu blic void testFindUs ersWithAny Role() { | |
| 111 | asse rtEquals(0 , security Dao.findUs ersWithAny Role(new A rrayList<S tring>()). size()); | |
| 112 | fina l List<Str ing> roleL ist = new ArrayList< String>(); | |
| 113 | fina l String r oleName = "Test Role "; | |
| 114 | role List.add(r oleName); | |
| 115 | role List.add(" no role"); | |
| 116 | role List.add(" "); | |
| 117 | fina l Map<Stri ng, UserPr incipal<?> > userMap = security Dao.findUs ersWithAny Role(roleL ist); | |
| 118 | asse rtEquals(1 , userMap. size()); | |
| 119 | asse rtEquals(" testUser", userMap.v alues().it erator().n ext().getU sername()) ; | |
| 120 | } | |
| 121 | ||
| 122 | @T est | |
| 123 | pu blic void testFindAp pUsers() { | |
| 124 | ||
| 125 | fina l SearchCr iteria sc = new Sear chCriteria (); | |
| 126 | sc.s etLastName ("ihtaadmi n"); | |
| 127 | ||
| 128 | try { | |
| 129 | ||
| 130 | final List<Simp leUser> us ers = secu rityDao.fi ndAppUsers (sc); | |
| 131 | assert True(users .size() > 0); | |
| 132 | ||
| 133 | } ca tch (DAOEx ception e) { | |
| 134 | e.prin tStackTrac e(); | |
| 135 | } | |
| 136 | ||
| 137 | } | |
| 138 | ||
| 139 | @T est | |
| 140 | pu blic void testFindAl lSimpleROl es() throw s DAOExcep tion{ | |
| 141 | // N o roles sh ould be Sy stem Admin istrator | |
| 142 | fina l SimpleRo le simpleR ole = new SimpleRole (); | |
| 143 | simp leRole.set Name("Syst em Adminis trator"); | |
| 144 | simp leRole.set Id(new Lon g(2020)); | |
| 145 | fina l List<Sim pleRole> r oleList = securityDa o.findAllS impleRoles (); | |
| 146 | asse rtTrue(rol eList.size () > 0); | |
| 147 | asse rtFalse(ro leList.con tains(simp leRole)); | |
| 148 | } | |
| 149 | ||
| 150 | @T est | |
| 151 | pu blic void testGetSim pleRoleByN ame() thro ws DAOExce ption { | |
| 152 | fina l String r oleName = "Test Role "; | |
| 153 | fina l SimpleRo le expecte dRole = ne w SimpleRo le(); | |
| 154 | expe ctedRole.s etId(new L ong(2028)) ; | |
| 155 | expe ctedRole.s etName(rol eName); | |
| 156 | fina l SimpleRo le actualR ole = secu rityDao.ge tSimpleRol eByName(ro leName); | |
| 157 | asse rtEquals(e xpectedRol e.getName( ), actualR ole.getNam e()); | |
| 158 | asse rtEquals(e xpectedRol e.getId(), actualRol e.getId()) ; | |
| 159 | } | |
| 160 | ||
| 161 | @T est | |
| 162 | pu blic void testGetFed eralHolida ys() throw s DAOExcep tion { | |
| 163 | // M ost years have 10 ho lidays, bu t this isn 't guarant eed | |
| 164 | asse rtEquals(1 0, securit yDao.findH olidays(20 12).size() ); | |
| 165 | // Y ears only go up to a certain p oint right now. | |
| 166 | asse rtEquals(0 , security Dao.findHo lidays(999 9).size()) ; | |
| 167 | } | |
| 168 | ||
| 169 | @T est | |
| 170 | pu blic void testGetUse rIds() thr ows DAOExc eption { | |
| 171 | fina l List<Str ing> userI ds = secur ityDao.get UserIds(); | |
| 172 | asse rtTrue(use rIds.size( ) > 0); | |
| 173 | asse rtTrue(use rIds.conta ins("ihtaa dmin")); | |
| 174 | } | |
| 175 | ||
| 176 | @T est | |
| 177 | pu blic void testGetAud itUser() t hrows DAOE xception { | |
| 178 | fina l UserPrin cipal user = securit yDao.getAu ditUser(TE ST_USER_NA ME); | |
| 179 | asse rtEquals(" test", use r.getFirst Name()); | |
| 180 | asse rtEquals(" test", use r.getLastN ame()); | |
| 181 | } | |
| 182 | ||
| 183 | @T est | |
| 184 | pu blic void testFindAl lPermissio ns() throw s DAOExcep tion { | |
| 185 | asse rtTrue(sec urityDao.f indAllPerm issions(). size() > 0 ); | |
| 186 | } | |
| 187 | ||
| 188 | @T est | |
| 189 | pu blic void testDelete RolePermis sionsFromR ole() thro ws DAOExce ption { | |
| 190 | ||
| 191 | Role testRole = new Role (); | |
| 192 | Perm ission tes tPermissio n = new Pe rmission() ; | |
| 193 | ||
| 194 | Set< Permission > permissi ons = new HashSet<Pe rmission>( ); | |
| 195 | perm issions.ad dAll(secur ityDao.fin dAllPermis sions()); | |
| 196 | ||
| 197 | test Role.setNa me(TEST_RO LE_NAME); | |
| 198 | test Role.setRe cordCreate dDate(TEST _DATE); | |
| 199 | test Role.setRe cordModifi edDate(TES T_DATE); | |
| 200 | test Role.setRe cordModifi edBy(TEST_ USER_NAME) ; | |
| 201 | test Role.setRe cordCreate dBy(TEST_U SER_NAME); | |
| 202 | test Role.setPe rmissions( permission s, TEST_US ER_NAME); | |
| 203 | ||
| 204 | secu rityDao.pe rsist(test Role); | |
| 205 | fina l Role ret rievedRole = securit yDao.getRo leByName(T EST_ROLE_N AME); | |
| 206 | asse rtNotNull( testRole); | |
| 207 | ||
| 208 | asse rtEquals(r etrievedRo le.getPerm issions(). size(), pe rmissions. size()); / / should h ave 1 perm ission | |
| 209 | ||
| 210 | secu rityDao.de leteRolePe rmissionsF romRole(te stRole); | |
| 211 | ||
| 212 | fina l Role ret rievedRole AfterDelet e = securi tyDao.getR oleByName( TEST_ROLE_ NAME); | |
| 213 | ||
| 214 | asse rtEquals(r etrievedRo leAfterDel ete.getPer missions() .size(), 0 ); // shou ld have no permissio ns | |
| 215 | ||
| 216 | secu rityDao.de leteEntity (retrieved RoleAfterD elete); | |
| 217 | } | |
| 218 | ||
| 219 | ||
| 220 | } | |
| 221 | */ |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.