|
@@ -1,23 +1,24 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt |
2 |
2 |
|
package org.litesoft.or; |
3 |
3 |
|
|
|
4 |
+ |
import java.io.*; |
|
5 |
+ |
import java.sql.*; |
|
6 |
+ |
import java.util.*; |
|
7 |
+ |
import java.util.Date; |
|
8 |
+ |
|
4 |
9 |
|
import org.junit.*; |
5 |
|
- |
import static org.junit.Assert.*; |
6 |
10 |
|
import org.litesoft.bo.attributes.*; |
7 |
11 |
|
import org.litesoft.db.*; |
8 |
12 |
|
import org.litesoft.orsup.base.*; |
9 |
13 |
|
import org.litesoft.orsup.base.SupplimentedSCD.*; |
10 |
14 |
|
import org.litesoft.orsup.nonpublic.Blob; |
11 |
15 |
|
import org.litesoft.orsup.nonpublic.*; |
12 |
|
- |
import static org.litesoft.orsup.nonpublic.Parts4Blobs.*; |
13 |
16 |
|
import org.litesoft.orsup.selection.*; |
14 |
17 |
|
import org.litesoft.orsup.transact.*; |
15 |
18 |
|
import org.litesoft.util.*; |
16 |
19 |
|
|
17 |
|
- |
import java.io.*; |
18 |
|
- |
import java.sql.*; |
19 |
|
- |
import java.util.*; |
20 |
|
- |
import java.util.Date; |
|
20 |
+ |
import static org.junit.Assert.*; |
|
21 |
+ |
import static org.litesoft.orsup.nonpublic.Parts4Blobs.*; |
21 |
22 |
|
|
22 |
23 |
|
//@SuppressWarnings({"UnnecessaryLocalVariable"}) |
23 |
24 |
|
public class SampleTest |
|
@@ -118,8 +119,7 @@ |
118 |
119 |
|
invoice.setContactedAndResolved( true ); |
119 |
120 |
|
transaction.commit(); |
120 |
121 |
|
|
121 |
|
- |
invoices = mUF.findAll( DBInvoice.class, f.isEqual( DBInvoice.CD_Paid, false ), |
122 |
|
- |
new OrderBy( DBInvoice.CD_Company ) ); |
|
122 |
+ |
invoices = mUF.findAll( DBInvoice.class, f.isEqual( DBInvoice.CD_Paid, false ), new OrderBy( DBInvoice.CD_Company ) ); |
123 |
123 |
|
assertEquals( 2, invoices.size() ); |
124 |
124 |
|
assertInvoice( invoices, 0, "ABC Co", "I03" ); |
125 |
125 |
|
assertInvoice( invoices, 1, "XYZZY", "I01" ); |
|
@@ -296,13 +296,11 @@ |
296 |
296 |
|
return this; |
297 |
297 |
|
} |
298 |
298 |
|
|
299 |
|
- |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
300 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
299 |
+ |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
301 |
300 |
|
{ |
302 |
301 |
|
} |
303 |
302 |
|
|
304 |
|
- |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
305 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
303 |
+ |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
306 |
304 |
|
{ |
307 |
305 |
|
} |
308 |
306 |
|
} |
|
@@ -315,13 +313,11 @@ |
315 |
313 |
|
return this; |
316 |
314 |
|
} |
317 |
315 |
|
|
318 |
|
- |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
319 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
316 |
+ |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
320 |
317 |
|
{ |
321 |
318 |
|
} |
322 |
319 |
|
|
323 |
|
- |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
324 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
320 |
+ |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
325 |
321 |
|
{ |
326 |
322 |
|
} |
327 |
323 |
|
} |
|
@@ -363,13 +359,11 @@ |
363 |
359 |
|
return this; |
364 |
360 |
|
} |
365 |
361 |
|
|
366 |
|
- |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
367 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
362 |
+ |
public void pre_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
368 |
363 |
|
{ |
369 |
364 |
|
} |
370 |
365 |
|
|
371 |
|
- |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, |
372 |
|
- |
Timestamp pTransactionTimeStamp ) |
|
366 |
+ |
public void post_aboutToCommitAugment( PersistentObject<?> pPersistentObject, Timestamp pTransactionTimeStamp ) |
373 |
367 |
|
{ |
374 |
368 |
|
} |
375 |
369 |
|
|
|
@@ -393,8 +387,7 @@ |
393 |
387 |
|
|
394 |
388 |
|
assertEquals( "Invoice.Notes.Text", RO.rInvoice().rNotes().aText ); |
395 |
389 |
|
|
396 |
|
- |
assertEquals( "DBLineItemNames.INSTANCE.Invoice.Notes. --> DBNote", |
397 |
|
- |
RO.rInvoice().rNotes().toString() ); |
|
390 |
+ |
assertEquals( "DBLineItemNames.INSTANCE.Invoice.Notes. --> DBNote", RO.rInvoice().rNotes().toString() ); |
398 |
391 |
|
|
399 |
392 |
|
DBNoteNames names = RO.rInvoice().cNotes(); |
400 |
393 |
|
assertEquals( "cDBNoteNames.INSTANCE", names.toString() ); |
|
@@ -463,8 +456,7 @@ |
463 |
456 |
|
|
464 |
457 |
|
assertEquals( "Name", expectedSSCD.getName(), pActual.getName() ); |
465 |
458 |
|
|
466 |
|
- |
assertEquals( "expected Mutability: " + pActual.getName(), expectedMutability, |
467 |
|
- |
expectedSSCD.getMutability() ); |
|
459 |
+ |
assertEquals( "expected Mutability: " + pActual.getName(), expectedMutability, expectedSSCD.getMutability() ); |
468 |
460 |
|
assertEquals( "expected Form: " + pActual.getName(), expectedForm, expectedSSCD.getForm() ); |
469 |
461 |
|
|
470 |
462 |
|
//noinspection ObjectEquality |
|
@@ -479,8 +471,7 @@ |
479 |
471 |
|
|
480 |
472 |
|
assertLineItemProductCodes( invoiceRO, "Alpha", "Beta", "Omega" ); |
481 |
473 |
|
|
482 |
|
- |
List<DBLineItem> items = |
483 |
|
- |
invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
|
474 |
+ |
List<DBLineItem> items = invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
484 |
475 |
|
|
485 |
476 |
|
Transaction transaction = mUF.createTransaction(); |
486 |
477 |
|
|
|
@@ -510,8 +501,7 @@ |
510 |
501 |
|
|
511 |
502 |
|
assertLineItemProductCodes( invoiceRO, "Alpha", "Beta", "Omega" ); |
512 |
503 |
|
|
513 |
|
- |
List<DBLineItem> items = |
514 |
|
- |
invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
|
504 |
+ |
List<DBLineItem> items = invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
515 |
505 |
|
|
516 |
506 |
|
Transaction transaction = mUF.createTransaction(); |
517 |
507 |
|
|
|
@@ -1118,11 +1108,9 @@ |
1118 |
1108 |
|
|
1119 |
1109 |
|
createInvoiceWithLineItems(); |
1120 |
1110 |
|
|
1121 |
|
- |
DBLineItem itemRO = DataStoreLocator.get().getUnfilteredFinder().findOne( DBLineItem.class, f.isEqual( |
1122 |
|
- |
DBLineItem.CD_ProductCode, "Omega" ) ); |
|
1111 |
+ |
DBLineItem itemRO = DataStoreLocator.get().getUnfilteredFinder().findOne( DBLineItem.class, f.isEqual( DBLineItem.CD_ProductCode, "Omega" ) ); |
1123 |
1112 |
|
assertEquals( "Omega", itemRO.getProductCode() ); |
1124 |
|
- |
DBInvoice invoiceRO = |
1125 |
|
- |
itemRO.getInvoice(); // Lazy load the Invoice from the LineItem (Not in transaction) |
|
1113 |
+ |
DBInvoice invoiceRO = itemRO.getInvoice(); // Lazy load the Invoice from the LineItem (Not in transaction) |
1126 |
1114 |
|
|
1127 |
1115 |
|
assertInvoice( invoiceRO, "XYZZY", "I01" ); |
1128 |
1116 |
|
|
|
@@ -1135,8 +1123,7 @@ |
1135 |
1123 |
|
{ |
1136 |
1124 |
|
DBInvoice invoiceRO = createInvoiceWithLineItems(); |
1137 |
1125 |
|
|
1138 |
|
- |
List<DBLineItem> items = |
1139 |
|
- |
invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
|
1126 |
+ |
List<DBLineItem> items = invoiceRO.getDBLineItemSetForInvoice(); // Lazy load the LineItems from the Invoice (Not in transaction) |
1140 |
1127 |
|
|
1141 |
1128 |
|
try |
1142 |
1129 |
|
{ |
|
@@ -1182,8 +1169,7 @@ |
1182 |
1169 |
|
} |
1183 |
1170 |
|
|
1184 |
1171 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1185 |
|
- |
invoice.addDBLineItemSetForInvoice( |
1186 |
|
- |
item ); // Lazy load the LineItems from the Invoice (In transaction) |
|
1172 |
+ |
invoice.addDBLineItemSetForInvoice( item ); // Lazy load the LineItems from the Invoice (In transaction) |
1187 |
1173 |
|
|
1188 |
1174 |
|
assertLineItemProductCodes( invoice, "Alpha", "Beta", "Omega", "AAA" ); |
1189 |
1175 |
|
|
|
@@ -1220,9 +1206,7 @@ |
1220 |
1206 |
|
return null; |
1221 |
1207 |
|
} |
1222 |
1208 |
|
}; |
1223 |
|
- |
FilterableFinderImpl zFinder = new FilterableFinderImpl( (ORFacilitatorInternalExtension) mUF, |
1224 |
|
- |
mUF.isIncludingImmortalInactives(), |
1225 |
|
- |
zQueryFilterFactory ); |
|
1209 |
+ |
FilterableFinderImpl zFinder = new FilterableFinderImpl( (ORFacilitatorInternalExtension) mUF, mUF.isIncludingImmortalInactives(), zQueryFilterFactory ); |
1226 |
1210 |
|
assertDSRefreshLineItemProductCodes( zFinder, invoiceRO, true, "AAA", "Alpha", "Omega" ); |
1227 |
1211 |
|
|
1228 |
1212 |
|
try |
|
@@ -1261,14 +1245,12 @@ |
1261 |
1245 |
|
return null; |
1262 |
1246 |
|
} |
1263 |
1247 |
|
}; |
1264 |
|
- |
zFinder = new FilterableFinderImpl( (ORFacilitatorInternalExtension) mUF, |
1265 |
|
- |
mUF.isIncludingImmortalInactives(), zQueryFilterFactory ); |
|
1248 |
+ |
zFinder = new FilterableFinderImpl( (ORFacilitatorInternalExtension) mUF, mUF.isIncludingImmortalInactives(), zQueryFilterFactory ); |
1266 |
1249 |
|
assertDSRefreshLineItemProductCodes( zFinder, invoiceRO, true, "AAA", "Beta", "Omega" ); |
1267 |
1250 |
|
|
1268 |
1251 |
|
assertLineItemProductCodeKeys( zFinder, invoiceRO, "AAA", "Beta", "Omega" ); |
1269 |
1252 |
|
|
1270 |
|
- |
WhereClause zWhereClause = |
1271 |
|
- |
WhereClauseFactory.INSTANCE.isAnyOf( DBLineItem.CD_ProductCode, "Alpha", "Omega" ); |
|
1253 |
+ |
WhereClause zWhereClause = WhereClauseFactory.INSTANCE.isAnyOf( DBLineItem.CD_ProductCode, "Alpha", "Omega" ); |
1272 |
1254 |
|
List<DBLineItem> zLineItems = mUF.findAll( DBLineItem.class, zWhereClause ); |
1273 |
1255 |
|
assertLineItemProductCodes( zLineItems, "Alpha", "Omega" ); |
1274 |
1256 |
|
zLineItems = mUF.findAll( DBLineItem.class, WhereClauseFactory.INSTANCE.not( zWhereClause ) ); |
|
@@ -1369,8 +1351,7 @@ |
1369 |
1351 |
|
|
1370 |
1352 |
|
transaction.commit(); |
1371 |
1353 |
|
|
1372 |
|
- |
assertNull( DataStoreLocator.get().getUnfilteredFinder().findOne( DBInvoice.class, |
1373 |
|
- |
invoiceRO.getPersistentObjectUniqueKey() ) ); |
|
1354 |
+ |
assertNull( DataStoreLocator.get().getUnfilteredFinder().findOne( DBInvoice.class, invoiceRO.getPersistentObjectUniqueKey() ) ); |
1374 |
1355 |
|
} |
1375 |
1356 |
|
|
1376 |
1357 |
|
private Transaction createDeleteAugmentedTransaction() |
|
@@ -1545,8 +1526,7 @@ |
1545 |
1526 |
|
assertDSRefreshLineItemProductCodes( invoiceRO, true, "BBB", "Beta", "Omega" ); |
1546 |
1527 |
|
} |
1547 |
1528 |
|
|
1548 |
|
- |
@SuppressWarnings({"unchecked"}) |
1549 |
|
- |
@Test |
|
1529 |
+ |
@SuppressWarnings({"unchecked"}) @Test |
1550 |
1530 |
|
public void testGenericInvoiceLazyLoadSetLineItems() |
1551 |
1531 |
|
throws Exception |
1552 |
1532 |
|
{ |
|
@@ -1596,18 +1576,15 @@ |
1596 |
1576 |
|
|
1597 |
1577 |
|
createInvoiceWithLineItems(); |
1598 |
1578 |
|
|
1599 |
|
- |
DBNote note = DataStoreLocator.get().getUnfilteredFinder().findOne( DBNote.class, f.isEqual( |
1600 |
|
- |
DBNote.CD_Text, "Invoice Note 1" ) ); |
|
1579 |
+ |
DBNote note = DataStoreLocator.get().getUnfilteredFinder().findOne( DBNote.class, f.isEqual( DBNote.CD_Text, "Invoice Note 1" ) ); |
1601 |
1580 |
|
assertNotNull( "No Note Found", note ); |
1602 |
|
- |
DBInvoice invoiceRO = |
1603 |
|
- |
(DBInvoice) note.getOwner(); // Lazy load the Invoice from the Note (Not in transaction) |
|
1581 |
+ |
DBInvoice invoiceRO = (DBInvoice) note.getOwner(); // Lazy load the Invoice from the Note (Not in transaction) |
1604 |
1582 |
|
|
1605 |
1583 |
|
assertInvoice( invoiceRO, "XYZZY", "I01" ); |
1606 |
1584 |
|
|
1607 |
1585 |
|
assertLineItemProductCodes( invoiceRO, "Alpha", "Beta", "Omega" ); |
1608 |
1586 |
|
|
1609 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1610 |
|
- |
"LineItem Note 1" ); |
|
1587 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1611 |
1588 |
|
} |
1612 |
1589 |
|
|
1613 |
1590 |
|
@Test |
|
@@ -1616,8 +1593,7 @@ |
1616 |
1593 |
|
{ |
1617 |
1594 |
|
DBInvoice invoiceRO = createInvoiceWithLineItems(); |
1618 |
1595 |
|
|
1619 |
|
- |
List<DBNote> notes = |
1620 |
|
- |
invoiceRO.getNotes(); // Lazy load the Notes from the Invoice (Not in transaction) |
|
1596 |
+ |
List<DBNote> notes = invoiceRO.getNotes(); // Lazy load the Notes from the Invoice (Not in transaction) |
1621 |
1597 |
|
|
1622 |
1598 |
|
try |
1623 |
1599 |
|
{ |
|
@@ -1635,8 +1611,7 @@ |
1635 |
1611 |
|
invoice.removeNotes( notes.get( 1 ).copyInto( transaction ) ); |
1636 |
1612 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1" ), "LineItem Note 1" ); |
1637 |
1613 |
|
|
1638 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1639 |
|
- |
"LineItem Note 1" ); |
|
1614 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1640 |
1615 |
|
|
1641 |
1616 |
|
transaction.commit(); |
1642 |
1617 |
|
|
|
@@ -1666,17 +1641,13 @@ |
1666 |
1641 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1667 |
1642 |
|
invoice.addNotes( note ); // Lazy load the Notes from the Invoice (In transaction) |
1668 |
1643 |
|
|
1669 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2", "AAA" ), |
1670 |
|
- |
"LineItem Note 1" ); |
|
1644 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2", "AAA" ), "LineItem Note 1" ); |
1671 |
1645 |
|
|
1672 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1673 |
|
- |
"LineItem Note 1" ); |
|
1646 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1674 |
1647 |
|
|
1675 |
1648 |
|
transaction.commit(); |
1676 |
1649 |
|
|
1677 |
|
- |
assertLineItemNoteTexts( |
1678 |
|
- |
assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2", "AAA" ), |
1679 |
|
- |
"LineItem Note 1" ); |
|
1650 |
+ |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2", "AAA" ), "LineItem Note 1" ); |
1680 |
1651 |
|
} |
1681 |
1652 |
|
|
1682 |
1653 |
|
@Test |
|
@@ -1685,8 +1656,7 @@ |
1685 |
1656 |
|
{ |
1686 |
1657 |
|
DBInvoice invoiceRO = createInvoiceWithLineItems(); |
1687 |
1658 |
|
|
1688 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1689 |
|
- |
"LineItem Note 1" ); |
|
1659 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1690 |
1660 |
|
List<DBNote> notes = invoiceRO.getNotes(); |
1691 |
1661 |
|
|
1692 |
1662 |
|
notes.remove( 1 ); |
|
@@ -1704,8 +1674,7 @@ |
1704 |
1674 |
|
Transaction transaction = mUF.createTransaction(); |
1705 |
1675 |
|
|
1706 |
1676 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1707 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), |
1708 |
|
- |
"LineItem Note 1" ); |
|
1677 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1709 |
1678 |
|
notes = invoice.getNotes(); |
1710 |
1679 |
|
|
1711 |
1680 |
|
notes.remove( 1 ); |
|
@@ -1714,13 +1683,11 @@ |
1714 |
1683 |
|
|
1715 |
1684 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "BBB" ), "LineItem Note 1" ); |
1716 |
1685 |
|
|
1717 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1718 |
|
- |
"LineItem Note 1" ); |
|
1686 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1719 |
1687 |
|
|
1720 |
1688 |
|
transaction.commit(); |
1721 |
1689 |
|
|
1722 |
|
- |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "BBB" ), |
1723 |
|
- |
"LineItem Note 1" ); |
|
1690 |
+ |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "BBB" ), "LineItem Note 1" ); |
1724 |
1691 |
|
} |
1725 |
1692 |
|
|
1726 |
1693 |
|
@Test |
|
@@ -1732,16 +1699,14 @@ |
1732 |
1699 |
|
Transaction transaction = mUF.createTransaction(); |
1733 |
1700 |
|
|
1734 |
1701 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1735 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), |
1736 |
|
- |
"LineItem Note 1" ); |
|
1702 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1737 |
1703 |
|
List<DBNote> notes = invoice.getNotes(); |
1738 |
1704 |
|
|
1739 |
1705 |
|
notes.get( 1 ).requestDelete(); // note: clears all foreign references |
1740 |
1706 |
|
|
1741 |
1707 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1" ), "LineItem Note 1" ); |
1742 |
1708 |
|
|
1743 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1744 |
|
- |
"LineItem Note 1" ); |
|
1709 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1745 |
1710 |
|
|
1746 |
1711 |
|
transaction.commit(); |
1747 |
1712 |
|
|
|
@@ -1757,8 +1722,7 @@ |
1757 |
1722 |
|
Transaction transaction = mUF.createTransaction(); |
1758 |
1723 |
|
|
1759 |
1724 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1760 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), |
1761 |
|
- |
"LineItem Note 1" ); |
|
1725 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1762 |
1726 |
|
List<DBNote> notes = invoice.getNotes(); |
1763 |
1727 |
|
|
1764 |
1728 |
|
DBNote note = notes.get( 0 ); |
|
@@ -1766,8 +1730,7 @@ |
1766 |
1730 |
|
|
1767 |
1731 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 2" ), "LineItem Note 1" ); |
1768 |
1732 |
|
|
1769 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1770 |
|
- |
"LineItem Note 1" ); |
|
1733 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1771 |
1734 |
|
|
1772 |
1735 |
|
note.setText( "BBB" ); |
1773 |
1736 |
|
|
|
@@ -1780,13 +1743,11 @@ |
1780 |
1743 |
|
|
1781 |
1744 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 2", "BBB" ), "LineItem Note 1" ); |
1782 |
1745 |
|
|
1783 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1784 |
|
- |
"LineItem Note 1" ); |
|
1746 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1785 |
1747 |
|
|
1786 |
1748 |
|
transaction.commit(); |
1787 |
1749 |
|
|
1788 |
|
- |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "BBB", "Invoice Note 2" ), |
1789 |
|
- |
"LineItem Note 1" ); |
|
1750 |
+ |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "BBB", "Invoice Note 2" ), "LineItem Note 1" ); |
1790 |
1751 |
|
} |
1791 |
1752 |
|
|
1792 |
1753 |
|
@Test |
|
@@ -1798,8 +1759,7 @@ |
1798 |
1759 |
|
Transaction transaction = mUF.createTransaction(); |
1799 |
1760 |
|
|
1800 |
1761 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1801 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), |
1802 |
|
- |
"LineItem Note 1" ); |
|
1762 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1803 |
1763 |
|
List<DBNote> notes = invoice.getNotes(); |
1804 |
1764 |
|
|
1805 |
1765 |
|
DBNote note = notes.get( 0 ); |
|
@@ -1807,36 +1767,30 @@ |
1807 |
1767 |
|
|
1808 |
1768 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 2" ), "LineItem Note 1" ); |
1809 |
1769 |
|
|
1810 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1811 |
|
- |
"LineItem Note 1" ); |
|
1770 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1812 |
1771 |
|
|
1813 |
1772 |
|
note.setText( "BBB" ); |
1814 |
1773 |
|
|
1815 |
1774 |
|
textSetOwner( note, "Jose" ); |
1816 |
1775 |
|
|
1817 |
|
- |
note.setAttributeValue( "Owner", new PO_VarURLstringHelper( DBInvoice.CD_Notes.getName(), |
1818 |
|
- |
invoice ).toString() ); |
|
1776 |
+ |
note.setAttributeValue( "Owner", new PO_VarURLstringHelper( DBInvoice.CD_Notes.getName(), invoice ).toString() ); |
1819 |
1777 |
|
|
1820 |
1778 |
|
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 2", "BBB" ), "LineItem Note 1" ); |
1821 |
1779 |
|
|
1822 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1823 |
|
- |
"LineItem Note 1" ); |
|
1780 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1824 |
1781 |
|
|
1825 |
1782 |
|
transaction.commit(); |
1826 |
1783 |
|
|
1827 |
|
- |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "BBB", "Invoice Note 2" ), |
1828 |
|
- |
"LineItem Note 1" ); |
|
1784 |
+ |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "BBB", "Invoice Note 2" ), "LineItem Note 1" ); |
1829 |
1785 |
|
} |
1830 |
1786 |
|
|
1831 |
|
- |
@SuppressWarnings({"unchecked"}) |
1832 |
|
- |
@Test |
|
1787 |
+ |
@SuppressWarnings({"unchecked"}) @Test |
1833 |
1788 |
|
public void testGenericInvoiceLazyLoadSetNotes() |
1834 |
1789 |
|
throws Exception |
1835 |
1790 |
|
{ |
1836 |
1791 |
|
DBInvoice invoiceRO = createInvoiceWithLineItems(); |
1837 |
1792 |
|
|
1838 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1839 |
|
- |
"LineItem Note 1" ); |
|
1793 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1840 |
1794 |
|
List<DBNote> notes = invoiceRO.getNotes(); |
1841 |
1795 |
|
|
1842 |
1796 |
|
notes.remove( 1 ); |
|
@@ -1854,8 +1808,7 @@ |
1854 |
1808 |
|
Transaction transaction = mUF.createTransaction(); |
1855 |
1809 |
|
|
1856 |
1810 |
|
DBInvoice invoice = invoiceRO.copyInto( transaction ); |
1857 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), |
1858 |
|
- |
"LineItem Note 1" ); |
|
1811 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1859 |
1812 |
|
notes = invoice.getNotes(); |
1860 |
1813 |
|
|
1861 |
1814 |
|
List changes = new ArrayList( notes ); |
|
@@ -1866,17 +1819,13 @@ |
1866 |
1819 |
|
changes.add( new DBNote( transaction, "EEE" ).getObjectHandle() ); |
1867 |
1820 |
|
invoice.setAttributeValue( "Notes", changes ); |
1868 |
1821 |
|
|
1869 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "BBB", "CCC", "DDD", "EEE" ), |
1870 |
|
- |
"LineItem Note 1" ); |
|
1822 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoice, "Invoice Note 1", "BBB", "CCC", "DDD", "EEE" ), "LineItem Note 1" ); |
1871 |
1823 |
|
|
1872 |
|
- |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), |
1873 |
|
- |
"LineItem Note 1" ); |
|
1824 |
+ |
assertLineItemNoteTexts( assertNoteTexts( invoiceRO, "Invoice Note 1", "Invoice Note 2" ), "LineItem Note 1" ); |
1874 |
1825 |
|
|
1875 |
1826 |
|
transaction.commit(); |
1876 |
1827 |
|
|
1877 |
|
- |
assertLineItemNoteTexts( |
1878 |
|
- |
assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "BBB", "CCC", "DDD", "EEE" ), |
1879 |
|
- |
"LineItem Note 1" ); |
|
1828 |
+ |
assertLineItemNoteTexts( assertDSRefreshNoteTexts( invoiceRO, "Invoice Note 1", "BBB", "CCC", "DDD", "EEE" ), "LineItem Note 1" ); |
1880 |
1829 |
|
} |
1881 |
1830 |
|
|
1882 |
1831 |
|
private void textSetOwner( DBNote pNote, Object pValue ) |
|
@@ -1967,8 +1916,7 @@ |
1967 |
1916 |
|
Timestamp zTSnow = new Timestamp( new Date().getTime() ); |
1968 |
1917 |
|
String zNewDescription = "2B/!2B"; |
1969 |
1918 |
|
zDBNode = mUF.snagOne( DBNode.class, null, null, // |
1970 |
|
- |
new ColumnUpdateValuePair( DBNode.CD_Description, zNewDescription ), |
1971 |
|
- |
new ColumnUpdateValuePair( DBNode.CD_DateShipped, zTSnow ) ); |
|
1919 |
+ |
new ColumnUpdateValuePair( DBNode.CD_Description, zNewDescription ), new ColumnUpdateValuePair( DBNode.CD_DateShipped, zTSnow ) ); |
1972 |
1920 |
|
|
1973 |
1921 |
|
assertNotNull( "Not Snagged", zDBNode ); |
1974 |
1922 |
|
assertEquals( "N2", zDBNode.getName() ); |
|
@@ -2045,8 +1993,7 @@ |
2045 |
1993 |
|
assertInvoice( pInvoices.get( pIndex ), pCompany, pNumber ); |
2046 |
1994 |
|
} |
2047 |
1995 |
|
|
2048 |
|
- |
private void assertInvoice( DBInvoice pOld, DBInvoice pNew, String pCompany, String pNumber, |
2049 |
|
- |
boolean pExpectedChange ) |
|
1996 |
+ |
private void assertInvoice( DBInvoice pOld, DBInvoice pNew, String pCompany, String pNumber, boolean pExpectedChange ) |
2050 |
1997 |
|
{ |
2051 |
1998 |
|
assertInvoice( pNew, pCompany, pNumber ); |
2052 |
1999 |
|
if ( pExpectedChange ) |
|
@@ -2065,15 +2012,12 @@ |
2065 |
2012 |
|
assertEquals( pNumber, pInvoice.getNumber() ); |
2066 |
2013 |
|
} |
2067 |
2014 |
|
|
2068 |
|
- |
private void assertDSRefreshLineItemProductCodes( DBInvoice pInvoice, boolean pExpectedChange, |
2069 |
|
- |
String... pProductCodes ) |
|
2015 |
+ |
private void assertDSRefreshLineItemProductCodes( DBInvoice pInvoice, boolean pExpectedChange, String... pProductCodes ) |
2070 |
2016 |
|
{ |
2071 |
|
- |
assertDSRefreshLineItemProductCodes( DataStoreLocator.get().getUnfilteredFinder(), pInvoice, |
2072 |
|
- |
pExpectedChange, pProductCodes ); |
|
2017 |
+ |
assertDSRefreshLineItemProductCodes( DataStoreLocator.get().getUnfilteredFinder(), pInvoice, pExpectedChange, pProductCodes ); |
2073 |
2018 |
|
} |
2074 |
2019 |
|
|
2075 |
|
- |
private void assertDSRefreshLineItemProductCodes( Finder pFinder, DBInvoice pInvoice, |
2076 |
|
- |
boolean pExpectedChange, String... pProductCodes ) |
|
2020 |
+ |
private void assertDSRefreshLineItemProductCodes( Finder pFinder, DBInvoice pInvoice, boolean pExpectedChange, String... pProductCodes ) |
2077 |
2021 |
|
{ |
2078 |
2022 |
|
DBInvoice invoice = pFinder.findOne( DBInvoice.class, pInvoice.getPersistentObjectUniqueKey() ); |
2079 |
2023 |
|
|
|
@@ -2082,8 +2026,7 @@ |
2082 |
2026 |
|
assertLineItemProductCodes( invoice, pProductCodes ); |
2083 |
2027 |
|
} |
2084 |
2028 |
|
|
2085 |
|
- |
private void assertLineItemProductCodeKeys( NonTransactionalFinder pFinder, DBInvoice pInvoice, |
2086 |
|
- |
String... pProductCodes ) |
|
2029 |
+ |
private void assertLineItemProductCodeKeys( NonTransactionalFinder pFinder, DBInvoice pInvoice, String... pProductCodes ) |
2087 |
2030 |
|
{ |
2088 |
2031 |
|
DBInvoice invoice = pFinder.findOne( DBInvoice.class, pInvoice.getPersistentObjectUniqueKey() ); |
2089 |
2032 |
|
|
|
@@ -2100,8 +2043,7 @@ |
2100 |
2043 |
|
} |
2101 |
2044 |
|
assertFalse( zKeyIterator.hasNext() ); |
2102 |
2045 |
|
|
2103 |
|
- |
List<DBLineItem> zItems2 = |
2104 |
|
- |
DataStoreLocator.get().getUnfilteredFinder().findAllByKeys( DBLineItem.class, zKeys ); |
|
2046 |
+ |
List<DBLineItem> zItems2 = DataStoreLocator.get().getUnfilteredFinder().findAllByKeys( DBLineItem.class, zKeys ); |
2105 |
2047 |
|
|
2106 |
2048 |
|
assertEquals( zItems.size(), zItems2.size() ); |
2107 |
2049 |
|
|
|
@@ -2125,8 +2067,7 @@ |
2125 |
2067 |
|
|
2126 |
2068 |
|
private DBInvoice assertDSRefreshNoteTexts( DBInvoice pInvoice, String... pNoteTexts ) |
2127 |
2069 |
|
{ |
2128 |
|
- |
DBInvoice invoice = DataStoreLocator.get().getUnfilteredFinder().findOne( DBInvoice.class, |
2129 |
|
- |
pInvoice.getPersistentObjectUniqueKey() ); |
|
2070 |
+ |
DBInvoice invoice = DataStoreLocator.get().getUnfilteredFinder().findOne( DBInvoice.class, pInvoice.getPersistentObjectUniqueKey() ); |
2130 |
2071 |
|
|
2131 |
2072 |
|
assertInvoice( pInvoice, invoice, "XYZZY", "I01", true ); |
2132 |
2073 |
|
|
|
@@ -2334,8 +2275,7 @@ |
2334 |
2275 |
|
assertTrue( pBlob.isReadable() ); |
2335 |
2276 |
|
assertFalse( pBlob.isWritable() ); |
2336 |
2277 |
|
|
2337 |
|
- |
assertEquals( (pExpectedBlock.length + MAX_BYTES_PER_PART - 1) / MAX_BYTES_PER_PART, |
2338 |
|
- |
mUF.count( Parts4Blobs.class, null ) ); |
|
2278 |
+ |
assertEquals( (pExpectedBlock.length + MAX_BYTES_PER_PART - 1) / MAX_BYTES_PER_PART, mUF.count( Parts4Blobs.class, null ) ); |
2339 |
2279 |
|
|
2340 |
2280 |
|
assertEquals( pExpectedBlock.length, pBlob.getSizeInBytes() ); |
2341 |
2281 |
|
|
|
@@ -2449,8 +2389,7 @@ |
2449 |
2389 |
|
assertTrue( zStreamAccessor.isReadable() ); |
2450 |
2390 |
|
assertEquals( (pSamples.getTransaction() != null), zStreamAccessor.isWritable() ); |
2451 |
2391 |
|
|
2452 |
|
- |
assertEquals( (pExpectedBlock.length + MAX_BYTES_PER_PART - 1) / MAX_BYTES_PER_PART, |
2453 |
|
- |
mUF.count( Parts4Blobs.class, null ) ); |
|
2392 |
+ |
assertEquals( (pExpectedBlock.length + MAX_BYTES_PER_PART - 1) / MAX_BYTES_PER_PART, mUF.count( Parts4Blobs.class, null ) ); |
2454 |
2393 |
|
|
2455 |
2394 |
|
assertEquals( pExpectedBlock.length, zStreamAccessor.getSizeInBytes() ); |
2456 |
2395 |
|
|