Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assetmaint/servicedef/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ under the License.
<description>Create WorkEffort and Associate it with Parent (identified by workEffortFromId)</description>
<implements service="createWorkEffortAndAssoc"/>
</service>

</services>
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,43 @@
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.Test

import java.sql.Timestamp

@JunitJupiterTest
class FixedAssetMaintTests implements JupiterTestHelper {

// Shared by testCreateFixedAssetMaintUpdateWorkEffortWithProductMaint and
// testUpdateFixedAssetMaintAndWorkEffort - both need a freshly-created FixedAssetMaint (with
// product maintenance) as their starting point, one to assert on directly, the other as
// fixture setup before its own update assertions.
private Map createFixedAssetMaintWithProductMaint() {
String fixedAssetId = testParams.fixedAssetId ?: 'DEMO_VEHICLE_01'
String statusId = testParams.statusId ?: 'FAM_CREATED'
String productMaintSeqId = testParams.productMaintSeqId ?: 'seq03'
String intervalMeterTypeId = testParams.intervalMeterTypeId ?: 'ODOMETER'
Timestamp estimatedStartDate = UtilDateTime.toTimestamp(testParams.estimatedStartDate ?: '2009-12-18 00:00:00.000')
Timestamp estimatedCompletionDate = UtilDateTime.toTimestamp(testParams.estimatedCompletionDate ?: '2009-12-18 00:00:00.000')
Timestamp actualStartDate = UtilDateTime.toTimestamp(testParams.actualStartDate ?: '2009-12-20 00:00:00.000')
Map serviceCtx = [fixedAssetId: fixedAssetId,
statusId: statusId,
productMaintSeqId: productMaintSeqId, // product maintenance,
intervalMeterTypeId: intervalMeterTypeId,
estimatedStartDate: estimatedStartDate,
estimatedCompletionDate: estimatedCompletionDate,
actualStartDate: actualStartDate,
userLogin: userLogin]
Map serviceResult = dispatcher.runSync('createFixedAssetMaintUpdateWorkEffort', serviceCtx)
return [fixedAssetId: fixedAssetId, serviceCtx: serviceCtx, serviceResult: serviceResult]
}

@Test
@Order(1)
void testCreateFixedAssetMaintUpdateWorkEffortWithProductMaint() {
// Test case for service createFixedAssetMaintUpdateWorkEffort with a product Maintenance
String fixedAssetId = 'DEMO_VEHICLE_01'
Map serviceCtx = [fixedAssetId: fixedAssetId,
statusId: 'FAM_CREATED',
productMaintSeqId: 'seq03', // product maintenance,
intervalMeterTypeId: 'ODOMETER',
estimatedStartDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
estimatedCompletionDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
actualStartDate: UtilDateTime.toTimestamp('2009-12-20 00:00:00.000'),
userLogin: userLogin]
Map serviceResult = dispatcher.runSync('createFixedAssetMaintUpdateWorkEffort', serviceCtx)
Map created = createFixedAssetMaintWithProductMaint()
String fixedAssetId = created.fixedAssetId
Map serviceCtx = created.serviceCtx
Map serviceResult = created.serviceResult
GenericValue fixedAssetMaint = from('FixedAssetMaint')
.where('fixedAssetId', fixedAssetId,
'maintHistSeqId', serviceResult.maintHistSeqId)
Expand All @@ -61,14 +81,20 @@
@Order(2)
void testCreateFixedAssetMaintUpdateWorkEffortWithoutProductMaint() {
// Test case for service createFixedAssetMaintUpdateWorkEffort without a product maintenance
String fixedAssetId = 'DEMO_VEHICLE_01'
String fixedAssetId = testParams.fixedAssetId ?: 'DEMO_VEHICLE_01'
String statusId = testParams.statusId ?: 'FAM_CREATED'
String productMaintTypeId = testParams.productMaintTypeId ?: 'OIL_CHANGE'
String intervalMeterTypeId = testParams.intervalMeterTypeId ?: 'ODOMETER'
Timestamp estimatedStartDate = UtilDateTime.toTimestamp(testParams.estimatedStartDate ?: '2009-12-18 00:00:00.000')
Timestamp estimatedCompletionDate = UtilDateTime.toTimestamp(testParams.estimatedCompletionDate ?: '2009-12-18 00:00:00.000')

Check failure on line 89 in assetmaint/src/test/groovy/org/apache/ofbiz/assetmaint/assetmaint/test/FixedAssetMaintTests.groovy

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal '2009-12-18 00:00:00.000' 4 times.

See more on https://sonarcloud.io/project/issues?id=apache_ofbiz-plugins&issues=AaApQxR_Hu0gULto0W5e&open=AaApQxR_Hu0gULto0W5e&pullRequest=374
Timestamp actualStartDate = UtilDateTime.toTimestamp(testParams.actualStartDate ?: '2009-12-20 00:00:00.000')
Map serviceCtx = [fixedAssetId: fixedAssetId,
statusId: 'FAM_CREATED',
productMaintTypeId: 'OIL_CHANGE',
intervalMeterTypeId: 'ODOMETER',
estimatedStartDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
estimatedCompletionDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
actualStartDate: UtilDateTime.toTimestamp('2009-12-20 00:00:00.000'),
statusId: statusId,
productMaintTypeId: productMaintTypeId,
intervalMeterTypeId: intervalMeterTypeId,
estimatedStartDate: estimatedStartDate,
estimatedCompletionDate: estimatedCompletionDate,
actualStartDate: actualStartDate,
userLogin: userLogin]
Map serviceResult = dispatcher.runSync('createFixedAssetMaintUpdateWorkEffort', serviceCtx)
String maintHistSeqId = serviceResult.maintHistSeqId
Expand All @@ -93,27 +119,25 @@
@Order(3)
void testUpdateFixedAssetMaintAndWorkEffort() {
// Test case for service updateFixedAssetMaintAndWorkEffort
String fixedAssetId = 'DEMO_VEHICLE_01'
Map serviceCtx = [fixedAssetId: fixedAssetId,
statusId: 'FAM_CREATED',
productMaintSeqId: 'seq03', // product maintenance,
intervalMeterTypeId: 'ODOMETER',
estimatedStartDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
estimatedCompletionDate: UtilDateTime.toTimestamp('2009-12-18 00:00:00.000'),
actualStartDate: UtilDateTime.toTimestamp('2009-12-20 00:00:00.000'),
userLogin: userLogin]
Map serviceResult = dispatcher.runSync('createFixedAssetMaintUpdateWorkEffort', serviceCtx)
String maintHistSeqId = serviceResult.maintHistSeqId
Map created = createFixedAssetMaintWithProductMaint()
String fixedAssetId = created.fixedAssetId
String statusId = created.serviceCtx.statusId
String intervalMeterTypeId = created.serviceCtx.intervalMeterTypeId
String maintHistSeqId = created.serviceResult.maintHistSeqId
GenericValue fixedAssetMaint = from('FixedAssetMaint')
.where('fixedAssetId', fixedAssetId,
'maintHistSeqId', maintHistSeqId)
.queryOne()
serviceCtx = [fixedAssetId: fixedAssetId,

String productMaintTypeId = testParams.productMaintTypeId ?: 'OIL_CHANGE'
Timestamp updatedEstimatedCompletionDate =
UtilDateTime.toTimestamp(testParams.updatedEstimatedCompletionDate ?: '2009-12-22 01:00:00.000')
Map serviceCtx = [fixedAssetId: fixedAssetId,
maintHistSeqId: maintHistSeqId,
statusId: 'FAM_CREATED',
productMaintTypeId: 'OIL_CHANGE',
intervalMeterTypeId: 'ODOMETER',
estimatedCompletionDate: UtilDateTime.toTimestamp('2009-12-22 01:00:00.000'),
statusId: statusId,
productMaintTypeId: productMaintTypeId,
intervalMeterTypeId: intervalMeterTypeId,
estimatedCompletionDate: updatedEstimatedCompletionDate,
scheduleWorkEffortId: fixedAssetMaint.scheduleWorkEffortId,
userLogin: userLogin]

Expand All @@ -128,19 +152,20 @@
assert workEffort.estimatedCompletionDate == serviceCtx.estimatedCompletionDate

// Test case for service updateFixedAssetMaintAndWorkEffort
String completedStatusId = testParams.completedStatusId ?: 'FAM_COMPLETED'
serviceCtx = [fixedAssetId: fixedAssetMaint.fixedAssetId,
maintHistSeqId: fixedAssetMaint.maintHistSeqId,
scheduleWorkEffortId: fixedAssetMaint.scheduleWorkEffortId,
statusId: 'FAM_COMPLETED',
statusId: completedStatusId,
actualCompletionDate: UtilDateTime.nowTimestamp(),
userLogin: userLogin]

dispatcher.runSync('updateFixedAssetMaintAndWorkEffort', serviceCtx)
GenericValue newFixedAssetMaint = from('FixedAssetMaint')
.where('fixedAssetId', 'DEMO_VEHICLE_01',
.where('fixedAssetId', fixedAssetId,

Check failure on line 165 in assetmaint/src/test/groovy/org/apache/ofbiz/assetmaint/assetmaint/test/FixedAssetMaintTests.groovy

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal 'fixedAssetId' 4 times.

See more on https://sonarcloud.io/project/issues?id=apache_ofbiz-plugins&issues=AaApQxR_Hu0gULto0W5b&open=AaApQxR_Hu0gULto0W5b&pullRequest=374
'maintHistSeqId', maintHistSeqId)
.queryOne()
assert newFixedAssetMaint.statusId == 'FAM_COMPLETED'
assert newFixedAssetMaint.statusId == completedStatusId
workEffort = from('WorkEffort')
.where('workEffortId', fixedAssetMaint.scheduleWorkEffortId)
.queryOne()
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/ofbiz-component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ under the License.
<entity-resource type="data" reader-name="demo" loader="main" location="data/DemoProductAdditionalViewData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/DemoPopularCategoriesData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/DemoContentAltUrl.xml"/>

<test-suite loader="main" location="testdef/EcommerceTest.xml"/>

<webapp name="ecommerce"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
@Test
@Order(1)
void testSendOrderConfirmation() {
String orderId = testParams.orderId ?: 'TEST_DEMO10090'
String sendTo = testParams.sendTo ?: 'test_email@example.com'

Map serviceCtx = [
orderId: 'TEST_DEMO10090',
sendTo: 'test_email@example.com',
orderId: orderId,
sendTo: sendTo,
userLogin: userLogin
]
Map serviceResult = dispatcher.runSync('sendOrderConfirmation', serviceCtx)
Expand All @@ -43,11 +46,16 @@
@Test
@Order(2)
void testSendOrderChangeNotification() {
String orderId = testParams.orderId ?: 'TEST_DEMO10090'
String note = testParams.note ?: 'Test Note'
String comments = testParams.comments ?: 'Test comments'
String sendTo = testParams.sendTo ?: 'test_email@example.com'

Map serviceCtx = [
orderId: 'TEST_DEMO10090',
note: 'Test Note',
comments: 'Test comments',
sendTo: 'test_email@example.com',
orderId: orderId,
note: note,
comments: comments,
sendTo: sendTo,
userLogin: userLogin
]
Map serviceResult = dispatcher.runSync('sendOrderChangeNotification', serviceCtx)
Expand All @@ -58,9 +66,12 @@
@Test
@Order(3)
void testSendOrderBackorderNotification() {
String orderId = testParams.orderId ?: 'TEST_DEMO10090'
String sendTo = testParams.sendTo ?: 'test_email@example.com'

Map serviceCtx = [
orderId: 'TEST_DEMO10090',
sendTo: 'test_email@example.com',
orderId: orderId,
sendTo: sendTo,
userLogin: userLogin
]
Map serviceResult = dispatcher.runSync('sendOrderBackorderNotification', serviceCtx)
Expand All @@ -71,9 +82,12 @@
@Test
@Order(4)
void testsendOrderPayRetryNotification() {
String orderId = testParams.orderId ?: 'TEST_DEMO10090'
String sendTo = testParams.sendTo ?: 'test_email@example.com'

Map serviceCtx = [
orderId: 'TEST_DEMO10090',
sendTo: 'test_email@example.com',
orderId: orderId,
sendTo: sendTo,
userLogin: userLogin
]
Map serviceResult = dispatcher.runSync('sendOrderPayRetryNotification', serviceCtx)
Expand All @@ -84,9 +98,12 @@
@Test
@Order(5)
void testsendOrderCompleteNotification() {
String orderId = testParams.orderId ?: 'TEST_DEMO10090'

Check failure on line 101 in ecommerce/src/test/groovy/org/apache/ofbiz/ecommerce/order/test/OrderNotificationTests.groovy

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal 'TEST_DEMO10090' 5 times.

See more on https://sonarcloud.io/project/issues?id=apache_ofbiz-plugins&issues=AaApQxRYHu0gULto0W5Z&open=AaApQxRYHu0gULto0W5Z&pullRequest=374
String sendTo = testParams.sendTo ?: 'test_email@example.com'

Check failure on line 102 in ecommerce/src/test/groovy/org/apache/ofbiz/ecommerce/order/test/OrderNotificationTests.groovy

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal 'test_email@example.com' 5 times.

See more on https://sonarcloud.io/project/issues?id=apache_ofbiz-plugins&issues=AaApQxRYHu0gULto0W5Y&open=AaApQxRYHu0gULto0W5Y&pullRequest=374

Map serviceCtx = [
orderId: 'TEST_DEMO10090',
sendTo: 'test_email@example.com',
orderId: orderId,
sendTo: sendTo,
userLogin: userLogin
]
Map serviceResult = dispatcher.runSync('sendOrderCompleteNotification', serviceCtx)
Expand Down
18 changes: 0 additions & 18 deletions example/api/example.rest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,4 @@ under the License.
<service name="findExampleById"/>
</operation>
</resource>

<resource name="TestRunResource"
path="testruns"
displayName="Test Run"
description="Trigger and poll example component test runs only - componentName is not accepted, permanently scoped to the example component"
primaryPermission="TESTEXEC"
mainAction="ADMIN">

<operation verb="post" description="Trigger a test suite run (scoped to the example component)"
consumes="application/json">
<service name="runExampleTestSuite"/>
</operation>

<operation verb="get" description="Get a test run's status (scoped to the example component)"
path="{runId}">
<service name="getExampleTestRunStatus"/>
</operation>
</resource>
</api>
34 changes: 0 additions & 34 deletions example/servicedef/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,38 +178,4 @@ under the License.
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>

<!-- Test Run Services (component-scoped wrapper around framework/testtools) -->
<service name="runExampleTestSuite" engine="groovy" auth="true"
location="component://example/src/test/groovy/org/apache/ofbiz/example/ExampleTestRunServices.groovy"
invoke="runExampleTestSuite">
<description>Kicks off a testdef test-suite run asynchronously, scoped to the example
component only - see TestRunServices.runScopedTestSuite. Gated by the test.api.enabled
config flag and the TESTEXEC_ADMIN permission (checked inside the underlying service).
Also gated by the per-component test.api.enabled.example override - same
SystemProperty-backed mechanism, defaults to enabled, lets this component's endpoint be
disabled independently of every other component's. componentName is deliberately not an
attribute here - the component is fixed, not caller-suppliable. testMethodName optionally
scopes the run to one @Test/@ParameterizedTest method within the class testCaseName
resolves to - requires testCaseName, and only applies when it resolves to a
jupiter-test-suite.</description>
<attribute name="suiteName" type="String" mode="IN" optional="false"/>
<attribute name="testCaseName" type="String" mode="IN" optional="true"/>
<attribute name="testMethodName" type="String" mode="IN" optional="true"/>
<attribute name="testParams" type="Map" mode="IN" optional="true"/>
<attribute name="runId" type="String" mode="OUT" optional="true"/>
</service>

<service name="getExampleTestRunStatus" engine="groovy" auth="true"
location="component://example/src/test/groovy/org/apache/ofbiz/example/ExampleTestRunServices.groovy"
invoke="getExampleTestRunStatus">
<description>Reads a runExampleTestSuite-triggered run's status, scoped to the example
component only - a runId belonging to another component's run is reported as
not-found, not a distinguishable "wrong component" error. See
TestRunServices.getScopedTestRunStatus.</description>
<attribute name="runId" type="String" mode="IN" optional="false"/>
<attribute name="status" type="String" mode="OUT" optional="true"/>
<attribute name="componentName" type="String" mode="OUT" optional="true"/>
<attribute name="resultSummary" type="Map" mode="OUT" optional="true"/>
</service>

</services>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class LuceneTests implements JupiterTestHelper {

@Test
void testSearchTermHand() {
String contentId = testParams.contentId ?: 'LuceneCONTENT'
Map ctx = [
contentId: 'LuceneCONTENT',
contentId: contentId,
userLogin: userLogin
]
Map resp = dispatcher.runSync('indexContentTree', ctx)
Expand All @@ -64,7 +65,7 @@ class LuceneTests implements JupiterTestHelper {
}

BooleanQuery.Builder combQueryBuilder = new BooleanQuery.Builder()
String queryLine = 'hand'
String queryLine = testParams.queryLine ?: 'hand'

IndexSearcher searcher = new IndexSearcher(reader)
Analyzer analyzer = new StandardAnalyzer()
Expand Down
1 change: 1 addition & 0 deletions scrum/servicedef/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,5 @@ under the License.
</description>
<attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
</service>

</services>
Loading