Skip to content

Commit 50a2cf3

Browse files
authored
Fix automated testing of sample modules (#509)
1 parent d5e029f commit 50a2cf3

File tree

13 files changed

+178
-147
lines changed

13 files changed

+178
-147
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ jobs:
6363
echo "COMMIT=${{ github.event.inputs.commit }}" >> $GITHUB_OUTPUT
6464
exit 0
6565
fi
66-
6766
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
6867
echo "COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
6968
exit 0
7069
fi
71-
7270
echo "Unable to determine commit SHA as the workflow was not triggered by a pull request and the commit input was not provided"
7371
exit 1
7472
@@ -81,6 +79,7 @@ jobs:
8179
uses: actions/checkout@v4
8280
with:
8381
ref: ${{ needs.context.outputs.commit }}
82+
8483
- name: "Setup Java"
8584
uses: actions/setup-java@v4
8685
with:
@@ -107,11 +106,13 @@ jobs:
107106
uses: actions/checkout@v4
108107
with:
109108
ref: ${{ needs.context.outputs.commit }}
109+
110110
- name: "Setup java"
111111
uses: actions/setup-java@v4
112112
with:
113113
distribution: "temurin"
114114
java-version: 17
115+
115116
- name: "Restore Dependencies"
116117
id: restore-dependencies
117118
uses: actions/cache/restore@v4
@@ -125,11 +126,10 @@ jobs:
125126
126127
if [[ "${{ github.event.inputs.build-release-artifacts }}" == "true" ]]; then
127128
echo "[DEBUG] Building release artifacts"
128-
129129
python .pipeline/scripts/generate-javadoc-sourcepath-properties.py
130130
MVN_ARGS="$MVN_ARGS javadoc:aggregate -Pdocs"
131131
fi
132-
132+
133133
echo "[DEBUG] Running Maven with following arguments: $MVN_ARGS"
134134
mvn $MVN_ARGS
135135
@@ -173,12 +173,14 @@ jobs:
173173
name: ${{ env.RELEASE_ARTIFACT_NAME }}
174174
path: ~/.sdk-release/${{ env.RELEASE_ARTIFACT_NAME }}
175175
retention-days: 1
176+
176177
- name: "Upload SDK M2"
177178
uses: actions/upload-artifact@v4
178179
with:
179180
name: ${{ env.SDK_M2_NAME }}
180181
path: ${{ env.SDK_M2_PATH }}
181182
retention-days: 1
183+
182184
- name: "Upload SDK Targets"
183185
uses: actions/upload-artifact@v4
184186
with:
@@ -195,22 +197,26 @@ jobs:
195197
uses: actions/checkout@v4
196198
with:
197199
ref: ${{ needs.context.outputs.commit }}
200+
198201
- name: "Setup java"
199202
uses: actions/setup-java@v4
200203
with:
201204
distribution: "temurin"
202205
java-version: 17
206+
203207
- name: "Restore Dependencies"
204208
id: restore-dependencies
205209
uses: actions/cache/restore@v4
206210
with:
207211
key: ${{ env.MAVEN_CACHE_KEY }}
208212
path: ${{ env.M2_ROOT }}
213+
209214
- name: "Restore SDK M2"
210215
uses: actions/download-artifact@v4
211216
with:
212217
name: ${{ env.SDK_M2_NAME }}
213218
path: ${{ env.M2_ROOT }}
219+
214220
- name: "Restore SDK Targets"
215221
uses: actions/download-artifact@v4
216222
with:
@@ -219,7 +225,6 @@ jobs:
219225
- name: "Run Unit Tests"
220226
run: |
221227
MVN_ARGS="${{ env.MVN_SINGLE_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report --fail-at-end"
222-
223228
echo "[DEBUG] Running Maven with arguments: $MVN_ARGS"
224229
mvn $MVN_ARGS
225230
@@ -253,22 +258,26 @@ jobs:
253258
uses: actions/checkout@v4
254259
with:
255260
ref: ${{ needs.context.outputs.commit }}
261+
256262
- name: "Setup java"
257263
uses: actions/setup-java@v4
258264
with:
259265
distribution: "temurin"
260266
java-version: 17
267+
261268
- name: "Restore Dependencies"
262269
id: restore-dependencies
263270
uses: actions/cache/restore@v4
264271
with:
265272
key: ${{ env.MAVEN_CACHE_KEY }}
266273
path: ${{ env.M2_ROOT }}
274+
267275
- name: "Restore SDK M2"
268276
uses: actions/download-artifact@v4
269277
with:
270278
name: ${{ env.SDK_M2_NAME }}
271279
path: ${{ env.M2_ROOT }}
280+
272281
- name: "Restore SDK Targets"
273282
uses: actions/download-artifact@v4
274283
with:
@@ -277,10 +286,8 @@ jobs:
277286
- name: "Run ${{ matrix.task.name }} Analysis"
278287
run: |
279288
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} ${{ matrix.task.mvn_goal }}"
280-
281289
echo "[DEBUG] Running Maven with arguments: $MVN_ARGS"
282290
mvn $MVN_ARGS
283-
284291
python ${{ matrix.task.report }}
285292
286293
code-ql:
@@ -292,11 +299,13 @@ jobs:
292299
uses: actions/checkout@v4
293300
with:
294301
ref: ${{ needs.context.outputs.commit }}
302+
295303
- name: "Setup java"
296304
uses: actions/setup-java@v4
297305
with:
298306
distribution: "temurin"
299307
java-version: 17
308+
300309
- name: "Restore Dependencies"
301310
id: restore-dependencies
302311
uses: actions/cache/restore@v4
@@ -313,7 +322,6 @@ jobs:
313322
- name: "Build SDK"
314323
run: |
315324
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} install -Dmaven.test.skip=true ${{ env.MVN_SKIP_CI_PLUGINS }}"
316-
317325
echo "[DEBUG] Running Maven with arguments: $MVN_ARGS"
318326
mvn $MVN_ARGS
319327
@@ -340,12 +348,14 @@ jobs:
340348
with:
341349
distribution: "temurin"
342350
java-version: 17
351+
343352
- name: "Restore Dependencies"
344353
id: restore-dependencies
345354
uses: actions/cache/restore@v4
346355
with:
347356
key: ${{ env.MAVEN_CACHE_KEY }}
348357
path: ${{ env.MAVEN_CACHE_DIR }}
358+
349359
- name: "Restore SDK M2"
350360
uses: actions/download-artifact@v4
351361
with:
@@ -393,13 +403,11 @@ jobs:
393403
cat $logFilePath
394404
exit 1
395405
fi
396-
397406
if ! grep -q "I am running!" $logFilePath; then
398407
echo "Project generated from archetype '${{ matrix.task.archetype }}' started locally, but did not contain the expected log output."
399408
cat $logFilePath
400409
exit 1
401410
fi
402-
403411
if grep -iq "caused by" $logFilePath; then
404412
echo "Project generated from archetype '${{ matrix.task.archetype }}' started locally, but an unexpected error occurred."
405413
cat $logFilePath

