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
d171d91d
Commit
d171d91d
authored
1 year ago
by
Lukas Malte Monnerjahn
Browse files
Options
Downloads
Patches
Plain Diff
OZG-4948 OZG-5058 Simplify test
parent
a98b0e30
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/de/ozgcloud/admin/migration/M001_CreateEmptyPostfachIfMissingITCase.java
+25
-20
25 additions, 20 deletions
...in/migration/M001_CreateEmptyPostfachIfMissingITCase.java
with
25 additions
and
20 deletions
src/test/java/de/ozgcloud/admin/migration/M001_CreateEmptyPostfachIfMissingITCase.java
+
25
−
20
View file @
d171d91d
...
...
@@ -12,6 +12,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import
java.util.List
;
import
static
de
.
ozgcloud
.
admin
.
migration
.
M001_CreateEmptyPostfachIfMissing
.
SETTINGS_COLLECTION
;
import
static
de
.
ozgcloud
.
admin
.
migration
.
M001_CreateEmptyPostfachIfMissing
.
TYPE_NAME_KEY
;
import
static
org
.
assertj
.
core
.
api
.
AssertionsForInterfaceTypes
.
assertThat
;
@DataITCase
...
...
@@ -36,8 +37,12 @@ class M001_CreateEmptyPostfachIfMissingITCase {
changeUnit
.
doMigration
(
template
);
List
<
Document
>
settings
=
findAllSettings
();
assertThat
(
settings
).
hasSize
(
1
)
.
anyMatch
(
this
::
isEmptyPostfachSetting
);
assertThat
(
settings
).
hasSize
(
1
);
Document
document
=
settings
.
getFirst
();
System
.
out
.
println
(
document
);
assertThat
(
document
)
.
usingRecursiveComparison
().
ignoringFields
(
"_id"
)
.
isEqualTo
(
MigrationTestFactory
.
createEmptyPostfach
());
}
@Test
...
...
@@ -48,9 +53,9 @@ class M001_CreateEmptyPostfachIfMissingITCase {
changeUnit
.
doMigration
(
template
);
List
<
Document
>
settings
=
findAllSettings
();
assertThat
(
settings
)
.
hasSize
(
2
)
.
anyMatch
(
this
::
isEmptyPostfachSetting
)
.
contains
(
settingItem
);
assertThat
(
settings
)
.
extracting
(
TYPE_NAME_KEY
)
.
contains
Exactly
(
"SomeType"
,
MigrationTestFactory
.
ITEM_TYPE_VALUE_POSTFACH
);
}
@Test
...
...
@@ -67,27 +72,13 @@ class M001_CreateEmptyPostfachIfMissingITCase {
return
template
.
findAll
(
Document
.
class
,
SETTINGS_COLLECTION
);
}
private
boolean
isEmptyPostfachSetting
(
Document
document
)
{
return
document
.
containsKey
(
MigrationTestFactory
.
ITEM_TYPE_KEY
)
&&
document
.
get
(
MigrationTestFactory
.
ITEM_TYPE_KEY
)
.
equals
(
MigrationTestFactory
.
ITEM_TYPE_VALUE_POSTFACH
)
&&
!
document
.
containsKey
(
MigrationTestFactory
.
ITEM_SETTINGS_KEY
);
}
}
static
class
MigrationTestFactory
{
public
static
final
String
ITEM_TYPE_KEY
=
"name"
;
public
static
final
String
ITEM_SETTINGS_KEY
=
"settings"
;
static
Document
createSettingsItem
(
String
itemType
,
Document
itemValue
)
{
var
settingsItem
=
new
Document
();
settingsItem
.
put
(
ITEM_TYPE_KEY
,
itemType
);
settingsItem
.
put
(
ITEM_SETTINGS_KEY
,
itemValue
);
return
settingsItem
;
}
public
static
final
String
ITEM_ID
=
"_id"
;
public
static
final
String
ITEM_TYPE_VALUE_POSTFACH
=
"Postfach"
;
public
static
final
String
POSTFACH_ABSENDER_KEY
=
"absender"
;
...
...
@@ -97,5 +88,19 @@ class M001_CreateEmptyPostfachIfMissingITCase {
return
createSettingsItem
(
ITEM_TYPE_VALUE_POSTFACH
,
postfach
);
}
static
Document
createEmptyPostfach
()
{
var
postfach
=
new
Document
();
postfach
.
put
(
ITEM_TYPE_KEY
,
ITEM_TYPE_VALUE_POSTFACH
);
postfach
.
put
(
ITEM_ID
,
null
);
return
postfach
;
}
static
Document
createSettingsItem
(
String
itemType
,
Document
itemValue
)
{
var
settingsItem
=
new
Document
();
settingsItem
.
put
(
ITEM_TYPE_KEY
,
itemType
);
settingsItem
.
put
(
ITEM_SETTINGS_KEY
,
itemValue
);
return
settingsItem
;
}
}
}
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