80. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/31/2017 10:27: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.

80.1 Files compared

# Location File Last Modified
1 VSS_5_1_2542.zip\VSS_5_1_2542\rel_5_1\core\src\test\java\gov\va\shared\test AbstractTransactionalAppTest.java Wed Jan 11 18:44:16 2017 UTC
2 VSS_5_1_2542.zip\VSS_5_1_2542\rel_5_1\core\src\test\java\gov\va\shared\test AbstractTransactionalAppTest.java Fri Jan 13 18:23:16 2017 UTC

80.2 Comparison summary

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

80.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

80.4 Active regular expressions

No regular expressions were active.

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