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
d9347cc4
Commit
d9347cc4
authored
7 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-6867 Change order of methods
parent
c53b2929
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/ozgcloud/admin/keycloak/GroupMapper.java
+9
-9
9 additions, 9 deletions
src/main/java/de/ozgcloud/admin/keycloak/GroupMapper.java
src/test/java/de/ozgcloud/admin/keycloak/GroupMapperTest.java
+59
-59
59 additions, 59 deletions
...test/java/de/ozgcloud/admin/keycloak/GroupMapperTest.java
with
68 additions
and
68 deletions
src/main/java/de/ozgcloud/admin/keycloak/GroupMapper.java
+
9
−
9
View file @
d9347cc4
...
...
@@ -23,15 +23,6 @@ abstract class GroupMapper {
public
abstract
List
<
Group
>
fromGroupRepresentations
(
List
<
GroupRepresentation
>
groupRepresentations
);
@AfterMapping
protected
void
deleteGroupsWithoutOrganisationsEinheitId
(
@MappingTarget
List
<
Group
>
groups
)
{
groups
.
removeIf
(
this
::
isMissingOrganisationsEinheitId
);
}
protected
boolean
isMissingOrganisationsEinheitId
(
Group
group
)
{
return
StringUtils
.
isBlank
(
group
.
getOrganisationsEinheitId
());
}
@Mapping
(
target
=
"organisationsEinheitId"
,
source
=
"attributes"
)
public
abstract
Group
fromGroupRepresentation
(
GroupRepresentation
groupRepresentation
);
...
...
@@ -49,6 +40,15 @@ abstract class GroupMapper {
return
values
.
getFirst
();
}
@AfterMapping
protected
void
deleteGroupsWithoutOrganisationsEinheitId
(
@MappingTarget
List
<
Group
>
groups
)
{
groups
.
removeIf
(
this
::
isMissingOrganisationsEinheitId
);
}
protected
boolean
isMissingOrganisationsEinheitId
(
Group
group
)
{
return
StringUtils
.
isBlank
(
group
.
getOrganisationsEinheitId
());
}
@Mapping
(
target
=
"attributes"
,
expression
=
"java(buildGroupAttributes(groupToAdd))"
)
public
abstract
GroupRepresentation
toGroupRepresentation
(
AddGroupData
groupToAdd
);
...
...
This diff is collapsed.
Click to expand it.
src/test/java/de/ozgcloud/admin/keycloak/GroupMapperTest.java
+
59
−
59
View file @
d9347cc4
...
...
@@ -93,65 +93,6 @@ class GroupMapperTest {
}
}
@Nested
class
TestDeleteGroupsWithoutOrganisationsEinheitId
{
private
final
Group
group
=
GroupTestFactory
.
create
();
private
final
List
<
Group
>
groups
=
new
ArrayList
<>();
@BeforeEach
void
init
()
{
groups
.
add
(
group
);
}
@Test
void
shouldCheckIfGroupHasOrganisationsEinheitId
()
{
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
verify
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
}
@Test
void
shouldKeepGroupsWithOrganisationsEinheitId
()
{
doReturn
(
false
).
when
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
assertThat
(
groups
).
containsExactly
(
group
);
}
@Test
void
shouldRemoveGroupsWithoutOrganisationsEinheitId
()
{
doReturn
(
true
).
when
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
assertThat
(
groups
).
isEmpty
();
}
}
@Nested
class
TestIsMissingOrganisationsEinheitId
{
@ParameterizedTest
@ValueSource
(
strings
=
" "
)
@NullAndEmptySource
void
shouldReturnTrueIfIdIsBlank
(
String
organisationsEinheitId
)
{
var
group
=
GroupTestFactory
.
createBuilder
().
organisationsEinheitId
(
organisationsEinheitId
).
build
();
var
isMissing
=
mapper
.
isMissingOrganisationsEinheitId
(
group
);
assertThat
(
isMissing
).
isTrue
();
}
@Test
void
shouldReturnFalseIfIdIsSet
()
{
var
isMissing
=
mapper
.
isMissingOrganisationsEinheitId
(
GroupTestFactory
.
create
());
assertThat
(
isMissing
).
isFalse
();
}
}
@Nested
class
TestFromGroupRepresentation
{
...
...
@@ -246,6 +187,65 @@ class GroupMapperTest {
}
}
@Nested
class
TestDeleteGroupsWithoutOrganisationsEinheitId
{
private
final
Group
group
=
GroupTestFactory
.
create
();
private
final
List
<
Group
>
groups
=
new
ArrayList
<>();
@BeforeEach
void
init
()
{
groups
.
add
(
group
);
}
@Test
void
shouldCheckIfGroupHasOrganisationsEinheitId
()
{
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
verify
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
}
@Test
void
shouldKeepGroupsWithOrganisationsEinheitId
()
{
doReturn
(
false
).
when
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
assertThat
(
groups
).
containsExactly
(
group
);
}
@Test
void
shouldRemoveGroupsWithoutOrganisationsEinheitId
()
{
doReturn
(
true
).
when
(
mapper
).
isMissingOrganisationsEinheitId
(
group
);
mapper
.
deleteGroupsWithoutOrganisationsEinheitId
(
groups
);
assertThat
(
groups
).
isEmpty
();
}
}
@Nested
class
TestIsMissingOrganisationsEinheitId
{
@ParameterizedTest
@ValueSource
(
strings
=
" "
)
@NullAndEmptySource
void
shouldReturnTrueIfIdIsBlank
(
String
organisationsEinheitId
)
{
var
group
=
GroupTestFactory
.
createBuilder
().
organisationsEinheitId
(
organisationsEinheitId
).
build
();
var
isMissing
=
mapper
.
isMissingOrganisationsEinheitId
(
group
);
assertThat
(
isMissing
).
isTrue
();
}
@Test
void
shouldReturnFalseIfIdIsSet
()
{
var
isMissing
=
mapper
.
isMissingOrganisationsEinheitId
(
GroupTestFactory
.
create
());
assertThat
(
isMissing
).
isFalse
();
}
}
@Nested
class
TestToGroupRepresentation
{
...
...
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