This is an automated email from the ASF dual-hosted git repository.
ashishvijaywargiya pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new bb3b224d1 Fixed: replace duplicated EXST_DEFINED literal with a
constant in ExampleJupiterTests (#414)
bb3b224d1 is described below
commit bb3b224d1f958e704b37635e84501b341d8fee78
Author: Ashish Vijaywargiya <[email protected]>
AuthorDate: Fri Sep 18 18:03:40 2026 +0530
Fixed: replace duplicated EXST_DEFINED literal with a constant in
ExampleJupiterTests (#414)
## Summary
- SonarCloud flagged a code-smell on PR #412 (Adopt update() DSL
orderBy()/first()/ifExists() in createExampleStatus()): the status
literal `EXST_DEFINED` was duplicated 4 times in new code.
- Introduces a `STATUS_DEFINED` constant and replaces all 4 occurrences.
No behavior change.
## Test plan
- [x] compileTestGroovy passes
- [x] checkstyleTest passes
- [x] codenarcTest passes
---
.../org/apache/ofbiz/example/test/ExampleJupiterTests.groovy | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
b/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
index 6bce353ec..676b0bb4f 100644
---
a/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
+++
b/example/src/test/groovy/org/apache/ofbiz/example/test/ExampleJupiterTests.groovy
@@ -48,6 +48,8 @@ import org.junit.jupiter.params.provider.MethodSource
@JunitJupiterTest
class ExampleJupiterTests implements JupiterTestHelper {
+ private static final String STATUS_DEFINED = 'EXST_DEFINED'
+
@Test
@Order(1)
void shouldCreateExample() {
@@ -91,7 +93,7 @@ class ExampleJupiterTests implements JupiterTestHelper {
String exampleId = createResult.exampleId
String updatedExampleName = testParams.updatedExampleName ?: 'Test
Example - After Update'
- String updatedStatusId = testParams.updatedStatusId ?: 'EXST_DEFINED'
+ String updatedStatusId = testParams.updatedStatusId ?: STATUS_DEFINED
Map<String, Object> updateResult = dispatcher.runSync('updateExample',
[
exampleId: exampleId,
@@ -132,7 +134,7 @@ class ExampleJupiterTests implements JupiterTestHelper {
Map<String, Object> secondStatusResult =
dispatcher.runSync('createExampleStatus', [
exampleId: exampleId,
- statusId: 'EXST_DEFINED',
+ statusId: STATUS_DEFINED,
userLogin: userLogin
])
assert ServiceUtil.isSuccess(secondStatusResult)
@@ -142,7 +144,7 @@ class ExampleJupiterTests implements JupiterTestHelper {
assert afterSecond.size() == 2
assert afterSecond[0].statusEndDate != null
assert afterSecond[1].statusEndDate == null
- assert afterSecond[1].statusId == 'EXST_DEFINED'
+ assert afterSecond[1].statusId == STATUS_DEFINED
}
@ParameterizedTest(name = '[{index}] exampleTypeId={0}')
@@ -231,7 +233,7 @@ class ExampleJupiterTests implements JupiterTestHelper {
private static List<Arguments> exampleCreationCases() {
[
Arguments.of('real-world-in-design', 'REAL_WORLD',
'EXST_IN_DESIGN', 'Test Example - Real World', true),
- Arguments.of('made-up-defined', 'MADE_UP', 'EXST_DEFINED',
'Test Example - Made Up', true),
+ Arguments.of('made-up-defined', 'MADE_UP', STATUS_DEFINED,
'Test Example - Made Up', true),
Arguments.of('contrived-approved', 'CONTRIVED',
'EXST_APPROVED', 'Test Example - Contrived', true),
Arguments.of('inspired-implemented', 'INSPIRED',
'EXST_IMPLEMENTED', 'Test Example - Inspired', true),
Arguments.of('missing-example-type-fails', null,
'EXST_IN_DESIGN', 'Test Example - Missing Type', false),