datamodel/odata-v4/odata-v4-api-sample/pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,34 @@
167167
<skip>false</skip>
168168
</configuration>
169169
</plugin>
170+
<plugin>
171+
<groupId>org.apache.maven.plugins</groupId>
172+
<artifactId>maven-checkstyle-plugin</artifactId>
173+
<configuration>
174+
<skip>true</skip>
175+
</configuration>
176+
</plugin>
177+
<plugin>
178+
<groupId>org.apache.maven.plugins</groupId>
179+
<artifactId>maven-pmd-plugin</artifactId>
180+
<configuration>
181+
<skip>true</skip>
182+
</configuration>
183+
</plugin>
184+
<plugin>
185+
<groupId>org.apache.maven.plugins</groupId>
186+
<artifactId>maven-javadoc-plugin</artifactId>
187+
<configuration>
188+
<skip>true</skip>
189+
</configuration>
190+
</plugin>
191+
<plugin>
192+
<groupId>org.jacoco</groupId>
193+
<artifactId>jacoco-maven-plugin</artifactId>
194+
<configuration>
195+
<skip>true</skip>
196+
</configuration>
197+
</plugin>
170198
</plugins>
171199
</build>
172200
</project>

datamodel/odata-v4/pom.xml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<module>odata-v4-core</module>
3434
<module>odata-v4-generator</module>
3535
<module>odata-v4-generator-maven-plugin</module>
36+
<module>odata-v4-api-sample</module>
3637
</modules>
3738
<scm>
3839
<connection />
@@ -45,18 +46,4 @@
4546
<project.rootdir>${project.basedir}/../../../</project.rootdir>
4647
<japicmp.skip>true</japicmp.skip>
4748
</properties>
48-
<profiles>
49-
<profile>
50-
<id>code.scans.included</id>
51-
<activation>
52-
<activeByDefault>false</activeByDefault>
53-
<property>
54-
<name>sdk.code.scanning</name>
55-
</property>
56-
</activation>
57-
<modules>
58-
<module>odata-v4-api-sample</module>
59-
</modules>
60-
</profile>
61-
</profiles>
6249
</project>

datamodel/odata/odata-api-sample/pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,34 @@
197197
<skip>false</skip>
198198
</configuration>
199199
</plugin>
200+
<plugin>
201+
<groupId>org.apache.maven.plugins</groupId>
202+
<artifactId>maven-checkstyle-plugin</artifactId>
203+
<configuration>
204+
<skip>true</skip>
205+
</configuration>
206+
</plugin>
207+
<plugin>
208+
<groupId>org.apache.maven.plugins</groupId>
209+
<artifactId>maven-pmd-plugin</artifactId>
210+
<configuration>
211+
<skip>true</skip>
212+
</configuration>
213+
</plugin>
214+
<plugin>
215+
<groupId>org.apache.maven.plugins</groupId>
216+
<artifactId>maven-javadoc-plugin</artifactId>
217+
<configuration>
218+
<skip>true</skip>
219+
</configuration>
220+
</plugin>
221+
<plugin>
222+
<groupId>org.jacoco</groupId>
223+
<artifactId>jacoco-maven-plugin</artifactId>
224+
<configuration>
225+
<skip>true</skip>
226+
</configuration>
227+
</plugin>
200228
</plugins>
201229
</build>
202230
</project>

