Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GrowBros
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tomato
GrowBros
Commits
11a12d92
Commit
11a12d92
authored
1 year ago
by
Lukas Karsch
Browse files
Options
Downloads
Patches
Plain Diff
#29
first test for plant service
parent
7d97e727
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!15
#29 Pagination for Plants endpoint w/ CustomPageDTO
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requests.http
+1
-1
1 addition, 1 deletion
requests.http
src/test/java/hdm/mi/growbros/service/PlantsServiceTest.java
+44
-0
44 additions, 0 deletions
src/test/java/hdm/mi/growbros/service/PlantsServiceTest.java
with
45 additions
and
1 deletion
requests.http
+
1
−
1
View file @
11a12d92
### Get all plants
GET http://localhost:8080/api/v1/plants?page=0
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWthcy5rYXJzY2hAZ214LmRlIiwiaWF0IjoxNzAxM
jc4Mzkz
LCJleHAiOjE3MDE
zNjQ3OTN9.TVQlG3yAl_zJddPoWDndY9Xj-9EaR0P__x3aGU3sdBA
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWthcy5rYXJzY2hAZ214LmRlIiwiaWF0IjoxNzAxM
zcyNTIx
LCJleHAiOjE3MDE
0NTg5MjF9.8_rTh-5s4A6D1t_bdRdQFbM5RdNl2fpCLETpTQzInuc
### Get garden entries
GET http://localhost:8080/api/v1/garden
...
...
This diff is collapsed.
Click to expand it.
src/test/java/hdm/mi/growbros/service/PlantsServiceTest.java
0 → 100644
+
44
−
0
View file @
11a12d92
package
hdm.mi.growbros.service
;
import
hdm.mi.growbros.models.dto.CustomPageDto
;
import
hdm.mi.growbros.models.plant.Plant
;
import
hdm.mi.growbros.repositories.PlantRepository
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.test.context.ActiveProfiles
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
@SpringBootTest
@ActiveProfiles
(
"test"
)
class
PlantsServiceTest
{
@MockBean
private
PlantRepository
plantRepository
;
@Autowired
private
PlantsService
plantsService
;
@Test
void
getPlants_withPageEmpty
()
{
final
PageRequest
pageable
=
PageRequest
.
of
(
0
,
10
);
PageImpl
<
Plant
>
page
=
new
PageImpl
<>(
List
.
of
());
final
CustomPageDto
<
Plant
>
expected
=
new
CustomPageDto
<>(
0
,
0
,
page
.
getContent
());
when
(
plantRepository
.
findAll
(
pageable
))
.
thenReturn
(
page
);
CustomPageDto
<
Plant
>
actual
=
plantsService
.
getPlants
(
0
,
10
);
verify
(
plantRepository
).
findAll
(
pageable
);
assertEquals
(
actual
.
currentPage
(),
expected
.
currentPage
());
assertEquals
(
actual
.
pageSize
(),
0
);
assertEquals
(
actual
.
content
(),
expected
.
content
());
}
}
\ 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