98. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/18/2017 10:53:33 AM 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.

98.1 Files compared

# Location File Last Modified
1 VSS_5_2_1_2841.zip\vss_svn_backup\core\src\test\java\gov\va\shared\test AbstractTransactionalAppTest.java Wed May 31 15:27:38 2017 UTC
2 VSS_5_2_1_2841.zip\vss_svn_backup\core\src\test\java\gov\va\shared\test AbstractTransactionalAppTest.java Mon Jul 17 19:12:01 2017 UTC

98.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 418
Changed 1 2
Inserted 0 0
Removed 0 0

98.3 Comparison options

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

98.4 Active regular expressions

No regular expressions were active.

98.5 Comparison detail

  1   package go v.va.share d.test;
  2  
  3   import jav a.sql.Conn ection;
  4   import jav a.sql.Prep aredStatem ent;
  5   import jav a.sql.Resu ltSet;
  6   import jav a.sql.SQLE xception;
  7   import jav a.util.Lis t;
  8   import jav a.util.Ran dom;
  9  
  10   import jav ax.annotat ion.Resour ce;
  11   import jav ax.persist ence.Entit yManager;
  12   import jav ax.persist ence.Entit yManagerFa ctory;
  13   import jav ax.persist ence.Persi stenceCont ext;
  14   import jav ax.sql.Dat aSource;
  15  
  16   import org .apache.lo gging.log4 j.core.net .Facility;
  17   import org .junit.Bef ore;
  18   import org .slf4j.Log ger;
  19   import org .slf4j.Log gerFactory ;
  20   import org .springfra mework.bea ns.factory .annotatio n.Autowire d;
  21   import org .springfra mework.bea ns.factory .annotatio n.Qualifie r;
  22   import org .springfra mework.con text.Messa geSource;
  23   import org .springfra mework.dao .DataAcces sException ;
  24   import org .springfra mework.jdb c.core.Pre paredState mentCreato r;
  25   import org .springfra mework.jdb c.core.Res ultSetExtr actor;
  26   import org .springfra mework.sec urity.test .context.s upport.Wit hSecurityC ontextTest ExecutionL istener;
  27   import org .springfra mework.sec urity.test .context.s upport.Wit hUserDetai ls;
  28   import org .springfra mework.tes t.context. TestExecut ionListene rs;
  29   import org .springfra mework.tes t.context. junit4.Abs tractTrans actionalJU nit4Spring ContextTes ts;
  30   import org .springfra mework.tra nsaction.P latformTra nsactionMa nager;
  31   import org .springfra mework.tra nsaction.T ransaction Status;
  32   import org .springfra mework.tra nsaction.s upport.Tra nsactionCa llback;
  33   import org .springfra mework.tra nsaction.s upport.Tra nsactionTe mplate;
  34  
  35   import gov .va.shared .model.App User;
  36   import gov .va.shared .model.Rol e;
  37   import gov .va.shared .model.Rol e.RoleType ;
  38   import gov .va.shared .model.loo kup.sds.VA Facility;
  39   import gov .va.shared .persisten ce.AppUser DAO;
  40   import gov .va.shared .persisten ce.Grantab leRoleDAO;
  41   import gov .va.shared .persisten ce.lookup. RoleDAO;
  42   import gov .va.shared .persisten ce.lookup. sds.Gender DAO;
  43   import gov .va.shared .persisten ce.lookup. sds.VAFaci lityDAO;
  44   import gov .va.shared .persisten ce.lookup. sds.VAFaci lityTypeDA O;
  45   import gov .va.shared .service.A ppUserServ ice;
  46   import gov .va.shared .service.A ppUserTest Service;
  47   import gov .va.shared .service.V AFacilityS ervice;
  48   import gov .va.shared .util.Secu rityUtil;
  49  
  50   /**
  51    * Base cl ass that p rovides co mmon beans  within th e applicat ion contex t for
  52    * integra tion testi ng. The pa rent Sprin g class es tablishes  a transact ion before
  53    * each te st method  and rolls  it back af ter comple tion, to p revent dat abase
  54    * changes  from bein g saved.
  55    * 
  56    * @author  barrycon
  57    * 
  58    */
  59   @TestExecu tionListen ers({ With SecurityCo ntextTestE xecutionLi stener.cla ss })
  60   public abs tract clas s Abstract Transactio nalAppTest  extends A bstractTra nsactional JUnit4Spri ngContextT ests {
  61           pr ivate stat ic final L ogger log  = LoggerFa ctory.getL ogger(Abst ractTransa ctionalApp Test.class );
  62  
  63           pr otected st atic final  String UN IT_TEST_US ER = "VHAC ISSVSSTEST 1";
  64           pu blic stati c final St ring TEST_ STATION_NU MBER = "44 2";
  65  
  66           //  --------- ---------- ----------  Shared Fi elds
  67  
  68           @A utowired
  69           pr otected Da taSource d ataSource;
  70           @P ersistence Context
  71           pr otected En tityManage r em;
  72           @R esource
  73           pr otected En tityManage rFactory e mFactory;
  74           @A utowired
  75           @Q ualifier(" transactio nManager")
  76           pr otected Pl atformTran sactionMan ager tm;
  77  
  78           //  DAOs
  79           @A utowired
  80           pr otected Ap pUserDAO a ppUserDAO;
  81           @A utowired
  82           pr otected Ge nderDAO ge nderDAO;
  83           @A utowired
  84           pr otected Gr antableRol eDAO grant ableRoleDA O;
  85           @A utowired
  86           pr otected Ro leDAO role DAO;
  87           @A utowired
  88           pr otected VA FacilityDA O vaFacili tyDAO;
  89           @A utowired
  90           pr otected VA FacilityTy peDAO vaFa cilityType DAO;
  91           @A utowired
  92           pr otected VA FacilitySe rvice vaFa cilityServ ice;
  93  
  94           //  Services
  95           @A utowired
  96           pr otected Ap pUserServi ce appUser Service;
  97           @A utowired
  98           pr otected Ap pUserTestS ervice app UserTestSe rvice;
  99           @A utowired
  100           pr otected Me ssageSourc e messageS ource;
  101  
  102           //  --------- ---------- ---------- ---- Test  Data
  103  
  104           pr otected Ra ndom rando m = new Ra ndom();
  105  
  106           pr otected Ap pUser user ;
  107  
  108           //  --------- ---------- ---------- ---- Test  Methods
  109  
  110           @B efore
  111           @W ithUserDet ails(UNIT_ TEST_USER)
  112           pu blic void  login() th rows Excep tion {
  113                    Syst em.out.pri ntln("Logg ed in as m ock user "  + UNIT_TE ST_USER);
  114                    user  = appUser DAO.findBy Username(U NIT_TEST_U SER, false );
  115           }
  116  
  117           pr otected Ap pUser crea teTestUser () {
  118                    retu rn recreat eDummyPers istentNati onalAdminU ser(appUse rDAO, role DAO, appUs erTestServ ice, tm);
  119           }
  120  
  121           st atic AppUs er recreat eDummyPers istentNati onalAdminU ser(final  AppUserDAO  appUserDA O, final R oleDAO rol eDAO,
  122                             final  AppUserTes tService a ppUserServ ice, final  PlatformT ransaction Manager tm ) {
  123                    AppU ser persis tentUser =  new Trans actionTemp late(tm).e xecute(new  Transacti onCallback <AppUser>( ) {
  124                             public  AppUser d oInTransac tion(Trans actionStat us ts) {
  125                                      String u sername =  SecurityUt il.getCurr entUserNam e();
  126                                      appUserS ervice.del eteIfExist s(username );
  127                                      AppUser  user = new  AppUser(u sername);
  128  
  129                                      Role rol e = roleDA O.findByLo okup(RoleT ype.NATION AL_ADMIN);
  130                                      user.add GlobalRole (role);
  131  
  132                                       user.setEm ail(" PII                     ");
  133                                      user.set LastName(" CISS1");
  134                                      user.set FirstName( "UnitTest" );
  135                                      user = a ppUserDAO. saveOrUpda te(user);
  136                                      return u ser;
  137                             }
  138                    });
  139                    retu rn persist entUser;
  140           }
  141  
  142           //  --------- ---------- ----------  Utility M ethods
  143  
  144           pr otected VA Facility g etVAFacili ty() {
  145                    retu rn vaFacil ityDAO.fin dByStation Number(TES T_STATION_ NUMBER);
  146           }
  147           
  148           pr otected sy nchronized  VAFacilit y createNe wVAFacilit y(String n ame) {
  149                    fina l String I NSERT_SQL  = "insert  into sdsad m.std_inst itution(id , name, vi staName, s tationNumb er, facili tyType_id, "
  150                                      + " mfn_ zeg_recipi ent, versi on, create d, created By) select  max(f.id)  + 1," //
  151                                      + " ?, ? , ?, max(c .id), 0, 0 , current_ timestamp,  'UnitTest '" //
  152                                      + " from  sdsadm.st d_institut ion f, sds adm.std_fa cilitytype  c" //
  153                                      + " wher e c.code =  'CBOC'";
  154  
  155                    jdbc Template.u pdate(new  PreparedSt atementCre ator() {
  156                             public  PreparedS tatement c reatePrepa redStateme nt(Connect ion connec tion) thro ws SQLExce ption {
  157                                      Prepared Statement  ps = conne ction.prep areStateme nt(INSERT_ SQL, new S tring[] {  "id" });
  158                                      ps.setSt ring(1, na me);
  159                                      ps.setSt ring(2, na me);
  160                                      ps.setSt ring(3, na me);
  161                                      return p s;
  162                             }
  163                    });
  164  
  165                    Long  newId = j dbcTemplat e.query("s elect max( id) from s dsadm.std_ institutio n", new Re sultSetExt ractor<Lon g>() {
  166                             @Overr ide
  167                             public  Long extr actData(Re sultSet rs ) throws S QLExceptio n, DataAcc essExcepti on {
  168                                      rs.next( );
  169                                      return r s.getLong( 1);
  170                             }
  171                    });
  172  
  173                    retu rn vaFacil ityDAO.fin dRequiredB yPrimaryKe y(newId);
  174           }
  175  
  176           @S uppressWar nings("unc hecked")
  177           pr otected Li st<Object[ ]> querySQ L(String s ql) {
  178                    retu rn em.crea teNativeQu ery(sql).g etResultLi st();
  179           }
  180  
  181           pr otected in t executeS QL(String  sql) {
  182                    retu rn em.crea teNativeQu ery(sql).e xecuteUpda te();
  183           }
  184  
  185           pr otected vo id dumpTab le(String  table) {
  186                    dump Table(tabl e, null);
  187           }
  188  
  189           pr otected vo id dumpTab le(String  table, Str ing custom SQL) {
  190                    List <Object[]>  resultLis t = queryS QL(customS QL != null  ? customS QL : "sele ct * from  " + table) ;
  191                    for  (Object[]  row : resu ltList) {
  192                             for (O bject col  : row)
  193                                      System.o ut.print(" \t" + col) ;
  194                             System .out.print ("\n");
  195                    }
  196           }
  197  
  198           /*
  199            *  Generical ly merges  any specif ied item i nto the DB  and immed iately
  200            *  requests  the entity manager to  flush the  change. T his is hel pful while
  201            *  unit test ing DAOs ( but servic e methods  should acc ommodate f lushing as
  202            *  needed)
  203            * /
  204           pr otected <T > T saveAn dFlush(T p 2) {
  205                    T ne wPA = em.m erge(p2);
  206                    em.f lush();
  207                    retu rn newPA;
  208           }
  209  
  210   }