-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #574 from codecentric/add-events-to-track-service-…
…using-modulith Add events to track service using modulith
- Loading branch information
Showing
35 changed files
with
565 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
bases: | ||
- environments.yaml | ||
|
||
repositories: | ||
- name: bitnami-archive-full-index | ||
url: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | ||
|
||
releases: | ||
- name: kafka | ||
namespace: hc-kafka | ||
labels: | ||
service: kafka | ||
chart: bitnami-archive-full-index/kafka | ||
version: 25.3.1 | ||
values: | ||
- ./values/kafka-values.yaml.gotmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
environments: | ||
default: | ||
istio: | ||
linkerd: | ||
kuma: | ||
traefik-mesh: |
35 changes: 35 additions & 0 deletions
35
infrastructure/kubernetes/helmfile.d/values/kafka-values.yaml.gotmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
controller: | ||
replicaCount: 1 | ||
kraft: | ||
# generated with: uuidgen | tr -d '-' | base64 | cut -b 1-22 | ||
clusterId: "ZDQ2MzI3MWEwNmIwNGMyMT" | ||
sasl: | ||
interbroker: | ||
password: "kafka" | ||
controller: | ||
password: "kafka" | ||
client: | ||
users: | ||
- "track" | ||
passwords: | ||
- "track" | ||
|
||
externalAccess: | ||
enabled: true | ||
service: | ||
broker: | ||
type: LoadBalancer | ||
ports: | ||
external: 9094 | ||
controller: | ||
type: LoadBalancer | ||
containerPorts: | ||
external: 9094 | ||
autoDiscovery: | ||
enabled: true | ||
|
||
serviceAccount: | ||
create: true | ||
|
||
rbac: | ||
create: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../src/intTest/java/de/codecentric/habitcentric/track/habit/HabitModuleIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package de.codecentric.habitcentric.track.habit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import de.codecentric.habitcentric.track.auth.UserIdArgumentResolver; | ||
import java.time.LocalDate; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.modulith.test.ApplicationModuleTest; | ||
import org.springframework.modulith.test.Scenario; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@ActiveProfiles("intTest") | ||
@ApplicationModuleTest | ||
@MockBean(UserIdArgumentResolver.class) | ||
public class HabitModuleIntegrationTest { | ||
|
||
@Autowired private HabitTrackingController habitTrackingController; | ||
@Autowired private HabitTrackingRepository habitTrackingRepository; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
habitTrackingRepository.deleteAll(); | ||
} | ||
|
||
@Test | ||
void shouldPublishDateTrackedEventWhenHabitTrackingIsSaved(Scenario scenario) { | ||
habitTrackingRepository.save( | ||
HabitTracking.from("userId", 1L, Set.of(LocalDate.parse("2023-09-29")))); | ||
|
||
scenario | ||
.stimulate( | ||
() -> | ||
habitTrackingController.putHabitTrackingRecords( | ||
"userId", | ||
1L, | ||
Set.of(LocalDate.parse("2023-09-29"), LocalDate.parse("2023-09-30")))) | ||
.andWaitForEventOfType(HabitTracking.DateTracked.class) | ||
.toArriveAndVerify( | ||
event -> { | ||
assertThat(event.habitId()).isEqualTo(1L); | ||
assertThat(event.userId()).isEqualTo("userId"); | ||
assertThat(event.trackDate()).isEqualTo(LocalDate.parse("2023-09-30")); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldPublishDateUntrackedEventWhenExistingHabitTrackingIsRemoved(Scenario scenario) { | ||
habitTrackingRepository.save( | ||
HabitTracking.from( | ||
"userId", 1L, Set.of(LocalDate.parse("2023-09-29"), LocalDate.parse("2023-09-30")))); | ||
|
||
scenario | ||
.stimulate( | ||
() -> | ||
habitTrackingController.putHabitTrackingRecords( | ||
"userId", 1L, Set.of(LocalDate.parse("2023-09-29")))) | ||
.andWaitForEventOfType(HabitTracking.DateUntracked.class) | ||
.toArriveAndVerify( | ||
event -> { | ||
assertThat(event.habitId()).isEqualTo(1L); | ||
assertThat(event.userId()).isEqualTo("userId"); | ||
assertThat(event.trackDate()).isEqualTo(LocalDate.parse("2023-09-30")); | ||
}); | ||
} | ||
} |
Oops, something went wrong.