Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
idatt2106-v23-03
backend
Commits
8f8de15c
Commit
8f8de15c
authored
1 year ago
by
Anders Austlid
Browse files
Options
Downloads
Patches
Plain Diff
Added WasteRepository unit tests
parent
29ba1e3b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepositoryTest.java
+61
-0
61 additions, 0 deletions
...6/v233/SmartMat/repository/group/WasteRepositoryTest.java
with
61 additions
and
0 deletions
src/test/java/ntnu/idatt2016/v233/SmartMat/repository/group/WasteRepositoryTest.java
0 → 100644
+
61
−
0
View file @
8f8de15c
package
ntnu.idatt2016.v233.SmartMat.repository.group
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Optional
;
import
ntnu.idatt2016.v233.SmartMat.entity.Waste
;
import
ntnu.idatt2016.v233.SmartMat.repository.group.WasteRepository
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
@ExtendWith
(
SpringExtension
.
class
)
@DataJpaTest
class
WasteRepositoryTest
{
@Autowired
private
WasteRepository
wasteRepository
;
private
Waste
waste1
;
private
Waste
waste2
;
@BeforeEach
void
setUp
()
{
waste1
=
Waste
.
builder
()
.
groupId
(
1L
)
.
ean
(
123456L
)
.
timestamp
(
Timestamp
.
valueOf
(
LocalDateTime
.
now
()))
.
amount
(
10
)
.
unit
(
"kg"
)
.
build
();
waste2
=
Waste
.
builder
()
.
groupId
(
1L
)
.
ean
(
789012L
)
.
timestamp
(
Timestamp
.
valueOf
(
LocalDateTime
.
now
()))
.
amount
(
5
)
.
unit
(
"kg"
)
.
build
();
wasteRepository
.
save
(
waste1
);
wasteRepository
.
save
(
waste2
);
}
@Test
void
findByGroupId
()
{
Optional
<
List
<
Waste
>>
result
=
wasteRepository
.
findByGroupId
(
1L
);
assertTrue
(
result
.
isPresent
());
assertEquals
(
2
,
result
.
get
().
size
());
assertEquals
(
waste1
.
getEan
(),
result
.
get
().
get
(
0
).
getEan
());
assertEquals
(
waste2
.
getEan
(),
result
.
get
().
get
(
1
).
getEan
());
}
}
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