Skip to content
GitLab
Menu
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
c6bc74b2
Commit
c6bc74b2
authored
Sep 03, 2021
by
Jean-Baptiste Nizet
Browse files
chore: upgrade to Spring Boot 2.5.4
and remove useless and deprecated stuff in build and tests
parent
72f3d8a5
Changes
26
Hide whitespace changes
Inline
Side-by-side
backend/build.gradle.kts
View file @
c6bc74b2
...
...
@@ -10,9 +10,9 @@ buildscript {
plugins
{
java
jacoco
id
(
"org.springframework.boot"
)
version
"2.
1.2.RELEASE
"
id
(
"org.springframework.boot"
)
version
"2.
5.4
"
id
(
"com.gorylenko.gradle-git-properties"
)
version
"2.3.1"
id
(
"io.spring.dependency-management"
)
version
"1.0.
6
.RELEASE"
id
(
"io.spring.dependency-management"
)
version
"1.0.
11
.RELEASE"
id
(
"org.sonarqube"
)
id
(
"org.owasp.dependencycheck"
)
version
"6.0.3"
}
...
...
@@ -25,8 +25,6 @@ repositories {
mavenCentral
()
}
val
snippetsDir
=
file
(
"build/generated-snippets"
)
tasks
{
withType
(
JavaCompile
::
class
.
java
)
{
...
...
@@ -36,12 +34,6 @@ tasks {
options
.
compilerArgs
.
add
(
"-parameters"
)
}
processResources
{
inputs
.
property
(
"app"
,
"gnpis"
)
filesMatching
(
"bootstrap.yml"
)
{}
}
// this task is always out-of-date because it generates a properties file with the build time inside
// so the bootJar task is also always out of date, too, since it depends on it
// but it's better to do that than using the bootInfo() method of the springBoot closure, because that
...
...
@@ -52,7 +44,7 @@ tasks {
}
bootJar
{
archive
Name
=
"${rootProject.name}.jar"
archive
FileName
.
set
(
"${rootProject.name}.jar"
)
dependsOn
(
buildInfo
)
dependsOn
(
":web:assemble"
)
...
...
@@ -89,27 +81,29 @@ tasks {
testLogging
{
exceptionFormat
=
TestExceptionFormat
.
FULL
}
outputs
.
dir
(
snippetsDir
)
}
jacocoTestReport
{
reports
{
xml
.
setEnabled
(
true
)
html
.
setEnabled
(
true
)
xml
.
required
.
set
(
true
)
html
.
required
.
set
(
true
)
}
}
}
extra
[
"springCloudVersion"
]
=
"2020.0.3"
dependencyManagement
{
imports
{
mavenBom
(
"org.springframework.cloud:spring-cloud-dependencies:
Finchley.SR1
"
)
mavenBom
(
"org.springframework.cloud:spring-cloud-dependencies:
${property("
springCloudVersion
")}
"
)
}
}
dependencies
{
// Spring
annotationProcessor
(
"org.springframework.boot:spring-boot-configuration-processor"
)
implementation
(
"org.springframework.boot:spring-boot-starter-web"
)
implementation
(
"org.springframework.boot:spring-boot-starter-validation"
)
implementation
(
"org.springframework.boot:spring-boot-starter-actuator"
)
implementation
(
"org.springframework.boot:spring-boot-starter-security"
)
implementation
(
"org.springframework.cloud:spring-cloud-starter-config"
)
...
...
@@ -129,14 +123,6 @@ dependencies {
implementation
(
"com.opencsv:opencsv:4.4"
)
// Test dependencies
testImplementation
(
"org.springframework.boot:spring-boot-starter-test"
)
{
exclude
(
module
=
"junit"
)
}
testImplementation
(
"org.junit.jupiter:junit-jupiter-api"
)
testImplementation
(
"org.junit.jupiter:junit-jupiter-params"
)
testImplementation
(
"org.mockito:mockito-junit-jupiter:2.23.0"
)
testImplementation
(
"org.junit-pioneer:junit-pioneer:0.3.0"
)
testImplementation
(
"org.springframework.boot:spring-boot-starter-test"
)
testImplementation
(
"org.jsoup:jsoup:1.14.2"
)
testRuntimeOnly
(
"org.junit.jupiter:junit-jupiter-engine"
)
}
backend/src/main/java/fr/inra/urgi/faidare/config/ElasticSearchConfig.java
View file @
c6bc74b2
...
...
@@ -6,7 +6,7 @@ import org.elasticsearch.client.NodeSelector;
import
org.elasticsearch.client.RestClient
;
import
org.elasticsearch.client.RestClientBuilder
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.elasticsearch.
rest.
RestClientAutoConfiguration
;
import
org.springframework.boot.autoconfigure.elasticsearch.
Elasticsearch
RestClientAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -20,7 +20,7 @@ public class ElasticSearchConfig {
private
Integer
esPort
;
/**
* Provides builder for {@link RestClientAutoConfiguration}
* Provides builder for {@link
Elasticsearch
RestClientAutoConfiguration}
*/
@Bean
public
RestClientBuilder
restClientBuilder
()
{
...
...
backend/src/main/resources/application.yml
View file @
c6bc74b2
spring
:
config
:
import
:
'
optional:configserver:'
name
:
faidare
cloud
:
config
:
uri
:
${SPRING_CONFIG_URI:http://localhost:8888}
data
:
elasticsearch
:
host
:
127.0.0.1
...
...
@@ -12,12 +21,13 @@ management:
exposure
:
include
:
'
*'
logging.level
:
root
:
ERROR
org.springframework
:
boot.web.embedded.tomcat.TomcatWebServer
:
INFO
web.client.RestTemplate
:
DEBUG
fr.inra
:
DEBUG
logging
:
level
:
root
:
ERROR
org.springframework
:
boot.web.embedded.tomcat.TomcatWebServer
:
INFO
web.client.RestTemplate
:
DEBUG
fr.inra
:
DEBUG
faidare
:
elasticsearch-indexing-template
:
...
...
@@ -93,9 +103,12 @@ server:
---
spring
:
profiles
:
dev
resources
:
static-locations
:
-
classpath:/static/
-
file:./web/build/dist/
config
:
activate
:
on-profile
:
dev
web
:
resources
:
static-locations
:
-
classpath:/static/
-
file:./web/build/dist/
backend/src/main/resources/bootstrap.yml
deleted
100644 → 0
View file @
72f3d8a5
spring
:
application.name
:
faidare
cloud
:
config
:
uri
:
${SPRING_CONFIG_URI:http://localhost:8888}
# label: feat(_)configure_openstack_ci
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/BrapiExceptionHandlerTest.java
View file @
c6bc74b2
...
...
@@ -33,8 +33,7 @@ class BrapiExceptionHandlerTest {
@Test
void
should_Throw_Pagination_Max_Size_Exception
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pageSize=99999"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pageSize=99999"
))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
content
().
json
(
"{\n"
+
" \"metadata\": {\n"
+
...
...
@@ -61,8 +60,7 @@ class BrapiExceptionHandlerTest {
@Test
void
should_Throw_Pagination_Min_Size_Exception
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pageSize=-1"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pageSize=-1"
))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
content
().
json
(
"{\n"
+
" \"metadata\": {\n"
+
...
...
@@ -85,8 +83,7 @@ class BrapiExceptionHandlerTest {
@Test
void
should_Throw_Pagination_Min_Page_Exception
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?page=-1"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?page=-1"
))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
content
().
json
(
"{\n"
+
" \"metadata\": {\n"
+
...
...
@@ -108,8 +105,7 @@ class BrapiExceptionHandlerTest {
@Test
void
should_Throw_Invalid_Param_Value_Exception
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?page=foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?page=foo"
))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
content
().
json
(
"{\n"
+
" \"metadata\": {\n"
+
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/CallsControllerTest.java
View file @
c6bc74b2
...
...
@@ -28,8 +28,7 @@ class CallsControllerTest {
@Test
void
should_Get_Page_Size
()
throws
Exception
{
int
pageSize
=
3
;
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize="
+
pageSize
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize="
+
pageSize
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
0
)))
.
andExpect
(
jsonPath
(
"$.result.data"
,
hasSize
(
pageSize
)));
...
...
@@ -37,8 +36,7 @@ class CallsControllerTest {
@Test
void
should_Fail_Page_Overflow
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize=100&page=2"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize=100&page=2"
))
.
andExpect
(
status
().
isBadRequest
())
.
andExpect
(
content
().
json
(
"{"
+
"\"metadata\":{"
+
...
...
@@ -56,8 +54,7 @@ class CallsControllerTest {
@Test
void
should_Get_All
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize=1000"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/calls?pageSize=1000"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
json
(
"{\n"
+
" \"metadata\": {\n"
+
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/GermplasmControllerTest.java
View file @
c6bc74b2
...
...
@@ -54,8 +54,7 @@ class GermplasmControllerTest {
void
should_Not_Show_JSON_LD_Fields_By_Default
()
throws
Exception
{
when
(
service
.
getById
(
anyString
())).
thenReturn
(
GERMPLASM
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/"
+
GERMPLASM
.
getGermplasmDbId
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/"
+
GERMPLASM
.
getGermplasmDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
).
doesNotExist
());
}
...
...
@@ -65,8 +64,7 @@ class GermplasmControllerTest {
when
(
service
.
getById
(
anyString
())).
thenReturn
(
GERMPLASM
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/"
+
GERMPLASM
.
getGermplasmDbId
())
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
,
is
(
GERMPLASM
.
getUri
())));
}
...
...
@@ -76,8 +74,7 @@ class GermplasmControllerTest {
ProgenyVO
progeny
=
new
ProgenyVO
();
when
(
service
.
getProgeny
(
anyString
())).
thenReturn
(
progeny
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/Z25waXNfcHVpOnVua25vd246UmljZToxNjc4MzEw/progeny"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/Z25waXNfcHVpOnVua25vd246UmljZToxNjc4MzEw/progeny"
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -86,8 +83,7 @@ class GermplasmControllerTest {
GermplasmVO
germplasm
=
new
GermplasmVO
();
when
(
service
.
getById
(
anyString
())).
thenReturn
(
germplasm
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/Z25waXNfcHVpOnVua25vd246UmljZToxNjc4MzEw"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/Z25waXNfcHVpOnVua25vd246UmljZToxNjc4MzEw"
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -95,8 +91,7 @@ class GermplasmControllerTest {
void
should_Return_Not_Found
()
throws
Exception
{
when
(
service
.
getById
(
anyString
())).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/foo"
))
.
andExpect
(
status
().
isNotFound
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
1
)))
.
andExpect
(
jsonPath
(
"$.metadata.status[0].code"
,
is
(
"404"
)));
...
...
@@ -122,9 +117,7 @@ class GermplasmControllerTest {
when
(
service
.
getById
(
anyString
())).
thenReturn
(
germplasm
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm/foo"
))
// Should not have private fields
.
andExpect
(
jsonPath
(
"$.result"
,
not
(
hasProperty
(
"groupId"
))))
.
andExpect
(
jsonPath
(
"$.result"
,
not
(
hasProperty
(
"speciesGroup"
))))
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/LocationControllerTest.java
View file @
c6bc74b2
...
...
@@ -45,8 +45,7 @@ class LocationControllerTest {
void
should_Not_Show_JSON_LD_Fields_By_Default
()
throws
Exception
{
when
(
repository
.
getById
(
LOCATION
.
getLocationDbId
())).
thenReturn
(
LOCATION
);
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/"
+
LOCATION
.
getLocationDbId
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/"
+
LOCATION
.
getLocationDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
).
doesNotExist
());
}
...
...
@@ -56,8 +55,7 @@ class LocationControllerTest {
when
(
repository
.
getById
(
LOCATION
.
getLocationDbId
())).
thenReturn
(
LOCATION
);
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/"
+
LOCATION
.
getLocationDbId
())
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
,
is
(
LOCATION
.
getUri
())));
}
...
...
@@ -69,8 +67,7 @@ class LocationControllerTest {
LocationVO
location
=
new
LocationVO
();
when
(
repository
.
getById
(
identifier
)).
thenReturn
(
location
);
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/"
+
identifier
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/"
+
identifier
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -78,8 +75,7 @@ class LocationControllerTest {
void
should_Return_Not_Found
()
throws
Exception
{
when
(
repository
.
getById
(
"foo"
)).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/locations/foo"
))
.
andExpect
(
status
().
isNotFound
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
1
)))
.
andExpect
(
jsonPath
(
"$.metadata.status[0].code"
,
is
(
"404"
)));
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/ObservationVariableControllerTest.java
View file @
c6bc74b2
...
...
@@ -43,8 +43,7 @@ class ObservationVariableControllerTest {
@Test
void
should_Not_Show_JSON_LD_Fields_By_Default
()
throws
Exception
{
when
(
repository
.
getVariableById
(
VARIABLE
.
getObservationVariableDbId
())).
thenReturn
(
VARIABLE
);
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/"
+
VARIABLE
.
getObservationVariableDbId
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/"
+
VARIABLE
.
getObservationVariableDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
).
doesNotExist
());
}
...
...
@@ -54,8 +53,7 @@ class ObservationVariableControllerTest {
when
(
repository
.
getVariableById
(
VARIABLE
.
getObservationVariableDbId
())).
thenReturn
(
VARIABLE
);
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/"
+
VARIABLE
.
getObservationVariableDbId
())
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
,
is
(
VARIABLE
.
getUri
())));
}
...
...
@@ -67,8 +65,7 @@ class ObservationVariableControllerTest {
ObservationVariableVO
variable
=
new
ObservationVariableVO
();
when
(
repository
.
getVariableById
(
identifier
)).
thenReturn
(
variable
);
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/"
+
identifier
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/"
+
identifier
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -76,8 +73,7 @@ class ObservationVariableControllerTest {
void
should_Return_Not_Found
()
throws
Exception
{
when
(
repository
.
getVariableById
(
"foo"
)).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/variables/foo"
))
.
andExpect
(
status
().
isNotFound
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
1
)))
.
andExpect
(
jsonPath
(
"$.metadata.status[0].code"
,
is
(
"404"
)));
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/ProgramControllerTest.java
View file @
c6bc74b2
...
...
@@ -43,8 +43,7 @@ class ProgramControllerTest {
@Test
void
should_Not_Show_JSON_LD_Fields_By_Default
()
throws
Exception
{
when
(
repository
.
getById
(
PROGRAM
.
getProgramDbId
())).
thenReturn
(
PROGRAM
);
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/"
+
PROGRAM
.
getProgramDbId
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/"
+
PROGRAM
.
getProgramDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
).
doesNotExist
());
}
...
...
@@ -54,8 +53,7 @@ class ProgramControllerTest {
when
(
repository
.
getById
(
PROGRAM
.
getProgramDbId
())).
thenReturn
(
PROGRAM
);
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/"
+
PROGRAM
.
getProgramDbId
())
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
,
is
(
PROGRAM
.
getUri
())));
}
...
...
@@ -67,8 +65,7 @@ class ProgramControllerTest {
ProgramVO
program
=
new
ProgramVO
();
when
(
repository
.
getById
(
identifier
)).
thenReturn
(
program
);
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/"
+
identifier
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/"
+
identifier
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -76,8 +73,7 @@ class ProgramControllerTest {
void
should_Return_Not_Found
()
throws
Exception
{
when
(
repository
.
getById
(
"foo"
)).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/programs/foo"
))
.
andExpect
(
status
().
isNotFound
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
1
)))
.
andExpect
(
jsonPath
(
"$.metadata.status[0].code"
,
is
(
"404"
)));
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/brapi/v1/StudyControllerTest.java
View file @
c6bc74b2
...
...
@@ -63,8 +63,7 @@ class StudyControllerTest {
@Test
void
should_Not_Show_JSON_LD_Fields_By_Default
()
throws
Exception
{
when
(
repository
.
getById
(
STUDY
.
getStudyDbId
())).
thenReturn
(
STUDY
);
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/"
+
STUDY
.
getStudyDbId
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/"
+
STUDY
.
getStudyDbId
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
).
doesNotExist
());
}
...
...
@@ -74,8 +73,7 @@ class StudyControllerTest {
when
(
repository
.
getById
(
STUDY
.
getStudyDbId
())).
thenReturn
(
STUDY
);
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/"
+
STUDY
.
getStudyDbId
())
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
accept
(
BrapiJSONViewHandler
.
APPLICATION_LD_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.result.@id"
,
is
(
STUDY
.
getUri
())));
}
...
...
@@ -87,8 +85,7 @@ class StudyControllerTest {
StudyDetailVO
study
=
new
StudyDetailVO
();
when
(
repository
.
getById
(
identifier
)).
thenReturn
(
study
);
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/"
+
identifier
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/"
+
identifier
))
.
andExpect
(
status
().
isOk
());
}
...
...
@@ -96,8 +93,7 @@ class StudyControllerTest {
void
should_Return_Not_Found
()
throws
Exception
{
when
(
repository
.
getById
(
"foo"
)).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/foo"
))
.
andExpect
(
status
().
isNotFound
())
.
andExpect
(
jsonPath
(
"$.metadata.status"
,
hasSize
(
1
)))
.
andExpect
(
jsonPath
(
"$.metadata.status[0].code"
,
is
(
"404"
)));
...
...
@@ -113,8 +109,7 @@ class StudyControllerTest {
PaginatedList
<
ObservationUnitVO
>
observationUnits
=
new
PaginatedList
<>(
pagination
,
new
ArrayList
<>());
when
(
observationUnitRepository
.
find
(
any
())).
thenReturn
(
observationUnits
);
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/{id}/observationUnits?page={page}&pageSize={pageSize}"
,
studyDbId
,
page
,
pageSize
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/studies/{id}/observationUnits?page={page}&pageSize={pageSize}"
,
studyDbId
,
page
,
pageSize
))
.
andExpect
(
jsonPath
(
"$.metadata.pagination.currentPage"
,
is
(
page
)))
.
andExpect
(
jsonPath
(
"$.metadata.pagination.pageSize"
,
is
(
pageSize
)));
}
...
...
backend/src/test/java/fr/inra/urgi/faidare/api/faidare/v1/GnpISGermplasmControllerTest.java
View file @
c6bc74b2
...
...
@@ -47,8 +47,7 @@ class GnpISGermplasmControllerTest {
String
id
=
"foo"
;
when
(
service
.
getById
(
id
)).
thenReturn
(
null
);
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?id="
+
id
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?id="
+
id
))
.
andExpect
(
status
().
isNotFound
());
}
...
...
@@ -57,8 +56,7 @@ class GnpISGermplasmControllerTest {
when
(
service
.
find
(
any
(
GermplasmSearchCriteria
.
class
))).
thenReturn
(
null
);
String
pui
=
"foo"
;
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pui="
+
pui
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/brapi/v1/germplasm?pui="
+
pui
))
.
andExpect
(
status
().
isNotFound
());
}
...
...
@@ -71,8 +69,7 @@ class GnpISGermplasmControllerTest {
when
(
service
.
find
(
criteriaCaptor
.
capture
())).
thenReturn
(
germplasmPage
);
String
pui
=
"doi:10.15454/1.4921786234137117E12"
;
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm?pui="
+
pui
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm?pui="
+
pui
))
.
andExpect
(
status
().
isOk
());
GermplasmSearchCriteria
value
=
criteriaCaptor
.
getValue
();
...
...
@@ -85,8 +82,7 @@ class GnpISGermplasmControllerTest {
@Test
void
should_Return_Bad_Request_With_No_Param
()
throws
Exception
{
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm"
))
.
andExpect
(
status
().
isBadRequest
());
}
...
...
@@ -112,9 +108,7 @@ class GnpISGermplasmControllerTest {
when
(
service
.
find
(
any
(
GermplasmSearchCriteria
.
class
))).
thenReturn
(
germplasmPage
);
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm?pui=foo"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
mockMvc
.
perform
(
get
(
"/faidare/v1/germplasm?pui=foo"
))
// Should not have private fields
.
andExpect
(
jsonPath
(
"$"
,
not
(
hasProperty
(
"groupId"
))))
.
andExpect
(
jsonPath
(
"$"
,
not
(
hasProperty
(
"speciesGroup"
))))
...
...
backend/src/test/java/fr/inra/urgi/faidare/elasticsearch/ESResponseParserTest.java
View file @
c6bc74b2
...
...
@@ -107,7 +107,7 @@ class ESResponseParserTest {
assertThat
(
actualDocumentObject
)
.
isNotNull
().
isNotEmpty
()
.
containsOnly
Elements
Of
(
expectedDocumentObjects
);
.
hasSame
Elements
As
(
expectedDocumentObjects
);
}
private
SearchHit
mockSearchHit
(
DocumentObject
object
)
throws
IOException
{
...
...
backend/src/test/java/fr/inra/urgi/faidare/repository/es/DataDiscoveryRepositoryTest.java
View file @
c6bc74b2
...
...
@@ -114,7 +114,7 @@ class DataDiscoveryRepositoryTest {
criteria
.
setTypes
(
types
);
DataDiscoveryResponse
result
=
repository
.
find
(
criteria
);
assertThat
(
result
.
getResult
().
getData
()).
isNotNull
().
hasSize
(
2
)
.
flatExtracting
(
"type"
).
containsOnlyElements
Of
(
types
);
.
flatExtracting
(
"type"
).
isSubset
Of
(
types
);
}
@Test
...
...
@@ -124,7 +124,7 @@ class DataDiscoveryRepositoryTest {
criteria
.
setSources
(
sources
);
DataDiscoveryResponse
result
=
repository
.
find
(
criteria
);
assertThat
(
result
.
getResult
().
getData
()).
isNotNull
().
hasSize
(
2
)
.
extracting
(
"sourceUri"
).
containsOnlyElements
Of
(
sources
);
.
extracting
(
"sourceUri"
).
isSubset
Of
(
sources
);
}
@Test
...
...
backend/src/test/java/fr/inra/urgi/faidare/repository/es/GermplasmAttributeRepositoryTest.java
View file @
c6bc74b2
...
...
@@ -101,6 +101,6 @@ class GermplasmAttributeRepositoryTest {
assertThat
(
data
).
isNotNull
().
isNotEmpty
().
hasSize
(
2
);
assertThat
(
data
)
.
extracting
(
"attributeDbId"
)
.
containsOnlyElements
Of
(
expectedAttributes
);
.
isSubset
Of
(
expectedAttributes
);
}
}
backend/src/test/java/fr/inra/urgi/faidare/repository/es/GermplasmRepositoryTest.java
View file @
c6bc74b2
...
...
@@ -118,7 +118,7 @@ class GermplasmRepositoryTest {
void
should_Scroll_All
()
{
GermplasmPOSTSearchCriteria
criteria
=
new
GermplasmPOSTSearchCriteria
();
Iterator
<
GermplasmVO
>
list
=
repository
.
scrollAll
(
criteria
);
assertThat
(
list
).
isNotNull
().
hasSize
(
14
);
assertThat
(
list
).
isNotNull
().
toIterable
().
hasSize
(
14
);
}
@Test
...
...
@@ -126,13 +126,14 @@ class GermplasmRepositoryTest {
GermplasmPOSTSearchCriteria
criteria
=
new
GermplasmPOSTSearchCriteria
();
criteria
.
setAccessionNumbers
(
Collections
.
singletonList
(
"FOOOO"
));
Iterator
<
GermplasmVO
>
list
=
repository
.
scrollAll
(
criteria
);
assertThat
(
list
).
isNotNull
().
hasSize
(
0
);
assertThat
(
list
).
isNotNull
().
toIterable
().
hasSize
(
0
);
}
@Test
void
shouldScrollAllForSitemap
()
{
Iterator
<
GermplasmSitemapVO
>
list
=
repository
.
scrollAllForSitemap
(
100
);
assertThat
(
list
).
isNotEmpty
()
assertThat
(
list
).
toIterable
()
.
isNotEmpty
()
.
allMatch
(
vo
->
!
vo
.
getGermplasmDbId
().
isEmpty
());
}
...
...
@@ -144,8 +145,10 @@ class GermplasmRepositoryTest {
criteria
.
setAccessionNumbers
(
Collections
.
singletonList
(
accessionNumber
));