JacquesLeRoux commented on code in PR #517:
URL: https://github.com/apache/ofbiz-framework/pull/517#discussion_r1135270359
##########
applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/InvoicePerShipmentTests.groovy:
##########
@@ -34,152 +31,155 @@ import org.apache.ofbiz.shipment.packing.PackingSession
import org.springframework.mock.web.MockHttpServletRequest
import org.springframework.mock.web.MockHttpServletResponse
+import javax.servlet.http.HttpSession
-public class InvoicePerShipmentTests extends OFBizTestCase {
- public InvoicePerShipmentTests(String name) {
+class InvoicePerShipmentTests extends OFBizTestCase {
+
+ InvoicePerShipmentTests(String name) {
super(name)
}
- def testInvoicePerShipment(String productId, String invoicePerShipment) {
+ void testInvoicePerShipmentSetFalse() {
+ /* Test Invoice Per Shipment
+ Step 1) Set create.invoice.per.shipment=N in accounting.properties
file.
+ Step 2) Create order and approve order.
+ Step 3) Pack Shipment For Ship Group.
+ Step 4) Check invoice should not created.
+ */
+ List invoices = testInvoicePerShipment('GZ-1000', 'N')
+ assert UtilValidate.isEmpty(invoices)
+ }
+
+ void testInvoicePerShipmentSetTrue() {
+ /* Test Invoice Per Shipment
+ Step 1) Set create.invoice.per.shipment=Y in accounting.properties
file.
+ Step 2) Create order and approve order.
+ Step 3) Pack Shipment For Ship Group.
+ Step 4) Check invoice should be created.
+ */
+ List invoices = testInvoicePerShipment('GZ-1000', 'Y')
+ assert UtilValidate.isNotEmpty(invoices)
+ }
+
+ void testInvoicePerShipmentSetOrderFalse() {
+ /* Test Invoice Per Shipment
+ Step 1) Create order and set invoicePerShipment=N.
+ Step 2) Pack Shipment For Ship Group.
+ Step 3) Check invoice should not be created.
+ */
+ List invoices = testInvoicePerShipment('GZ-2644', 'N')
+ assert UtilValidate.isEmpty(invoices)
+ }
+
+ void testInvoicePerShipmentSetOrderTrue() {
+ /* Test Invoice Per Shipment
+ Step 1) Create order and set invoicePerShipment=Y
+ Step 2) Pack Shipment For Ship Group.
+ Step 3) Check invoice should be created.
+ */
+ List invoices = testInvoicePerShipment('GZ-2644', 'Y')
+ assert UtilValidate.isNotEmpty(invoices)
+ }
+
+ private List testInvoicePerShipment(String productId, String
invoicePerShipment) {
MockHttpServletRequest request = new MockHttpServletRequest()
MockHttpServletResponse response = new MockHttpServletResponse()
Security security = SecurityFactory.getInstance(delegator)
- request.setAttribute("security", security)
- request.setAttribute("delegator", delegator)
- request.setAttribute("dispatcher", dispatcher)
+ request.setAttribute('security', security)
+ request.setAttribute('delegator', delegator)
+ request.setAttribute('dispatcher', dispatcher)
HttpSession session = request.getSession()
- session.setAttribute("orderMode", null)
+ session.setAttribute('orderMode', null)
String result = ShoppingCartEvents.routeOrderEntry(request, response)
- logInfo("===== >>> Event : routeOrderEntry, Response : " + result)
+ logInfo('===== >>> Event : routeOrderEntry, Response : ' + result)
- request.setParameter("orderMode", "SALES_ORDER")
- request.setParameter("productStoreId", "9000")
- request.setParameter("partyId", "DemoCustomer")
- request.setParameter("currencyUom", "USD")
- session.setAttribute("userLogin", userLogin)
+ request.setParameter('orderMode', 'SALES_ORDER')
+ request.setParameter('productStoreId', '9000')
+ request.setParameter('partyId', 'DemoCustomer')
+ request.setParameter('currencyUom', 'USD')
+ session.setAttribute('userLogin', userLogin)
result = ShoppingCartEvents.initializeOrderEntry(request, response)
- logInfo("===== >>> Event : initializeOrderEntry, Response : " + result)
+ logInfo('===== >>> Event : initializeOrderEntry, Response : ' + result)
result = ShoppingCartEvents.setOrderCurrencyAgreementShipDates(request, response)
- logInfo("===== >>> Event : setOrderCurrencyAgreementShipDates, Response :
" + result)
+ logInfo('===== >>> Event : setOrderCurrencyAgreementShipDates,
Response : ' + result)
- request.setParameter("add_product_id", productId)
+ request.setParameter('add_product_id', productId)
result = ShoppingCartEvents.addToCart(request, response)
- logInfo("===== >>> Event : addToCart, Response : " + result)
+ logInfo('===== >>> Event : addToCart, Response : ' + result)
- request.setParameter("checkoutpage", "quick")
- request.setParameter("shipping_contact_mech_id", "9015")
- request.setParameter("shipping_method", "GROUND@UPS")
- request.setParameter("checkOutPaymentId", "EXT_COD")
- request.setParameter("is_gift", "false")
- request.setParameter("may_split", "false")
- request.setAttribute("shoppingCart", null)
+ request.setParameter('checkoutpage', 'quick')
+ request.setParameter('shipping_contact_mech_id', '9015')
+ request.setParameter('shipping_method', 'GROUND@UPS')
+ request.setParameter('checkOutPaymentId', 'EXT_COD')
+ request.setParameter('is_gift', 'false')
+ request.setParameter('may_split', 'false')
+ request.setAttribute('shoppingCart', null)
result = CheckOutEvents.setQuickCheckOutOptions(request, response)
- logInfo("===== >>> Event : setQuickCheckOutOptions, Response : " +
result)
+ logInfo('===== >>> Event : setQuickCheckOutOptions, Response : ' +
result)
result = CheckOutEvents.createOrder(request, response)
- logInfo("===== >>> Event : createOrder, Response : " + result)
+ logInfo('===== >>> Event : createOrder, Response : ' + result)
result = CheckOutEvents.processPayment(request, response)
- logInfo("===== >>> Event : processPayment, Response : " + result)
+ logInfo('===== >>> Event : processPayment, Response : ' + result)
- dispatcher.runAsync("sendOrderConfirmation", null)
+ dispatcher.runAsync('sendOrderConfirmation', null)
result = ShoppingCartEvents.destroyCart(request, response)
- logInfo("===== >>> Event : destroyCart, Response = " + result)
+ logInfo('===== >>> Event : destroyCart, Response = ' + result)
// Step 3
- GenericValue orderHeader = from("OrderHeader").where("orderTypeId",
"SALES_ORDER").orderBy("-entryDate").queryFirst()
-
logInfo("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx :
" + orderHeader)
+ GenericValue orderHeader = from('OrderHeader').where('orderTypeId',
'SALES_ORDER').orderBy('-entryDate').queryFirst()
+
logInfo('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: ' + orderHeader)
if (invoicePerShipment) {
// if this value is available that means we need to set this on
the order
Map orderInput = [:]
orderInput.orderId = orderHeader.orderId
orderInput.invoicePerShipment = invoicePerShipment
orderInput.userLogin = userLogin
- Map serviceResult = dispatcher.runSync("updateOrderHeader",
orderInput)
- logInfo("===== >>> Service : updateOrderHeader / invoicePerShipment =
N, Response = " + serviceResult.responseMessage)
+ Map serviceResult = dispatcher.runSync('updateOrderHeader',
orderInput)
+ logInfo('===== >>> Service : updateOrderHeader /
invoicePerShipment = N, Response = ' + serviceResult.responseMessage)
}
PackingSession packingSession = new PackingSession(dispatcher, userLogin)
- session.setAttribute("packingSession", packingSession)
+ session.setAttribute('packingSession', packingSession)
packingSession.setPrimaryOrderId(orderHeader.orderId)
- packingSession.setPrimaryShipGroupSeqId("00001")
-
- Map packInput = [:]
- packInput.orderId = orderHeader.orderId
- packInput.shipGroupSeqId = "00001"
- packInput.packingSession = packingSession
- packInput.nextPackageSeq = 1
- packInput.userLogin = userLogin
-
- // Items
- packInput.selInfo = [_1: "Y"]
- packInput.pkgInfo = [_1: "1"]
- packInput.qtyInfo = [_1: "1"]
- packInput.prdInfo = [_1: productId]
- packInput.iteInfo = [_1: "00001"]
- packInput.wgtInfo = [_1: "0"]
- packInput.numPackagesInfo = [_1: "1"]
-
- Map serviceResult = dispatcher.runSync("packBulkItems", packInput)
+ packingSession.setPrimaryShipGroupSeqId('00001')
+
+ Map packInput = [
+ orderId: orderHeader.orderId,
+ shipGroupSeqId: '00001',
+ packingSession: packingSession,
+ nextPackageSeq: 1,
+ userLogin: userLogin,
+ selInfo: [_1: 'Y'],
+ pkgInfo: [_1: '1'],
+ qtyInfo: [_1: '1'],
+ prdInfo: [_1: productId],
+ iteInfo: [_1: '00001'],
+ wgtInfo: [_1: '0'],
+ numPackagesInfo: [_1: '1']
+ ]
+
+ Map serviceResult = dispatcher.runSync('packBulkItems', packInput)
assert ServiceUtil.isSuccess(serviceResult)
- logInfo("===== >>> Service: packBulkItems, Response = " +
serviceResult.responseMessage)
+ logInfo('===== >>> Service: packBulkItems, Response = ' +
serviceResult.responseMessage)
- Map completePackInput = dispatcher.getDispatchContext().makeValidContext("completePack", ModelService.IN_PARAM, packInput)
- serviceResult = dispatcher.runSync("completePack", completePackInput)
+ Map completePackInput =
dispatcher.getDispatchContext().makeValidContext('completePack',
ModelService.IN_PARAM, packInput)
+ serviceResult = dispatcher.runSync('completePack', completePackInput)
assert ServiceUtil.isSuccess(serviceResult)
- logInfo("===== >>> Service: completePack, shipmentId = " +
serviceResult.shipmentId)
+ logInfo('===== >>> Service: completePack, shipmentId = ' +
serviceResult.shipmentId)
// Step 4
- List invoices =
from("OrderItemBillingAndInvoiceAndItem").where("orderId",
orderHeader.orderId).queryList()
+ List invoices =
from('OrderItemBillingAndInvoiceAndItem').where('orderId',
orderHeader.orderId).queryList()
return invoices
}
Review Comment:
I see no reasons to remove the tests below. I can see them ran at
https://nightlies.apache.org/ofbiz/trunk/tests-results/plugins/html/