Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gla-client-template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Enseignants GLA
gla-client-template
Commits
90c63199
Commit
90c63199
authored
6 months ago
by
Arnaud LABOUREL
Browse files
Options
Downloads
Patches
Plain Diff
added test for DurationGenerator
parent
394bbe8e
Branches
1-amelioration-cote-client
2-appropriation-du-code-du-client
main
No related tags found
No related merge requests found
Pipeline
#44887
passed
5 months ago
Stage: build
Stage: test
Changes
1
Pipelines
3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/fr/univ_amu/m1info/client/util/DurationGeneratorTest.java
+51
-0
51 additions, 0 deletions
...fr/univ_amu/m1info/client/util/DurationGeneratorTest.java
with
51 additions
and
0 deletions
src/test/java/fr/univ_amu/m1info/client/util/DurationGeneratorTest.java
0 → 100644
+
51
−
0
View file @
90c63199
package
fr.univ_amu.m1info.client.util
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
java.time.Duration
;
import
java.util.Iterator
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.*;
class
DurationGeneratorTest
{
private
static
final
Duration
TEN_HOURS
=
Duration
.
ofHours
(
10
);
private
static
final
Duration
FOUR_HOURS
=
Duration
.
ofHours
(
4
);
private
static
final
Duration
ONE_HOUR
=
Duration
.
ofHours
(
1
);
private
static
final
Duration
ONE_QUARTER
=
Duration
.
ofMinutes
(
15
);
private
DurationGenerator
hoursUptoTenHours
;
private
DurationGenerator
quartersUptoFourHours
;
@BeforeEach
void
setUp
()
{
hoursUptoTenHours
=
new
DurationGenerator
(
ONE_HOUR
,
TEN_HOURS
);
quartersUptoFourHours
=
new
DurationGenerator
(
ONE_QUARTER
,
FOUR_HOURS
);
}
@Test
void
iterator
()
{
Iterator
<
Duration
>
iterator
=
hoursUptoTenHours
.
iterator
();
for
(
int
i
=
1
;
i
<=
10
;
i
++){
assertThat
(
iterator
.
hasNext
()).
isTrue
();
assertThat
(
iterator
.
next
()).
isEqualTo
(
Duration
.
ofHours
(
i
));
}
}
@Test
void
getDurations
()
{
assertThat
(
hoursUptoTenHours
.
getDurations
()).
contains
(
ONE_HOUR
,
FOUR_HOURS
);
assertThat
(
quartersUptoFourHours
.
getDurations
())
.
contains
(
ONE_QUARTER
,
ONE_QUARTER
.
multipliedBy
(
3
),
FOUR_HOURS
);
}
@Test
void
getDurationIndex
()
{
assertThat
(
hoursUptoTenHours
.
getDurationIndex
(
ONE_HOUR
)).
isEqualTo
(
0
);
assertThat
(
hoursUptoTenHours
.
getDurationIndex
(
FOUR_HOURS
)).
isEqualTo
(
3
);
assertThat
(
hoursUptoTenHours
.
getDurationIndex
(
ONE_QUARTER
)).
isEqualTo
(-
1
);
assertThat
(
quartersUptoFourHours
.
getDurationIndex
(
ONE_QUARTER
)).
isEqualTo
(
0
);
assertThat
(
quartersUptoFourHours
.
getDurationIndex
(
ONE_HOUR
)).
isEqualTo
(
3
);
}
}
\ No newline at end of file
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