Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alfa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
alfa
Commits
2d8c8aa2
Commit
2d8c8aa2
authored
2 years ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-359 fix assignUser
parent
5df6ab47
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
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
+27
-30
27 additions, 30 deletions
...lient/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
+24
-7
24 additions, 7 deletions
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
with
51 additions
and
37 deletions
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
+
27
−
30
View file @
2d8c8aa2
...
...
@@ -26,7 +26,7 @@ import { CommandListResource, CommandResource, CommandService } from '@goofy-cli
import
{
createEmptyStateResource
,
createStateResource
,
NavigationService
,
StateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
Mock
,
mock
,
useFromMock
}
from
'
@goofy-client/test-utils
'
;
import
{
getUrl
,
ResourceUri
}
from
'
@ngxp/rest
'
;
import
{
cold
,
hot
}
from
'
jest-marbles
'
;
import
{
cold
}
from
'
jest-marbles
'
;
import
{
createBinaryFileListResource
}
from
'
libs/binary-file-shared/test/binary-file
'
;
import
{
CommandLinkRel
}
from
'
libs/command-shared/src/lib/command.linkrel
'
;
import
{
createCommandListResource
,
createCommandResource
}
from
'
libs/command-shared/test/command
'
;
...
...
@@ -350,26 +350,18 @@ describe('VorgangService', () => {
const
vorgangWithEingangResource
:
VorgangWithEingangResource
=
createVorgangWithEingangResource
();
const
vorgangWithEingangStateResource
:
StateResource
<
VorgangWithEingangResource
>
=
createStateResource
(
vorgangWithEingangResource
);
describe
(
'
init and next value
'
,
()
=>
{
beforeEach
(()
=>
{
vorgangFacade
.
getVorgangWithEingang
.
mockReturnValue
(
hot
(
'
-a
'
,
{
a
:
vorgangWithEingangStateResource
}));
commandService
.
createCommand
.
mockReturnValue
(
hot
(
'
-a
'
,
{
a
:
commandStateResource
}));
service
.
reloadVorgangOnDone
=
jest
.
fn
();
})
it
(
'
should be return
'
,
()
=>
{
const
result
=
service
.
assignUser
(
userProfileUri
);
vorgangFacade
.
getVorgangWithEingang
.
mockReturnValue
(
of
(
vorgangWithEingangStateResource
));
commandService
.
createCommand
.
mockReturnValue
(
of
(
commandStateResource
));
expect
(
result
).
toBeObservable
(
cold
(
'
ab
'
,
{
a
:
createEmptyStateResource
(
true
),
b
:
commandStateResource
})
);
})
service
.
setAssignUserCommandLoading
=
jest
.
fn
(
);
service
.
setAssignUserCommand
=
jest
.
fn
();
})
describe
(
'
further process
'
,
()
=>
{
it
(
'
should set assign user command loading
'
,
()
=>
{
service
.
assignUser
(
userProfileUri
);
beforeEach
(()
=>
{
vorgangFacade
.
getVorgangWithEingang
.
mockReturnValue
(
of
(
vorgangWithEingangStateResource
));
commandService
.
createCommand
.
mockReturnValue
(
of
(
commandStateResource
));
expect
(
service
.
setAssignUserCommandLoading
).
toHaveBeenCalled
();
})
it
(
'
should call facade get vorgangWithEingang
'
,
()
=>
{
...
...
@@ -393,6 +385,11 @@ describe('VorgangService', () => {
expect
(
service
.
reloadVorgang
).
toHaveBeenCalled
();
})
it
(
'
should set assign user command on command is done
'
,
()
=>
{
service
.
assignUser
(
userProfileUri
);
expect
(
service
.
setAssignUserCommand
).
toHaveBeenCalledWith
(
commandStateResource
);
})
})
})
This diff is collapsed.
Click to expand it.
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
+
24
−
7
View file @
2d8c8aa2
...
...
@@ -26,11 +26,11 @@ import { Params } from '@angular/router';
import
{
BinaryFileListResource
}
from
'
@goofy-client/binary-file-shared
'
;
import
{
CommandListResource
,
CommandResource
,
CommandService
,
getPendingCommandByOrder
,
hasError
,
isDone
}
from
'
@goofy-client/command-shared
'
;
import
{
PostfachOrder
}
from
'
@goofy-client/postfach-shared
'
;
import
{
createEmptyStateResource
,
createStateResource
,
doIfLoadingRequired
,
isNotUndefined
,
NavigationService
,
StateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
createEmptyStateResource
,
createStateResource
,
doIfLoadingRequired
,
isNotNil
,
isNotUndefined
,
NavigationService
,
StateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
getUrl
,
hasLink
,
ResourceUri
}
from
'
@ngxp/rest
'
;
import
{
CommandLinkRel
}
from
'
libs/command-shared/src/lib/command.linkrel
'
;
import
{
BehaviorSubject
,
Observable
,
Subscription
}
from
'
rxjs
'
;
import
{
first
,
mergeMap
,
startWith
,
tap
}
from
'
rxjs/operators
'
;
import
{
first
,
startWith
,
tap
}
from
'
rxjs/operators
'
;
import
{
VorgangFacade
}
from
'
./+state/vorgang.facade
'
;
import
{
VorgangRepository
}
from
'
./+state/vorgang.repository
'
;
import
{
VorgangWithEingangLinkRel
}
from
'
./vorgang.linkrel
'
;
...
...
@@ -45,7 +45,10 @@ export class VorgangService {
private
readonly
attachments$
:
BehaviorSubject
<
StateResource
<
BinaryFileListResource
>>
=
new
BehaviorSubject
<
StateResource
<
BinaryFileListResource
>>
(
createEmptyStateResource
<
BinaryFileListResource
>
());
private
readonly
representations$
:
BehaviorSubject
<
StateResource
<
BinaryFileListResource
>>
=
new
BehaviorSubject
<
StateResource
<
BinaryFileListResource
>>
(
createEmptyStateResource
<
BinaryFileListResource
>
());
private
readonly
assignUserCommand$
:
BehaviorSubject
<
StateResource
<
CommandResource
>>
=
new
BehaviorSubject
<
StateResource
<
CommandResource
>>
(
createEmptyStateResource
<
CommandResource
>
());
private
navigationSubscription
:
Subscription
;
private
assignUserSubscription
:
Subscription
;
public
static
readonly
VORGANG_WITH_EINGANG_URL
:
string
=
'
vorgangWithEingangUrl
'
;
...
...
@@ -212,11 +215,19 @@ export class VorgangService {
}
public
assignUser
(
userUri
:
ResourceUri
):
Observable
<
StateResource
<
CommandResource
>>
{
return
this
.
vorgangFacade
.
getVorgangWithEingang
().
pipe
(
mergeMap
((
vorgangWithEingang
)
=>
this
.
commandService
.
createCommand
(
vorgangWithEingang
.
resource
,
VorgangWithEingangLinkRel
.
ASSIGN
,
this
.
createAssignUserOrder
(
userUri
))),
tap
(
commandStateResource
=>
this
.
reloadVorgangOnDone
(
commandStateResource
)),
startWith
(
createEmptyStateResource
<
CommandResource
>
(
true
))
)
this
.
setAssignUserCommandLoading
();
this
.
vorgangFacade
.
getVorgangWithEingang
().
pipe
(
first
()).
subscribe
(
vorgangWithEingang
=>
{
this
.
assignUserSubscription
=
this
.
commandService
.
createCommand
(
vorgangWithEingang
.
resource
,
VorgangWithEingangLinkRel
.
ASSIGN
,
this
.
createAssignUserOrder
(
userUri
)).
subscribe
(
commandStateResource
=>
{
this
.
reloadVorgangOnDone
(
commandStateResource
);
})
});
return
this
.
assignUserCommand$
.
asObservable
();
}
setAssignUserCommandLoading
():
void
{
this
.
assignUserCommand$
.
next
({
...
this
.
assignUserCommand$
.
value
,
loading
:
true
});
}
private
createAssignUserOrder
(
assignedTo
:
ResourceUri
):
CreateAssignUserCommand
{
...
...
@@ -225,10 +236,16 @@ export class VorgangService {
reloadVorgangOnDone
(
commandResource
:
StateResource
<
CommandResource
>
):
void
{
if
(
isDone
(
commandResource
.
resource
)
&&
!
hasError
(
commandResource
.
resource
))
{
this
.
setAssignUserCommand
(
commandResource
);
this
.
reloadVorgang
(
commandResource
.
resource
);
if
(
isNotNil
(
this
.
assignUserSubscription
))
this
.
assignUserSubscription
.
unsubscribe
();
}
}
setAssignUserCommand
(
commandStateResource
:
StateResource
<
CommandResource
>
):
void
{
this
.
assignUserCommand$
.
next
(
commandStateResource
);
}
public
reloadVorgang
(
commandResource
:
CommandResource
):
void
{
this
.
loadVorgangWithEingang
(
getUrl
(
commandResource
,
CommandLinkRel
.
EFFECTED_RESOURCE
));
}
...
...
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