datamodel/odata/odata-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odata/sample/ExtendedEntityClassTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545

4646
class ExtendedEntityClassTest
4747
{
48-
private static final String PRODUCT_INPUT =
49-
"""
48+
private static final String PRODUCT_INPUT = """
5049
{
5150
"versionIdentifier": "testVersion",
5251
"Id": "1005",
@@ -56,8 +55,7 @@ class ExtendedEntityClassTest
5655
"Shoesize": 8
5756
}
5857
""";
59-
private static final String EXPECTED_PRODUCT_OUTPUT =
60-
"""
58+
private static final String EXPECTED_PRODUCT_OUTPUT = """
6159
{
6260
"versionIdentifier":"testVersion",
6361
"Id":1005,
@@ -185,7 +183,7 @@ void testGsonSerialization()
185183
final String actualSerializedProduct = gsonBuilder.create().toJson(customProduct);
186184

187185
assertThat(actualSerializedProduct).isNotNull();
188-
assertThat(actualSerializedProduct).isEqualTo(EXPECTED_PRODUCT_OUTPUT);
186+
assertThat(actualSerializedProduct).isEqualToIgnoringNewLines(EXPECTED_PRODUCT_OUTPUT);
189187
}
190188

191189
@Test
@@ -220,7 +218,7 @@ void testJacksonSerialization()
220218
final ObjectMapper mapper = new ObjectMapper();
221219
final String actualSerializedProduct = mapper.writeValueAsString(customProduct);
222220

223-
assertThat(actualSerializedProduct).isNotNull().isEqualTo(EXPECTED_PRODUCT_OUTPUT);
221+
assertThat(actualSerializedProduct).isNotNull().isEqualToIgnoringNewLines(EXPECTED_PRODUCT_OUTPUT);
224222
}
225223

226224
@Test

datamodel/odata/odata-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odata/sample/FluentHelperCreateODataClientTest.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ void testHeaders()
9393
@Test
9494
void testEntitySerialization()
9595
{
96-
final String request =
97-
"""
96+
final String request = """
9897
{
9998
"Name": "Product",
10099
"Price": "19.99",
@@ -104,25 +103,25 @@ void testEntitySerialization()
104103
""";
105104
final String response =
106105
"""
107-
{
108-
"d": {
109-
"__metadata": {
110-
"id": "https://127.0.0.1/com.sap.cloud.sdk.store.grocery/Products(44444)",
111-
"uri": "https://127.0.0.1/com.sap.cloud.sdk.store.grocery/Products(44444)",
112-
"type": "SdkGroceryStore.ProductType",
113-
"etag": "W/\\"datetimeoffset'2023-04-18T10%3A55%3A00.5351290Z'\\""
114-
},
115-
"Id": "44444",
116-
"Name": "Product",
117-
"Price": "19.99",
118-
"VendorId": 42,
119-
"Image": "AQID",
120-
"ShelfId": null,
121-
"Vendor": {"__deferred": {"uri": "https://127.0.0.1//com.sap.cloud.sdk.store.grocery/Products(44444)/Vendor"}},
122-
"Shelf": {"__deferred": {"uri": "https://127.0.0.1//com.sap.cloud.sdk.store.grocery/Products(44444)/Shelf"}}
123-
}
124-
}
125-
""";
106+
{
107+
"d": {
108+
"__metadata": {
109+
"id": "https://127.0.0.1/com.sap.cloud.sdk.store.grocery/Products(44444)",
110+
"uri": "https://127.0.0.1/com.sap.cloud.sdk.store.grocery/Products(44444)",
111+
"type": "SdkGroceryStore.ProductType",
112+
"etag": "W/\\"datetimeoffset'2023-04-18T10%3A55%3A00.5351290Z'\\""
113+
},
114+
"Id": "44444",
115+
"Name": "Product",
116+
"Price": "19.99",
117+
"VendorId": 42,
118+
"Image": "AQID",
119+
"ShelfId": null,
120+
"Vendor": {"__deferred": {"uri": "https://127.0.0.1//com.sap.cloud.sdk.store.grocery/Products(44444)/Vendor"}},
121+
"Shelf": {"__deferred": {"uri": "https://127.0.0.1//com.sap.cloud.sdk.store.grocery/Products(44444)/Shelf"}}
122+
}
123+
}
124+
""";
126125

127126
stubFor(head(anyUrl()).willReturn(serverError()));
128127
stubFor(post(urlEqualTo(ODATA_QUERY_URL)).withRequestBody(equalToJson(request)).willReturn(okJson(response)));

0 commit comments

Comments
 (0)