Skip to content
Permalink
Browse files

Improved: Used more declarative style for the context map, preferring…

… map literals over imperative map.

(OFBIZ-8853)
Thanks Mathieu Lirzin for your suggestion.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860003 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Suraj Khurana
Suraj Khurana committed May 25, 2019
1 parent e51b05e commit 52d8436640aff023eb2d5d00b3d3078d1a530f4e
Showing with 29 additions and 27 deletions.
  1. +29 −27 applications/order/groovyScripts/test/OrderTests.groovy
@@ -4,57 +4,59 @@ import org.apache.ofbiz.testtools.GroovyScriptTestCase

class OrderTests extends GroovyScriptTestCase {
void testAddRequirementTask() {
Map serviceCtx = [:]
serviceCtx.requirementId = "1000"
serviceCtx.workEffortId = "9000"
serviceCtx.userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
Map serviceCtx = [
requirementId: '1000',
workEffortId: '9000',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync("addRequirementTask", serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
}
void testCreateReturnAdjustment() {
Map serviceCtx = [:]
serviceCtx.amount = '2.0000'
serviceCtx.returnId = '1009'
serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
Map serviceCtx = [
amount: '2.0000',
returnId: '1009',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync('createReturnAdjustment', serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
assert serviceResult.returnAdjustmentId != null
}

void testQuickReturnOrder() {
Map serviceCtx = [:]
serviceCtx.orderId = 'TEST_DEMO10090'
serviceCtx.returnHeaderTypeId = 'CUSTOMER_RETURN'
serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
Map serviceCtx = [
orderId: 'TEST_DEMO10090',
returnHeaderTypeId: 'CUSTOMER_RETURN',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync('quickReturnOrder', serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
assert serviceResult.returnId != null
}

void testCreateReturnAndItemOrAdjustment() {
Map serviceCtx = [:]
serviceCtx.orderId = 'DEMO10090'
serviceCtx.returnId = '1009'
serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
Map serviceCtx = [
orderId: 'DEMO10090',
returnId: '1009',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync('createReturnAndItemOrAdjustment', serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
assert serviceResult.returnAdjustmentId != null
}

void testCheckReturnComplete() {
Map serviceCtx = [:]
serviceCtx.amount = '2.0000'
serviceCtx.returnId = '1009'
serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
Map serviceCtx = [
amount: '2.0000',
returnId: '1009',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync('checkReturnComplete', serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
assert serviceResult.statusId != null
}

void testCheckPaymentAmountForRefund() {
Map serviceCtx = [:]
serviceCtx.returnId = '1009'
serviceCtx.userLogin = EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
Map serviceCtx = [
returnId: '1009',
userLogin: EntityQuery.use(delegator).from('UserLogin').where('userLoginId', 'system').cache().queryOne()
]
Map serviceResult = dispatcher.runSync('checkPaymentAmountForRefund', serviceCtx)
assert ServiceUtil.isSuccess(serviceResult)
}

0 comments on commit 52d8436

Please sign in to comment.
You can’t perform that action at this time.