Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
urgi-is
FAIDARE
Commits
e7b52229
Commit
e7b52229
authored
Nov 05, 2021
by
Jean-Baptiste Nizet
Browse files
feat: support passing the germplasm id as request parameter
parent
5e1ff4eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java
View file @
e7b52229
...
...
@@ -77,6 +77,17 @@ public class GermplasmController {
return
toModelAndView
(
germplasm
);
}
@GetMapping
(
params
=
"id"
)
public
ModelAndView
getById
(
@RequestParam
(
"id"
)
String
germplasmId
)
{
GermplasmVO
germplasm
=
germplasmRepository
.
getById
(
germplasmId
);
if
(
germplasm
==
null
)
{
throw
new
NotFoundException
(
"Germplasm with ID "
+
germplasmId
+
" not found"
);
}
return
toModelAndView
(
germplasm
);
}
@GetMapping
(
params
=
"pui"
)
public
ModelAndView
getByPui
(
@RequestParam
(
"pui"
)
String
pui
)
{
GermplasmGETSearchCriteria
criteria
=
new
GermplasmGETSearchCriteria
();
...
...
backend/src/test/java/fr/inra/urgi/faidare/web/germplasm/GermplasmControllerTest.java
View file @
e7b52229
...
...
@@ -2,17 +2,21 @@ package fr.inra.urgi.faidare.web.germplasm;
import
static
fr
.
inra
.
urgi
.
faidare
.
web
.
Fixtures
.
htmlContent
;
import
static
org
.
mockito
.
ArgumentMatchers
.*;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
request
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Sets
;
import
fr.inra.urgi.faidare.config.FaidareProperties
;
import
fr.inra.urgi.faidare.domain.criteria.GermplasmGETSearchCriteria
;
import
fr.inra.urgi.faidare.domain.criteria.GermplasmSearchCriteria
;
import
fr.inra.urgi.faidare.domain.data.germplasm.GermplasmAttributeValueListVO
;
import
fr.inra.urgi.faidare.domain.data.germplasm.GermplasmMcpdVO
;
import
fr.inra.urgi.faidare.domain.data.germplasm.GermplasmSitemapVO
;
...
...
@@ -26,6 +30,7 @@ import fr.inra.urgi.faidare.repository.es.XRefDocumentRepository;
import
fr.inra.urgi.faidare.web.Fixtures
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.mockito.ArgumentMatcher
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
...
...
@@ -104,6 +109,57 @@ public class GermplasmControllerTest {
.
andExpect
(
htmlContent
().
endsCorrectly
());
}
@Test
void
shouldDisplayGermplasmWithIdAsParameter
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/germplasms"
).
param
(
"id"
,
germplasm
.
getGermplasmDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentTypeCompatibleWith
(
MediaType
.
TEXT_HTML
))
.
andExpect
(
htmlContent
().
hasTitle
(
"Germplasm: BLE BARBU DU ROUSSILLON"
))
.
andExpect
(
htmlContent
().
containsH2s
(
"Identification"
,
"Depositary"
,
"Collector"
,
"Breeder"
,
"Donors"
,
"Distributors"
,
"Evaluation Data"
,
"Genealogy"
,
"Population"
,
"Collection"
,
"Panel"
,
"Cross references"
))
.
andExpect
(
htmlContent
().
endsCorrectly
());
}
@Test
void
shouldDisplayGermplasmWithPuiAsParameter
()
throws
Exception
{
PaginatedList
<
GermplasmVO
>
puiList
=
new
PaginatedList
<>(
null
,
Collections
.
singletonList
(
germplasm
));
when
(
mockGermplasmRepository
.
find
(
any
())).
thenReturn
(
puiList
);
mockMvc
.
perform
(
get
(
"/germplasms"
).
param
(
"pui"
,
germplasm
.
getGermplasmPUI
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentTypeCompatibleWith
(
MediaType
.
TEXT_HTML
))
.
andExpect
(
htmlContent
().
hasTitle
(
"Germplasm: BLE BARBU DU ROUSSILLON"
))
.
andExpect
(
htmlContent
().
containsH2s
(
"Identification"
,
"Depositary"
,
"Collector"
,
"Breeder"
,
"Donors"
,
"Distributors"
,
"Evaluation Data"
,
"Genealogy"
,
"Population"
,
"Collection"
,
"Panel"
,
"Cross references"
))
.
andExpect
(
htmlContent
().
endsCorrectly
());
ArgumentMatcher
<
GermplasmSearchCriteria
>
criteriaMatcher
=
criteria
->
criteria
instanceof
GermplasmGETSearchCriteria
&&
((
GermplasmGETSearchCriteria
)
criteria
).
getGermplasmPUI
()
.
equals
(
Collections
.
singletonList
(
germplasm
.
getGermplasmPUI
()));
verify
(
mockGermplasmRepository
).
find
(
argThat
(
criteriaMatcher
));
}
@Test
void
shouldGenerateSitemap
()
throws
Exception
{
List
<
GermplasmSitemapVO
>
germplasms
=
Arrays
.
asList
(
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment