Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Platform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Platform
Commits
593e1b08
Commit
593e1b08
authored
1 week ago
by
kbeyro
Browse files
Options
Downloads
Patches
Plain Diff
update test
parent
d49498c7
No related branches found
No related tags found
1 merge request
!210
Fix dashboard issue
Pipeline
#94346
failed
1 week ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/net/geant/nmaas/portal/service/impl/DashboardServiceImplTest.java
+29
-30
29 additions, 30 deletions
...t/nmaas/portal/service/impl/DashboardServiceImplTest.java
with
29 additions
and
30 deletions
src/test/java/net/geant/nmaas/portal/service/impl/DashboardServiceImplTest.java
+
29
−
30
View file @
593e1b08
...
...
@@ -128,36 +128,35 @@ public class DashboardServiceImplTest {
}
@Test
void
getSystemDashboardShouldCalculateCorrectTimestamps
()
{
OffsetDateTime
startDate
=
OffsetDateTime
.
now
().
minusHours
(
5
);
OffsetDateTime
endDate
=
OffsetDateTime
.
now
();
// Mock required repository methods
when
(
domainRepository
.
count
()).
thenReturn
(
1L
);
when
(
userRepository
.
count
()).
thenReturn
(
1L
);
when
(
appInstanceRepo
.
count
()).
thenReturn
(
1L
);
when
(
appInstanceRepo
.
countAllDeployedSinceTime
(
org
.
mockito
.
ArgumentMatchers
.
anyLong
(),
org
.
mockito
.
ArgumentMatchers
.
anyLong
())).
thenReturn
(
1
);
when
(
applicationBaseRepository
.
findAllNames
()).
thenReturn
(
Collections
.
emptyList
());
when
(
appInstanceRepo
.
findAllInTimePeriod
(
org
.
mockito
.
ArgumentMatchers
.
anyLong
(),
org
.
mockito
.
ArgumentMatchers
.
anyLong
())).
thenReturn
(
Collections
.
emptyList
());
// Call the method
dashboardService
.
getSystemDashboard
(
startDate
,
endDate
);
// Capture the arguments
ArgumentCaptor
<
Long
>
startCaptor
=
ArgumentCaptor
.
forClass
(
Long
.
class
);
ArgumentCaptor
<
Long
>
endCaptor
=
ArgumentCaptor
.
forClass
(
Long
.
class
);
// Verify that the method was called with calculated timestamps
org
.
mockito
.
Mockito
.
verify
(
appInstanceRepo
).
countAllDeployedSinceTime
(
startCaptor
.
capture
(),
endCaptor
.
capture
());
long
startTimestamp
=
startCaptor
.
getValue
();
long
endTimestamp
=
endCaptor
.
getValue
();
// The timestamps should be positive and start should be greater than end (since it's calculated as now - toEpochSecond)
assert
startTimestamp
>
0
;
assert
endTimestamp
>
0
;
assert
startTimestamp
>
endTimestamp
;
}
void
getSystemDashboardShouldCalculateCorrectTimestamps
()
{
OffsetDateTime
startDate
=
OffsetDateTime
.
now
().
minusHours
(
5
);
OffsetDateTime
endDate
=
OffsetDateTime
.
now
();
// Mock required repository methods
when
(
domainRepository
.
count
()).
thenReturn
(
1L
);
when
(
userRepository
.
count
()).
thenReturn
(
1L
);
when
(
appInstanceRepo
.
count
()).
thenReturn
(
1L
);
when
(
appInstanceRepo
.
countAllDeployedSinceTime
(
org
.
mockito
.
ArgumentMatchers
.
anyLong
(),
org
.
mockito
.
ArgumentMatchers
.
anyLong
())).
thenReturn
(
1
);
when
(
applicationBaseRepository
.
findAllNames
()).
thenReturn
(
Collections
.
emptyList
());
when
(
appInstanceRepo
.
findAllInTimePeriod
(
org
.
mockito
.
ArgumentMatchers
.
anyLong
(),
org
.
mockito
.
ArgumentMatchers
.
anyLong
())).
thenReturn
(
Collections
.
emptyList
());
// Call the method
dashboardService
.
getSystemDashboard
(
startDate
,
endDate
);
// Capture the arguments
ArgumentCaptor
<
Long
>
startCaptor
=
ArgumentCaptor
.
forClass
(
Long
.
class
);
ArgumentCaptor
<
Long
>
endCaptor
=
ArgumentCaptor
.
forClass
(
Long
.
class
);
org
.
mockito
.
Mockito
.
verify
(
appInstanceRepo
).
countAllDeployedSinceTime
(
startCaptor
.
capture
(),
endCaptor
.
capture
());
long
startTimestamp
=
startCaptor
.
getValue
();
long
endTimestamp
=
endCaptor
.
getValue
();
// The timestamps should be positive and start should be less than or equal to end
assert
startTimestamp
>
0
;
assert
endTimestamp
>
0
;
assert
startTimestamp
<=
endTimestamp
;
}
@Test
void
countAllDeployedSinceTimeShouldReturnCorrectCount
()
{
...
...
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