Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nachrichten-manager
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
nachrichten-manager
Commits
3e944211
Commit
3e944211
authored
9 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-6362 Test aktualisiert.
parent
abd99cb8
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
nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java
+10
-35
10 additions, 35 deletions
...de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java
with
10 additions
and
35 deletions
nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java
+
10
−
35
View file @
3e944211
...
...
@@ -22,14 +22,12 @@
*/
package
de.ozgcloud.nachrichten.postfach
;
import
static
de
.
ozgcloud
.
nachrichten
.
postfach
.
PersistPostfachNachrichtServiceImpl
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.*;
import
static
org
.
mockito
.
Mockito
.*;
import
java.time.ZonedDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.UUID
;
import
java.util.stream.Stream
;
...
...
@@ -52,7 +50,6 @@ import org.springframework.boot.logging.LogLevel;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
de.ozgcloud.common.errorhandling.TechnicalException
;
import
de.ozgcloud.nachrichten.antragraum.AntragraumService
;
import
de.ozgcloud.nachrichten.attributes.ClientAttributeService
;
import
de.ozgcloud.nachrichten.info.InfoManagerService
;
...
...
@@ -68,24 +65,23 @@ import nl.altindag.log.LogCaptor;
class
PostfachServiceTest
{
static
final
String
COMMAND_ID
=
UUID
.
randomUUID
().
toString
();
static
final
String
USER_ID
=
UUID
.
randomUUID
().
toString
();
@Spy
@InjectMocks
private
PostfachService
service
;
@Mock
private
PostfachRemoteService
postfachRemoteService
;
@Mock
private
PersistPostfachNachrichtService
persistingService
;
@Spy
private
PostfachNachrichtMapper
mapper
=
Mappers
.
getMapper
(
PostfachNachrichtMapper
.
class
);
@Mock
private
ClientAttributeService
clientAttributeService
;
@Mock
private
MessageAttachmentService
messageAttachmentService
;
@Mock
private
ApplicationEventPublisher
publisher
;
@Mock
private
CurrentUserService
userService
;
@Spy
...
...
@@ -93,9 +89,6 @@ class PostfachServiceTest {
@Spy
private
Optional
<
InfoManagerService
>
infomanagerService
=
Optional
.
of
(
mock
(
InfoManagerService
.
class
));
static
final
String
COMMAND_ID
=
UUID
.
randomUUID
().
toString
();
static
final
String
USER_ID
=
UUID
.
randomUUID
().
toString
();
@Nested
class
TestSaveDraft
{
...
...
@@ -316,6 +309,10 @@ class PostfachServiceTest {
@Mock
private
PostfachNachricht
mail
;
private
Optional
<
PostfachNachricht
>
adjustMail
()
{
return
service
.
adjustMail
(
mail
);
}
@Nested
class
TestReplaceBody
{
...
...
@@ -339,10 +336,6 @@ class PostfachServiceTest {
assertThat
(
result
).
isPresent
().
get
().
extracting
(
PostfachNachricht:
:
getMailBody
).
isEqualTo
(
expectedMailBody
);
}
}
private
Optional
<
PostfachNachricht
>
adjustMail
()
{
return
service
.
adjustMail
(
mail
);
}
}
}
...
...
@@ -804,8 +797,8 @@ class PostfachServiceTest {
@Nested
class
TestSavingMukAntwort
{
private
PostfachNachricht
antwort
;
private
final
String
refId
=
ObjectId
.
get
().
toHexString
();
private
PostfachNachricht
antwort
;
@BeforeEach
void
setup
()
{
...
...
@@ -824,8 +817,6 @@ class PostfachServiceTest {
@Nested
class
TestLinkingMukAntwortToVorgang
{
private
final
String
vorgangId
=
ObjectId
.
get
().
toHexString
();
@BeforeEach
void
setup
()
{
antwort
=
PostfachNachrichtTestFactory
.
createBuilder
().
vorgangId
(
null
).
referencedNachricht
(
refId
).
build
();
...
...
@@ -834,28 +825,12 @@ class PostfachServiceTest {
}
@Test
void
shouldLoadLinkedNachricht
()
{
when
(
service
.
findById
(
eq
(
refId
))).
thenReturn
(
Optional
.
of
(
Map
.
of
(
VORGANG_ID_FIELD
,
vorgangId
)));
service
.
fetchAndPersistReplies
();
verify
(
service
).
findById
(
anyString
());
}
@Test
void
shouldSetVorgangId
()
{
when
(
service
.
findById
(
anyString
())).
thenReturn
(
Optional
.
of
(
Map
.
of
(
VORGANG_ID_FIELD
,
vorgangId
)));
void
shouldLoadPersistedNachricht
()
{
when
(
persistingService
.
getById
(
anyString
())).
thenReturn
(
PostfachNachrichtTestFactory
.
asMap
());
service
.
fetchAndPersistReplies
();
verify
(
service
).
setVorgangId
(
anyString
(),
any
(
PostfachNachricht
.
class
));
}
@Test
void
shouldThrowExceptionWhenVorgangIdEmpty
()
{
when
(
service
.
findById
(
anyString
())).
thenReturn
(
Optional
.
of
(
Map
.
of
(
"otherId"
,
ObjectId
.
get
().
toHexString
())));
assertThatExceptionOfType
(
TechnicalException
.
class
).
isThrownBy
(()
->
service
.
fetchAndPersistReplies
());
verify
(
service
).
getNachricht
(
anyString
());
}
}
}
...
...
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