-
Notifications
You must be signed in to change notification settings - Fork 1
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 #505 from medizininformatik-initiative/500-make-de…
…faultpagesize-in-everythingdataselector-configurable Add `pageSize` to EverythingDataSelectorConfig
- Loading branch information
Showing
8 changed files
with
93 additions
and
24 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
42 changes: 35 additions & 7 deletions
42
...ical-domain-agent/src/main/java/care/smith/fts/cda/impl/EverythingDataSelectorConfig.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 |
---|---|---|
@@ -1,17 +1,45 @@ | ||
package care.smith.fts.cda.impl; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
import care.smith.fts.cda.services.FhirResolveConfig; | ||
import care.smith.fts.util.HttpClientConfig; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Setter(PRIVATE) | ||
@EqualsAndHashCode | ||
@ToString | ||
public final class EverythingDataSelectorConfig { | ||
|
||
public static int DEFAULT_PAGE_SIZE = 500; | ||
|
||
public record EverythingDataSelectorConfig( | ||
/* Server to fetch data from */ | ||
@NotNull HttpClientConfig fhirServer, | ||
private @NotNull HttpClientConfig fhirServer; | ||
private FhirResolveConfig resolve; | ||
private int pageSize = DEFAULT_PAGE_SIZE; | ||
|
||
/* */ | ||
FhirResolveConfig resolve) { | ||
private EverythingDataSelectorConfig() {} | ||
|
||
public EverythingDataSelectorConfig( | ||
HttpClientConfig fhirServer, FhirResolveConfig resolve, int pageSize) { | ||
this.fhirServer = fhirServer; | ||
this.resolve = resolve; | ||
checkArgument(pageSize > 0, "pageSize must be greater than 0"); | ||
this.pageSize = pageSize; | ||
} | ||
|
||
public @NotNull HttpClientConfig fhirServer() { | ||
return fhirServer; | ||
} | ||
|
||
public FhirResolveConfig resolve() { | ||
return resolve; | ||
} | ||
|
||
public EverythingDataSelectorConfig(HttpClientConfig fhirServer) { | ||
this(fhirServer, null); | ||
public int pageSize() { | ||
return pageSize; | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
...-domain-agent/src/test/java/care/smith/fts/cda/impl/EverythingDataSelectorConfigTest.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,23 @@ | ||
package care.smith.fts.cda.impl; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import care.smith.fts.util.HttpClientConfig; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class EverythingDataSelectorConfigTest { | ||
|
||
@Test | ||
void useDefaultIfPageSizeIsInvalid() { | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> { | ||
new EverythingDataSelectorConfig(new HttpClientConfig("http://localhost"), null, 0); | ||
}); | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> { | ||
new EverythingDataSelectorConfig(new HttpClientConfig("http://localhost"), null, -1); | ||
}); | ||
} | ||
} |
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