Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sprachschulsystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Pokorný
Sprachschulsystem
Commits
4f59d1c7
There was an error fetching the commit references. Please try again later.
Commit
4f59d1c7
authored
1 year ago
by
Dominika Zemanovičová
Browse files
Options
Downloads
Patches
Plain Diff
ExerciseRepositoryTest add flush
parent
562b4de1
No related branches found
No related tags found
3 merge requests
!31
M2
,
!30
M2 exercise
,
!29
M2 exercise
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/module-exercise/src/test/java/org/fuseri/moduleexercise/exercise/ExerciseRepositoryTest.java
+1
-26
1 addition, 26 deletions
...useri/moduleexercise/exercise/ExerciseRepositoryTest.java
with
1 addition
and
26 deletions
application/module-exercise/src/test/java/org/fuseri/moduleexercise/exercise/ExerciseRepositoryTest.java
+
1
−
26
View file @
4f59d1c7
package
org.fuseri.moduleexercise.exercise
;
package
org.fuseri.moduleexercise.exercise
;
import
org.fuseri.moduleexercise.question.Question
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -11,8 +10,6 @@ import org.springframework.data.domain.PageRequest;
...
@@ -11,8 +10,6 @@ import org.springframework.data.domain.PageRequest;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
@DataJpaTest
@DataJpaTest
class
ExerciseRepositoryTest
{
class
ExerciseRepositoryTest
{
...
@@ -25,8 +22,6 @@ class ExerciseRepositoryTest {
...
@@ -25,8 +22,6 @@ class ExerciseRepositoryTest {
Exercise
exercise
=
new
Exercise
(
"name"
,
"desc"
,
2
,
1L
,
new
HashSet
<>());
Exercise
exercise
=
new
Exercise
(
"name"
,
"desc"
,
2
,
1L
,
new
HashSet
<>());
Question
question
=
new
Question
(
"text"
,
new
HashSet
<>(),
exercise
);
@Test
@Test
void
saveExercise
()
{
void
saveExercise
()
{
Exercise
saved
=
exerciseRepository
.
save
(
exercise
);
Exercise
saved
=
exerciseRepository
.
save
(
exercise
);
...
@@ -64,6 +59,7 @@ class ExerciseRepositoryTest {
...
@@ -64,6 +59,7 @@ class ExerciseRepositoryTest {
entityManager
.
persist
(
exercise
);
entityManager
.
persist
(
exercise
);
entityManager
.
persist
(
exercise1
);
entityManager
.
persist
(
exercise1
);
entityManager
.
flush
();
Page
<
Exercise
>
coursePage
=
exerciseRepository
.
findAll
(
PageRequest
.
of
(
0
,
42
));
Page
<
Exercise
>
coursePage
=
exerciseRepository
.
findAll
(
PageRequest
.
of
(
0
,
42
));
...
@@ -71,26 +67,6 @@ class ExerciseRepositoryTest {
...
@@ -71,26 +67,6 @@ class ExerciseRepositoryTest {
Assertions
.
assertEquals
(
coursePage
.
getContent
(),
Arrays
.
asList
(
exercise
,
exercise1
));
Assertions
.
assertEquals
(
coursePage
.
getContent
(),
Arrays
.
asList
(
exercise
,
exercise1
));
}
}
@Test
void
getQuestionsEmptyQuestions
()
{
entityManager
.
persist
(
exercise
);
var
result
=
exerciseRepository
.
getQuestions
(
PageRequest
.
of
(
0
,
10
),
1L
);
Assertions
.
assertEquals
(
0
,
result
.
getTotalElements
());
}
@Test
void
getQuestions
()
{
exercise
.
setQuestions
(
Set
.
of
(
question
));
entityManager
.
persist
(
exercise
);
var
result
=
exerciseRepository
.
getQuestions
(
PageRequest
.
of
(
0
,
10
),
1L
);
Assertions
.
assertEquals
(
1
,
result
.
getTotalElements
());
Assertions
.
assertEquals
(
result
.
getContent
().
get
(
0
),
question
);
}
@Test
@Test
void
testDeleteExercise
()
{
void
testDeleteExercise
()
{
Long
id
=
entityManager
.
persist
(
exercise
).
getId
();
Long
id
=
entityManager
.
persist
(
exercise
).
getId
();
...
@@ -101,5 +77,4 @@ class ExerciseRepositoryTest {
...
@@ -101,5 +77,4 @@ class ExerciseRepositoryTest {
Assertions
.
assertTrue
(
exerciseRepository
.
findById
(
id
).
isEmpty
());
Assertions
.
assertTrue
(
exerciseRepository
.
findById
(
id
).
isEmpty
());
}
}
}
}
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