Skip to content

Commit 92c2ce7

Browse files
committed
Implement checkout-service
1 parent f9030bd commit 92c2ce7

106 files changed

Lines changed: 18513 additions & 191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
{
2-
"name": "Online Shop",
3-
"build": {
4-
"dockerfile": "Dockerfile"
5-
},
6-
"features": {
7-
"ghcr.io/devcontainers/features/java:1": {
8-
"version": "none",
9-
"installMaven": "true",
10-
"mavenVersion": "3.8.6",
11-
"installGradle": "false"
2+
"name": "Workshop Migration",
3+
"forwardPorts": [80, 4001],
4+
"portsAttributes": {
5+
"80": {
6+
"label": "Online Shop",
7+
"visibility": "public"
128
},
139
"ghcr.io/devcontainers/features/docker-in-docker:2": {
1410
"dockerDashComposeVersion": "v2"
1511
}
1612
},
17-
"postCreateCommand": "cd golden-master-tests && npm ci && npx playwright install --with-deps chromium",
18-
"postStartCommand": "docker compose up -d && cd golden-master-tests && npm run test:ui:codespaces",
13+
"postCreateCommand": "rm -f /etc/apt/sources.list.d/yarn.list && cd golden-master-tests && npm ci && npx playwright install --with-deps chromium",
14+
"postStartCommand": ".devcontainer/setup.sh && docker compose up -d && cd golden-master-tests && npm run test:ui:codespaces",
1915
"customizations": {
2016
"vscode": {
2117
"settings": {},

.devcontainer/setup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ -n "$CODESPACE_NAME" ]; then
5+
DOMAIN="${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN:-app.github.dev}"
6+
cat > "$(dirname "$0")/../.env" << ENVEOF
7+
ONLINE_SHOP_EXTERNAL_URL=https://${CODESPACE_NAME}-80.${DOMAIN}
8+
CHECKOUT_EXTERNAL_URL=https://${CODESPACE_NAME}-4001.${DOMAIN}
9+
ENVEOF
10+
echo "Codespaces URLs configured:"
11+
echo " Online Shop: https://${CODESPACE_NAME}-80.${DOMAIN}"
12+
echo " Checkout Service: https://${CODESPACE_NAME}-4001.${DOMAIN}"
13+
fi

README.md

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,10 @@ um in die Datenbank zu schauen.
2929

3030
## Aufgabe
3131

32-
Die Datei `checkout.spec.ts` im Ordner `golden-master-tests/tests`
33-
enthält einen UI-Test mit dem Framework Playwright.
34-
Führen Sie den Test aus und schauen Sie, dass er grün ist.
35-
Überlegen Sie, welche weiteren Pfade durch den Bestellabschluss es geben könnte.
36-
Schreiben Sie Tests für diese Fälle.
37-
Schreiben Sie auch Tests für das Pflegen der Adressen in der Kundenverwaltung.
32+
Führen Sie den Golden Master Test aus.
33+
Sie werden feststellen, dass er fehlschlägt.
34+
Was ist das Problem?
3835

39-
## Tests ausführen
36+
Analysieren Sie den Unterschied in der Tabelle `tab_order` zu der monolithischen Variante.
4037

41-
### Lokal
42-
43-
```
44-
cd golden-master-tests
45-
npm install
46-
npx playwright install --with-deps chromium
47-
npm test
48-
```
49-
50-
Die Playwright UI lässt sich lokal folgendermaßen starten:
51-
52-
```
53-
npm run test:ui
54-
```
55-
56-
### GitHub Codespaces
57-
58-
Im Codespace sind alle Abhängigkeiten bereits installiert. Die Playwright VS Code Extension
59-
ist vorinstalliert und ermöglicht das Ausführen und Debuggen der Tests direkt im Editor.
60-
61-
Alternativ lässt sich die Playwright UI über das Terminal starten:
62-
63-
```
64-
cd golden-master-tests
65-
npm run test:ui:codespaces
66-
```
67-
68-
Anschließend öffnet GitHub Codespaces automatisch einen Dialog zum Weiterleiten von Port `8832`.
69-
Die Playwright UI ist dann über den angezeigten Link im Browser erreichbar.
38+
Beheben Sie das Problem.

checkout-service/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM maven:3.9.9-eclipse-temurin-21 AS mvn
2+
3+
WORKDIR /usr/src/online-shop
4+
COPY pom.xml ./
5+
RUN mvn package dependency:go-offline # cache dependencies
6+
COPY src ./src
7+
RUN mvn clean package -Dservice.name=checkout-service -DskipTests
8+
9+
FROM eclipse-temurin:21-jre
10+
11+
EXPOSE 8080
12+
COPY --from=mvn /usr/src/online-shop/target/runner/meecrowave-core-runner.jar /opt/meecrowave-runner.jar
13+
COPY --from=mvn /usr/src/online-shop/target/checkout-service.war /opt/checkout-service.war
14+
COPY src/main/resources/log4j2.xml /opt/log4j2.xml
15+
ENTRYPOINT ["java", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "--illegal-access=permit", "-Djava.net.preferIPv4Stack=true", "-Dlog4j2.configurationFile=/opt/log4j2.xml", "-jar", "/opt/meecrowave-runner.jar", "--webapp", "/opt/checkout-service.war"]

checkout-service/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# JAX-RS server with OpenAPI
2+
3+
## Overview
4+
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using an
5+
[OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
6+
7+
This is an example of building a OpenAPI-enabled JAX-RS server.
8+
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework.
9+
10+
11+
The JAX-RS implementation needs to be provided by the application server you are deploying on.
12+
13+
To run the server from the command line, you can use maven to provision and start a TomEE Server.
14+
Please execute the following:
15+
16+
```
17+
mvn -Dtomee-embedded-plugin.http=9081 package org.apache.tomee.maven:tomee-embedded-maven-plugin:7.0.5:run
18+
```
19+
20+
You can then call your server endpoints under:
21+
22+
```
23+
http://localhost:9081/checkout-service/
24+
```
25+
26+
Note that if you have configured the `host` to be something other than localhost, the calls through
27+
swagger-ui will be directed to that host and not localhost!

checkout-service/pom.xml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- ~ Copyright (C) open knowledge GmbH. ~ ~ Licensed under the Apache License,
3+
Version 2.0 (the "License"); you may not use this file except in compliance
4+
with ~ the License. You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
5+
~ ~ Unless required by applicable law or agreed to in writing, software distributed
6+
under the License is distributed on ~ an "AS IS" BASIS, WITHOUT WARRANTIES
7+
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
8+
the ~ specific language governing permissions and limitations under the License. -->
9+
10+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
12+
<modelVersion>4.0.0</modelVersion>
13+
14+
<groupId>de.openkonwledge.sample.shop</groupId>
15+
<artifactId>checkout-service</artifactId>
16+
<version>1.0.0-SNAPSHOT</version>
17+
<packaging>war</packaging>
18+
19+
<properties>
20+
<service.name>online-shop</service.name>
21+
<maven.compiler.source>17</maven.compiler.source>
22+
<maven.compiler.target>17</maven.compiler.target>
23+
<failOnMissingWebXml>false</failOnMissingWebXml>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
<meecrowave.version>1.2.13</meecrowave.version>
26+
<junit.version>5.8.2</junit.version>
27+
</properties>
28+
29+
<dependencies>
30+
31+
<dependency>
32+
<groupId>org.apache.meecrowave</groupId>
33+
<artifactId>meecrowave-specs-api</artifactId>
34+
<version>${meecrowave.version}</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.apache.meecrowave</groupId>
39+
<artifactId>meecrowave-core</artifactId>
40+
<version>${meecrowave.version}</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.thymeleaf</groupId>
45+
<artifactId>thymeleaf</artifactId>
46+
<version>3.0.14.RELEASE</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.apache.geronimo.specs</groupId>
50+
<artifactId>geronimo-validation_2.0_spec</artifactId>
51+
<version>1.0</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.apache.bval</groupId>
55+
<artifactId>bval-jsr</artifactId>
56+
<version>2.0.6</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.eclipse.microprofile.config</groupId>
60+
<artifactId>microprofile-config-api</artifactId>
61+
<version>1.3</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.apache.geronimo.config</groupId>
65+
<artifactId>geronimo-config-impl</artifactId>
66+
<version>1.2.2</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.eclipse.microprofile.openapi</groupId>
70+
<artifactId>microprofile-openapi-api</artifactId>
71+
<version>1.1.2</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.apache.geronimo</groupId>
75+
<artifactId>geronimo-openapi-impl</artifactId>
76+
<version>1.0.12</version>
77+
<scope>runtime</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.webjars</groupId>
81+
<artifactId>swagger-ui</artifactId>
82+
<version>5.4.2</version>
83+
<scope>runtime</scope>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>org.apache.commons</groupId>
88+
<artifactId>commons-lang3</artifactId>
89+
<version>3.9</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.apache.commons</groupId>
93+
<artifactId>commons-io</artifactId>
94+
<version>1.3.2</version>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.hibernate.orm</groupId>
98+
<artifactId>hibernate-core</artifactId>
99+
<version>6.4.0.Final</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.slf4j</groupId>
103+
<artifactId>slf4j-simple</artifactId>
104+
<version>1.7.25</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.postgresql</groupId>
108+
<artifactId>postgresql</artifactId>
109+
<version>42.7.0</version>
110+
</dependency>
111+
112+
<dependency>
113+
<groupId>org.junit.jupiter</groupId>
114+
<artifactId>junit-jupiter-api</artifactId>
115+
<version>${junit.version}</version>
116+
<scope>test</scope>
117+
</dependency>
118+
<dependency>
119+
<groupId>org.junit.jupiter</groupId>
120+
<artifactId>junit-jupiter-engine</artifactId>
121+
<version>${junit.version}</version>
122+
<scope>test</scope>
123+
</dependency>
124+
<dependency>
125+
<groupId>org.assertj</groupId>
126+
<artifactId>assertj-core</artifactId>
127+
<version>3.22.0</version>
128+
<scope>test</scope>
129+
</dependency>
130+
<dependency>
131+
<groupId>org.apache.meecrowave</groupId>
132+
<artifactId>meecrowave-junit</artifactId>
133+
<version>${meecrowave.version}</version>
134+
<scope>test</scope>
135+
</dependency>
136+
<dependency>
137+
<groupId>org.testcontainers</groupId>
138+
<artifactId>junit-jupiter</artifactId>
139+
<version>1.19.3</version>
140+
<scope>test</scope>
141+
</dependency>
142+
<dependency>
143+
<groupId>org.testcontainers</groupId>
144+
<artifactId>postgresql</artifactId>
145+
<version>1.19.3</version>
146+
<scope>test</scope>
147+
</dependency>
148+
<dependency>
149+
<groupId>org.flywaydb</groupId>
150+
<artifactId>flyway-core</artifactId>
151+
<version>9.21.0</version>
152+
<scope>test</scope>
153+
</dependency>
154+
<dependency>
155+
<groupId>au.com.dius.pact.consumer</groupId>
156+
<artifactId>junit5</artifactId>
157+
<version>4.3.15</version>
158+
<scope>test</scope>
159+
</dependency>
160+
<dependency>
161+
<groupId>au.com.dius.pact.provider</groupId>
162+
<artifactId>junit5</artifactId>
163+
<version>4.3.15</version>
164+
<scope>test</scope>
165+
</dependency>
166+
</dependencies>
167+
<build>
168+
<finalName>${project.artifactId}</finalName>
169+
<plugins>
170+
<plugin>
171+
<groupId>org.apache.maven.plugins</groupId>
172+
<artifactId>maven-surefire-plugin</artifactId>
173+
<version>3.1.2</version>
174+
<configuration>
175+
<systemPropertyVariables>
176+
<org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>false</org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>
177+
</systemPropertyVariables>
178+
</configuration>
179+
</plugin>
180+
<plugin>
181+
<groupId>org.apache.maven.plugins</groupId>
182+
<artifactId>maven-war-plugin</artifactId>
183+
<version>3.4.0</version>
184+
</plugin>
185+
<plugin>
186+
<groupId>org.apache.maven.plugins</groupId>
187+
<artifactId>maven-dependency-plugin</artifactId>
188+
<version>3.6.1</version>
189+
<executions>
190+
<execution>
191+
<id>copy-runner</id>
192+
<phase>package</phase>
193+
<goals>
194+
<goal>copy</goal>
195+
</goals>
196+
<configuration>
197+
<artifactItems>
198+
<artifactItem>
199+
<groupId>org.apache.meecrowave</groupId>
200+
<artifactId>meecrowave-core</artifactId>
201+
<version>${meecrowave-version}</version>
202+
<classifier>runner</classifier>
203+
</artifactItem>
204+
</artifactItems>
205+
<outputDirectory>${project.build.directory}/runner</outputDirectory>
206+
<stripVersion>true</stripVersion>
207+
</configuration>
208+
</execution>
209+
</executions>
210+
</plugin>
211+
<plugin>
212+
<artifactId>maven-checkstyle-plugin</artifactId>
213+
<version>3.4.0</version>
214+
<configuration>
215+
<headerLocation>${project.basedir}/src/main/checkstyle/java.header</headerLocation>
216+
<failsOnError>true</failsOnError>
217+
<consoleOutput>true</consoleOutput>
218+
</configuration>
219+
<executions>
220+
<execution>
221+
<id>compile</id>
222+
<phase>compile</phase>
223+
<goals>
224+
<goal>checkstyle</goal>
225+
</goals>
226+
<configuration>
227+
<configLocation>${project.basedir}/src/main/checkstyle/configuration.xml</configLocation>
228+
<includeTestSourceDirectory>false</includeTestSourceDirectory>
229+
</configuration>
230+
</execution>
231+
<execution>
232+
<id>test-compile</id>
233+
<phase>test-compile</phase>
234+
<goals>
235+
<goal>checkstyle</goal>
236+
</goals>
237+
<configuration>
238+
<configLocation>${project.basedir}/src/main/checkstyle/test-configuration.xml</configLocation>
239+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
240+
</configuration>
241+
</execution>
242+
</executions>
243+
</plugin>
244+
</plugins>
245+
</build>
246+
</project>

0 commit comments

Comments
 (0)