Skip to content

Commit

Permalink
Improved: Used more declarative style for the context map, preferring…
Browse files Browse the repository at this point in the history
… 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
surajkhurana committed May 25, 2019
1 parent e51b05e commit 52d8436
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions applications/order/groovyScripts/test/OrderTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 52d8436

Please sign in to comment.