Author: jacopoc
Date: Tue Feb 9 14:40:11 2010
New Revision: 908059
URL: http://svn.apache.org/viewvc?rev=908059&view=rev
Log:
Automated test for the production run status change to scheduled/confirmed.
Fixed some code that was preventing the test to pass.
Modified:
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
Modified:
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml?rev=908059&r1=908058&r2=908059&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
(original)
+++
ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/test/ProductionRunTests.xml
Tue Feb 9 14:40:11 2010
@@ -113,4 +113,91 @@
<check-errors/>
</simple-method>
+
+
+ <simple-method method-name="testProductionRunScheduleConfirm"
short-description="Test the production run status change to scheduled and
confirmed" login-required="false">
+ <set field="productId" value="PROD_MANUF"/>
+ <set field="facilityId" value="WebStoreWarehouse"/>
+ <set field="quantity" value="5.0" type="BigDecimal"/>
+ <now-timestamp field="nowTimestamp"/>
+ <set-calendar field="productionRunStartDate" from-field="nowTimestamp"
days="1"/>
+
+ <entity-one entity-name="UserLogin" value-field="userLogin">
+ <field-map field-name="userLoginId" value="admin"/>
+ </entity-one>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productId" from-field="productId"/>
+ <set field="serviceCtx.pRQuantity" from-field="quantity"/>
+ <set field="serviceCtx.startDate" from-field="productionRunStartDate"/>
+ <set field="serviceCtx.facilityId" from-field="facilityId"/>
+
+ <!-- production run #1 -->
+ <call-service service-name="createProductionRun"
in-map-name="serviceCtx">
+ <result-to-field result-name="productionRunId"/>
+ </call-service>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_SCHEDULED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+
+ <!-- the tests -->
+ <entity-one entity-name="WorkEffort" value-field="productionRunHeader">
+ <field-map field-name="workEffortId" from-field="productionRunId"/>
+ </entity-one>
+ <entity-and list="productionRunTasks" entity-name="WorkEffort">
+ <field-map field-name="workEffortParentId"
from-field="productionRunId"/>
+ </entity-and>
+ <first-from-list entry="productionRunTask" list="productionRunTasks"/>
+
+ <assert>
+ <if-compare field="productionRunHeader.currentStatusId"
operator="equals" value="PRUN_SCHEDULED"/>
+ <if-compare field="productionRunTask.currentStatusId"
operator="equals" value="PRUN_SCHEDULED"/>
+ </assert>
+
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_DOC_PRINTED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+
+ <refresh-value value-field="productionRunHeader"/>
+ <refresh-value value-field="productionRunTask"/>
+ <assert>
+ <if-compare field="productionRunHeader.currentStatusId"
operator="equals" value="PRUN_DOC_PRINTED"/>
+ <if-compare field="productionRunTask.currentStatusId"
operator="equals" value="PRUN_DOC_PRINTED"/>
+ </assert>
+
+ <!-- production run #2 -->
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productId" from-field="productId"/>
+ <set field="serviceCtx.pRQuantity" from-field="quantity"/>
+ <set field="serviceCtx.startDate" from-field="productionRunStartDate"/>
+ <set field="serviceCtx.facilityId" from-field="facilityId"/>
+
+ <call-service service-name="createProductionRun"
in-map-name="serviceCtx">
+ <result-to-field result-name="productionRunId"/>
+ </call-service>
+ <clear-field field="serviceCtx"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.productionRunId" from-field="productionRunId"/>
+ <set field="serviceCtx.statusId" value="PRUN_DOC_PRINTED"/>
+ <call-service service-name="quickChangeProductionRunStatus"
in-map-name="serviceCtx"/>
+ <entity-one entity-name="WorkEffort" value-field="productionRunHeader">
+ <field-map field-name="workEffortId" from-field="productionRunId"/>
+ </entity-one>
+ <entity-and list="productionRunTasks" entity-name="WorkEffort">
+ <field-map field-name="workEffortParentId"
from-field="productionRunId"/>
+ </entity-and>
+ <first-from-list entry="productionRunTask" list="productionRunTasks"/>
+
+ <assert>
+ <if-compare field="productionRunHeader.currentStatusId"
operator="equals" value="PRUN_DOC_PRINTED"/>
+ <if-compare field="productionRunTask.currentStatusId"
operator="equals" value="PRUN_DOC_PRINTED"/>
+ </assert>
+
+ <check-errors/>
+ </simple-method>
+
</simple-methods>
\ No newline at end of file
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=908059&r1=908058&r2=908059&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
Tue Feb 9 14:40:11 2010
@@ -538,7 +538,7 @@
}
// PRUN_CREATED --> PRUN_SCHEDULED
- if (currentStatusId.equals("PRUN_CREATED") && (statusId != null &&
statusId.equals("PRUN_SCHEDULED"))) {
+ if ("PRUN_CREATED".equals(currentStatusId) &&
"PRUN_SCHEDULED".equals(statusId)) {
// change the production run status to PRUN_SCHEDULED
Map serviceContext = new HashMap();
serviceContext.clear();
@@ -552,7 +552,7 @@
Debug.logError(e, "Problem calling the updateWorkEffort
service", module);
return
ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ManufacturingProductionRunStatusNotChanged", locale));
}
- // change the production run tasks status to PRUN_CLOSED
+ // change the production run tasks status to PRUN_SCHEDULED
Iterator tasks =
productionRun.getProductionRunRoutingTasks().iterator();
while (tasks.hasNext()) {
GenericValue task = (GenericValue)tasks.next();
@@ -573,7 +573,7 @@
return result;
}
- // PRUN_CREATED or PRON_SCHEDULED --> PRUN_DOC_PRINTED
+ // PRUN_CREATED or PRUN_SCHEDULED --> PRUN_DOC_PRINTED
if ((currentStatusId.equals("PRUN_CREATED") ||
currentStatusId.equals("PRUN_SCHEDULED")) && (statusId == null ||
statusId.equals("PRUN_DOC_PRINTED"))) {
// change only the production run (header) status to
PRUN_DOC_PRINTED
Map serviceContext = new HashMap();
@@ -588,6 +588,22 @@
Debug.logError(e, "Problem calling the updateWorkEffort
service", module);
return
ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ManufacturingProductionRunStatusNotChanged", locale));
}
+ // change the production run tasks status to PRUN_DOC_PRINTED
+ Iterator tasks =
productionRun.getProductionRunRoutingTasks().iterator();
+ while (tasks.hasNext()) {
+ GenericValue task = (GenericValue)tasks.next();
+ serviceContext.clear();
+ serviceContext.put("workEffortId",
task.getString("workEffortId"));
+ serviceContext.put("currentStatusId", "PRUN_DOC_PRINTED");
+ serviceContext.put("userLogin", userLogin);
+ resultService = null;
+ try {
+ resultService = dispatcher.runSync("updateWorkEffort",
serviceContext);
+ } catch (GenericServiceException e) {
+ Debug.logError(e, "Problem calling the updateWorkEffort
service", module);
+ return
ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ManufacturingProductionRunStatusNotChanged", locale));
+ }
+ }
result.put("newStatusId", "PRUN_DOC_PRINTED");
result.put(ModelService.SUCCESS_MESSAGE,
UtilProperties.getMessage(resource,
"ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId",
"PRUN_DOC_PRINTED"), locale));
return result;
@@ -743,9 +759,9 @@
return result;
}
- // PRUN_CREATED or PRUN_SCHEDULED --> PRUN_RUNNING
+ // PRUN_CREATED or PRUN_SCHEDULED or PRUN_DOC_PRINTED --> PRUN_RUNNING
// this should be called only when the first task is started
- if ((currentStatusId.equals("PRUN_CREATED") ||
currentStatusId.equals("PRUN_SCHEDULED")) && (statusId == null ||
statusId.equals("PRUN_RUNNING"))) {
+ if ((currentStatusId.equals("PRUN_CREATED") ||
currentStatusId.equals("PRUN_SCHEDULED") ||
currentStatusId.equals("PRUN_DOC_PRINTED")) && (statusId == null ||
statusId.equals("PRUN_RUNNING"))) {
// change the production run task status to PRUN_RUNNING
// if necessary change the production run (header) status to
PRUN_RUNNING
if (!allPrecTaskCompletedOrRunning) {
@@ -2710,7 +2726,9 @@
for (int i = 0; i < tasks.size(); i++) {
oneTask = (GenericValue)tasks.get(i);
taskId = oneTask.getString("workEffortId");
- if ("PRUN_CREATED".equals(oneTask.getString("currentStatusId"))) {
+ if ("PRUN_CREATED".equals(oneTask.getString("currentStatusId")) ||
+
"PRUN_SCHEDULED".equals(oneTask.getString("currentStatusId")) ||
+
"PRUN_DOC_PRINTED".equals(oneTask.getString("currentStatusId"))) {
try {
Map serviceContext = UtilMisc.toMap("productionRunId",
productionRunId, "workEffortId", taskId);
serviceContext.put("statusId", "PRUN_RUNNING");