Produced by Araxis Merge on 3/13/2019 2:49:39 PM Central 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 | C:\AraxisMergeCompare\Pri_un\DSM\Direct Implementation\java\dsm-config\dsm-config-service-jar\src\test\java\org\nhindirect\config\resources | DNSResource_updateDNSRecordTest.java | Tue Mar 12 21:58:50 2019 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\DSM-scrubbed\Direct Implementation\java\dsm-config\dsm-config-service-jar\src\test\java\org\nhindirect\config\resources | DNSResource_updateDNSRecordTest.java | Wed Mar 13 02:22:50 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 678 |
| Changed | 4 | 8 |
| 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 or g.nhindire ct.config. resources; | |
| 2 | ||
| 3 | import sta tic org.mo ckito.Matc hers.any; | |
| 4 | import sta tic org.mo ckito.Matc hers.eq; | |
| 5 | import sta tic org.mo ckito.Mock ito.doThro w; | |
| 6 | import sta tic org.mo ckito.Mock ito.mock; | |
| 7 | import sta tic org.mo ckito.Mock ito.when; | |
| 8 | ||
| 9 | import jav a.util.Arr ays; | |
| 10 | import jav a.util.Col lection; | |
| 11 | ||
| 12 | import jav ax.ws.rs.c ore.MediaT ype; | |
| 13 | ||
| 14 | import org .junit.Tes t; | |
| 15 | import org .nhindirec t.config.B aseTestPla n; | |
| 16 | import org .nhindirec t.config.C onfigServi ceRunner; | |
| 17 | ||
| 18 | import org .nhindirec t.config.m odel.DNSRe cord; | |
| 19 | ||
| 20 | import org .nhindirec t.config.m odel.utils .DNSUtils; | |
| 21 | ||
| 22 | import org .nhindirec t.config.r esources.u til.Entity ModelConve rsion; | |
| 23 | import org .nhindirec t.config.s tore.dao.D NSDao; | |
| 24 | ||
| 25 | ||
| 26 | import com .sun.jerse y.api.clie nt.Generic Type; | |
| 27 | import com .sun.jerse y.api.clie nt.Uniform InterfaceE xception; | |
| 28 | import com .sun.jerse y.api.clie nt.WebReso urce; | |
| 29 | ||
| 30 | public cla ss DNSReso urce_updat eDNSRecord Test | |
| 31 | { | |
| 32 | protected DNSDao dn sDao; | |
| 33 | ||
| 34 | stat ic WebReso urce resou rce; | |
| 35 | ||
| 36 | abst ract class TestPlan extends Ba seTestPlan | |
| 37 | { | |
| 38 | protec ted DNSRec ord addedR ecord; | |
| 39 | ||
| 40 | @Overr ide | |
| 41 | protec ted void s etupMocks( ) | |
| 42 | { | |
| 43 | try | |
| 44 | { | |
| 45 | dnsDao = ( DNSDao)Con figService Runner.get SpringAppl icationCon text().get Bean("dnsD ao"); | |
| 46 | ||
| 47 | resource = getR esource(Co nfigServic eRunner.ge tConfigSer viceURL()) ; | |
| 48 | ||
| 49 | } | |
| 50 | catch (T hrowable t ) | |
| 51 | { | |
| 52 | throw new RuntimeExc eption(t); | |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | @Overr ide | |
| 57 | protec ted void t earDownMoc ks() | |
| 58 | { | |
| 59 | ||
| 60 | } | |
| 61 | ||
| 62 | protec ted DNSRec ord getDNS RecordToAd d() | |
| 63 | { | |
| 64 | ||
| 65 | addedRecor d = DNSUti ls.createA Record("my server.com ", 3600, " IP "); | |
| 66 | return a ddedRecord ; | |
| 67 | } | |
| 68 | ||
| 69 | protec ted abstra ct DNSReco rd getReco rdToUpdate (); | |
| 70 | ||
| 71 | @Overr ide | |
| 72 | protec ted void p erformInne r() throws Exception | |
| 73 | { | |
| 74 | ||
| 75 | final DN SRecord ad dRecord = getDNSReco rdToAdd(); | |
| 76 | ||
| 77 | if (addR ecord != n ull) | |
| 78 | { | |
| 79 | try | |
| 80 | { | |
| 81 | re source.pat h("/api/dn s").entity (addRecord , MediaTyp e.APPLICAT ION_JSON). put(); | |
| 82 | } | |
| 83 | catch (Uni formInterf aceExcepti on e) | |
| 84 | { | |
| 85 | th row e; | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | final DN SRecord re cordToUpda te = getRe cordToUpda te(); | |
| 90 | ||
| 91 | try | |
| 92 | { | |
| 93 | resource.p ath("/api/ dns").enti ty(recordT oUpdate, M ediaType.A PPLICATION _JSON).pos t(); | |
| 94 | } | |
| 95 | catch (U niformInte rfaceExcep tion e) | |
| 96 | { | |
| 97 | throw e; | |
| 98 | } | |
| 99 | ||
| 100 | try | |
| 101 | { | |
| 102 | final Gene ricType<Co llection<D NSRecord>> genType = new Gener icType<Col lection<DN SRecord>>( ){}; | |
| 103 | final Coll ection<DNS Record> ge tRecords = resource. path("/api /dns/") | |
| 104 | .que ryParam("n ame", reco rdToUpdate .getName() ).queryPar am("type", Integer.t oString(re cordToUpda te.getType ())).get(g enType); | |
| 105 | ||
| 106 | doAssertio ns(getReco rds); | |
| 107 | } | |
| 108 | catch (U niformInte rfaceExcep tion e) | |
| 109 | { | |
| 110 | throw e; | |
| 111 | } | |
| 112 | ||
| 113 | } | |
| 114 | ||
| 115 | ||
| 116 | protec ted void d oAssertion s(Collecti on<DNSReco rd> record s) throws Exception | |
| 117 | { | |
| 118 | ||
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | @Tes t | |
| 123 | publ ic void te stUpdateDN SRecord_up dateExisti ngRecord_a ssertRecor dUpdated() throws Ex ception | |
| 124 | { | |
| 125 | new Te stPlan() | |
| 126 | { | |
| 127 | protecte d DNSRecor d updatedR ecord; | |
| 128 | ||
| 129 | @Overrid e | |
| 130 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 131 | { | |
| 132 | Collection <org.nhind irect.conf ig.store.D NSRecord> records = dnsDao.get (addedReco rd.getName (), addedR ecord.getT ype()); | |
| 133 | ||
| 134 | // should be one rec ord | |
| 135 | assertEqua ls(1, reco rds.size() ); | |
| 136 | ||
| 137 | org.nhindi rect.confi g.store.DN SRecord re cord = rec ords.itera tor().next (); | |
| 138 | record.set Name("serv er2.com.") ; | |
| 139 | ||
| 140 | updatedRec ord = Enti tyModelCon version.to ModelDNSRe cord(recor d); | |
| 141 | ||
| 142 | return upd atedRecord ; | |
| 143 | } | |
| 144 | ||
| 145 | @Overrid e | |
| 146 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 147 | { | |
| 148 | assertEqua ls(1, reco rds.size() ); | |
| 149 | ||
| 150 | DNSRecord record = r ecords.ite rator().ne xt(); | |
| 151 | ||
| 152 | assertEqua ls("server 2.com.", r ecord.getN ame()); | |
| 153 | assertTrue (Arrays.eq uals(updat edRecord.g etData(), record.get Data())); | |
| 154 | } | |
| 155 | }.perf orm(); | |
| 156 | } | |
| 157 | ||
| 158 | @Tes t | |
| 159 | publ ic void te stUpdateDN SRecord_up dateExisti ngRecord_n oDottedSuf fix_assert RecordUpda ted() thro ws Excepti on | |
| 160 | { | |
| 161 | new Te stPlan() | |
| 162 | { | |
| 163 | protecte d DNSRecor d updatedR ecord; | |
| 164 | ||
| 165 | @Overrid e | |
| 166 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 167 | { | |
| 168 | Collection <org.nhind irect.conf ig.store.D NSRecord> records = dnsDao.get (addedReco rd.getName (), addedR ecord.getT ype()); | |
| 169 | ||
| 170 | // should be one rec ord | |
| 171 | assertEqua ls(1, reco rds.size() ); | |
| 172 | ||
| 173 | org.nhindi rect.confi g.store.DN SRecord re cord = rec ords.itera tor().next (); | |
| 174 | record.set Name("serv er2.com"); | |
| 175 | ||
| 176 | updatedRec ord = Enti tyModelCon version.to ModelDNSRe cord(recor d); | |
| 177 | ||
| 178 | return upd atedRecord ; | |
| 179 | } | |
| 180 | ||
| 181 | @Overrid e | |
| 182 | protecte d void doA ssertions( Collection <DNSRecord > records) throws Ex ception | |
| 183 | { | |
| 184 | assertEqua ls(1, reco rds.size() ); | |
| 185 | ||
| 186 | DNSRecord record = r ecords.ite rator().ne xt(); | |
| 187 | ||
| 188 | assertEqua ls("server 2.com.", r ecord.getN ame()); | |
| 189 | assertTrue (Arrays.eq uals(updat edRecord.g etData(), record.get Data())); | |
| 190 | } | |
| 191 | }.perf orm(); | |
| 192 | } | |
| 193 | ||
| 194 | @Tes t | |
| 195 | publ ic void te stUpdateDN SRecord_re cordDoesnt Exist_asse rtNotFound () throws Exception | |
| 196 | { | |
| 197 | new Te stPlan() | |
| 198 | { | |
| 199 | protecte d DNSRecor d updatedR ecord; | |
| 200 | ||
| 201 | @Overrid e | |
| 202 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 203 | { | |
| 204 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", 3600, " IP "); | |
| 205 | updatedRec ord.setId( 1233); | |
| 206 | return upd atedRecord ; | |
| 207 | } | |
| 208 | ||
| 209 | @Overrid e | |
| 210 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 211 | { | |
| 212 | assertTrue (exception instanceo f UniformI nterfaceEx ception); | |
| 213 | UniformInt erfaceExce ption ex = (UniformI nterfaceEx ception)ex ception; | |
| 214 | assertEqua ls(404, ex .getRespon se().getSt atus()); | |
| 215 | } | |
| 216 | }.perf orm(); | |
| 217 | } | |
| 218 | ||
| 219 | @Tes t | |
| 220 | publ ic void te stUpdateDN SRecord_er rorInLooku p_assertSe rverError( ) throws E xception | |
| 221 | { | |
| 222 | new Te stPlan() | |
| 223 | { | |
| 224 | protecte d DNSRecor d updatedR ecord; | |
| 225 | ||
| 226 | protecte d DNSResou rce dnsSer vice; | |
| 227 | ||
| 228 | @Overrid e | |
| 229 | protecte d void set upMocks() | |
| 230 | { | |
| 231 | try | |
| 232 | { | |
| 233 | su per.setupM ocks(); | |
| 234 | ||
| 235 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 236 | ||
| 237 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 238 | ||
| 239 | do Throw(new RuntimeExc eption()). when(mockD AO).get(eq (1233L)); | |
| 240 | ||
| 241 | dn sService.s etDNSDao(m ockDAO); | |
| 242 | } | |
| 243 | catch (Thr owable t) | |
| 244 | { | |
| 245 | th row new Ru ntimeExcep tion(t); | |
| 246 | } | |
| 247 | } | |
| 248 | ||
| 249 | @Overrid e | |
| 250 | protecte d void tea rDownMocks () | |
| 251 | { | |
| 252 | super.tear DownMocks( ); | |
| 253 | ||
| 254 | dnsService .setDNSDao (dnsDao); | |
| 255 | } | |
| 256 | ||
| 257 | @Overrid e | |
| 258 | protecte d DNSRecor d getDNSRe cordToAdd( ) | |
| 259 | { | |
| 260 | return nul l; | |
| 261 | } | |
| 262 | ||
| 263 | @Overrid e | |
| 264 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 265 | { | |
| 266 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", 3600, " IP "); | |
| 267 | updatedRec ord.setId( 1233); | |
| 268 | return upd atedRecord ; | |
| 269 | } | |
| 270 | ||
| 271 | @Overrid e | |
| 272 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 273 | { | |
| 274 | assertTrue (exception instanceo f UniformI nterfaceEx ception); | |
| 275 | UniformInt erfaceExce ption ex = (UniformI nterfaceEx ception)ex ception; | |
| 276 | assertEqua ls(500, ex .getRespon se().getSt atus()); | |
| 277 | } | |
| 278 | }.perf orm(); | |
| 279 | } | |
| 280 | ||
| 281 | @Tes t | |
| 282 | publ ic void te stUpdateDN SRecord_er rorInUpdat e_assertSe rverError( ) throws E xception | |
| 283 | { | |
| 284 | new Te stPlan() | |
| 285 | { | |
| 286 | protecte d DNSRecor d updatedR ecord; | |
| 287 | ||
| 288 | protecte d DNSResou rce dnsSer vice; | |
| 289 | ||
| 290 | @Overrid e | |
| 291 | protecte d void set upMocks() | |
| 292 | { | |
| 293 | try | |
| 294 | { | |
| 295 | su per.setupM ocks(); | |
| 296 | ||
| 297 | dn sService = (DNSResou rce)Config ServiceRun ner.getSpr ingApplica tionContex t().getBea n("DNSReso urce"); | |
| 298 | ||
| 299 | DN SDao mockD AO = mock( DNSDao.cla ss); | |
| 300 | ||
| 301 | wh en(mockDAO .get(1233L )).thenRet urn(new or g.nhindire ct.config. store.DNSR ecord()); | |
| 302 | do Throw(new RuntimeExc eption()). when(mockD AO).update (eq(1233L) , (org.nhi ndirect.co nfig.store .DNSRecord )any()); | |
| 303 | ||
| 304 | dn sService.s etDNSDao(m ockDAO); | |
| 305 | } | |
| 306 | catch (Thr owable t) | |
| 307 | { | |
| 308 | th row new Ru ntimeExcep tion(t); | |
| 309 | } | |
| 310 | } | |
| 311 | ||
| 312 | @Overrid e | |
| 313 | protecte d void tea rDownMocks () | |
| 314 | { | |
| 315 | super.tear DownMocks( ); | |
| 316 | ||
| 317 | dnsService .setDNSDao (dnsDao); | |
| 318 | } | |
| 319 | ||
| 320 | @Overrid e | |
| 321 | protecte d DNSRecor d getDNSRe cordToAdd( ) | |
| 322 | { | |
| 323 | return nul l; | |
| 324 | } | |
| 325 | ||
| 326 | @Overrid e | |
| 327 | protecte d DNSRecor d getRecor dToUpdate( ) | |
| 328 | { | |
| 329 | updatedRec ord = DNSU tils.creat eARecord(" myserver.c om", 3600, " IP "); | |
| 330 | updatedRec ord.setId( 1233); | |
| 331 | return upd atedRecord ; | |
| 332 | } | |
| 333 | ||
| 334 | @Overrid e | |
| 335 | protecte d void ass ertExcepti on(Excepti on excepti on) throws Exception | |
| 336 | { | |
| 337 | assertTrue (exception instanceo f UniformI nterfaceEx ception); | |
| 338 | UniformInt erfaceExce ption ex = (UniformI nterfaceEx ception)ex ception; | |
| 339 | assertEqua ls(500, ex .getRespon se().getSt atus()); | |
| 340 | } | |
| 341 | }.perf orm(); | |
| 342 | } | |
| 343 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.