Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
administration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
administration
Commits
910f87f5
Commit
910f87f5
authored
4 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-7239 OZG-7286 Handle case when postfach setting has no body
parent
e12ac2e6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/ozgcloud/admin/setting/SettingService.java
+4
-2
4 additions, 2 deletions
src/main/java/de/ozgcloud/admin/setting/SettingService.java
src/test/java/de/ozgcloud/admin/setting/SettingServiceTest.java
+18
-6
18 additions, 6 deletions
...st/java/de/ozgcloud/admin/setting/SettingServiceTest.java
with
22 additions
and
8 deletions
src/main/java/de/ozgcloud/admin/setting/SettingService.java
+
4
−
2
View file @
910f87f5
...
...
@@ -64,8 +64,10 @@ class SettingService {
}
PostfachSettingBody
getSettingWithPostfachFromDb
()
{
var
postfach
=
repository
.
findOneByName
(
POSTFACH_SETTING_ITEM_NAME
);
return
postfach
.
isPresent
()
?
(
PostfachSettingBody
)
postfach
.
get
().
getSettingBody
()
:
PostfachSettingBody
.
builder
().
build
();
return
repository
.
findOneByName
(
POSTFACH_SETTING_ITEM_NAME
)
.
map
(
Setting:
:
getSettingBody
)
.
map
(
PostfachSettingBody
.
class
::
cast
)
.
orElse
(
PostfachSettingBody
.
builder
().
build
());
}
Map
<
String
,
OrganisationsEinheitSettings
>
getOrganisationsEinheitSettings
()
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/de/ozgcloud/admin/setting/SettingServiceTest.java
+
18
−
6
View file @
910f87f5
...
...
@@ -62,9 +62,6 @@ class SettingServiceTest {
private
final
PostfachSettingBody
postfach
=
PostfachSettingBodyTestFactory
.
create
();
private
static
final
String
POSTFACH
=
"Postfach"
;
private
final
Setting
settingWithPostfach
=
SettingTestFactory
.
createBuilder
().
name
(
POSTFACH
).
settingBody
(
postfach
).
build
();
@Nested
class
TestGetAlfaSettingDTO
{
...
...
@@ -147,9 +144,15 @@ class SettingServiceTest {
@Nested
class
TestGetSettingWithPostfachFromDb
{
private
static
final
String
POSTFACH
=
"Postfach"
;
private
final
Setting
emptyPostfachSetting
=
SettingTestFactory
.
createBuilder
().
name
(
POSTFACH
).
build
();
private
final
Setting
postfachSettingWithBody
=
SettingTestFactory
.
createBuilder
().
name
(
POSTFACH
).
settingBody
(
postfach
).
build
();
@Test
void
shouldCallRepository
()
{
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
of
(
s
ettingWith
Postfach
));
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
of
(
postfachS
ettingWith
Body
));
service
.
getSettingWithPostfachFromDb
();
...
...
@@ -158,7 +161,7 @@ class SettingServiceTest {
@Test
void
shouldReturnPostfachSettingBody
()
{
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
of
(
s
ettingWith
Postfach
));
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
of
(
postfachS
ettingWith
Body
));
var
returnedBody
=
service
.
getSettingWithPostfachFromDb
();
...
...
@@ -166,13 +169,22 @@ class SettingServiceTest {
}
@Test
void
shouldReturnEmptyPostfachSettingBody
ForEmptySetting
()
{
void
shouldReturnEmptyPostfachSettingBody
WhenSettingNotFound
()
{
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
empty
());
var
returnedBody
=
service
.
getSettingWithPostfachFromDb
();
assertThat
(
returnedBody
).
usingRecursiveComparison
().
isEqualTo
(
PostfachSettingBody
.
builder
().
build
());
}
@Test
void
shouldReturnEmptyPostfachSettingBodyForSettingWithoutBody
()
{
when
(
repository
.
findOneByName
(
POSTFACH
)).
thenReturn
(
Optional
.
of
(
emptyPostfachSetting
));
var
returnedBody
=
service
.
getSettingWithPostfachFromDb
();
assertThat
(
returnedBody
).
usingRecursiveComparison
().
isEqualTo
(
PostfachSettingBody
.
builder
().
build
());
}
}
@Nested
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment