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
abbenhoumi
IntegrationProjet
Commits
442fcd30
Commit
442fcd30
authored
Mar 29, 2020
by
benhoumine
Browse files
test
parent
25c467df
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/isima/f2/model/Poubelle.java
View file @
442fcd30
...
...
@@ -39,8 +39,9 @@ public class Poubelle implements Serializable{
}
public
Poubelle
()
{
super
();
super
();
}
public
Poubelle
(
Long
id
,
Double
longitude
,
Double
latitude
,
Double
capacity
)
{
super
();
this
.
id
=
id
;
...
...
src/test/java/isima/F2/RamassagePoubleDepotApplicationTests.java
View file @
442fcd30
package
isima.F2
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
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.context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.web.client.TestRestTemplate
;
import
org.springframework.boot.web.server.LocalServerPort
;
@SpringBootTest
@SpringBootTest
(
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
class
RamassagePoubleDepotApplicationTests
{
@LocalServerPort
private
int
port
;
@Autowired
private
TestRestTemplate
restTemplate
;
@Test
void
contextLoads
()
{
public
void
testRunServerRamassageAppTest
()
throws
Exception
{
assertThat
(
this
.
restTemplate
.
getForObject
(
"http://localhost:"
+
port
+
"/"
,
String
.
class
)).
isNotEmpty
();
}
}
src/test/java/isima/F2/controller/PoubelleControllerTest.java
0 → 100644
View file @
442fcd30
package
isima.F2.controller
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultHandlers
.
print
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.test.web.servlet.MockMvc
;
import
isima.f2.controllers.PoubelleController
;
import
isima.f2.model.Poubelle
;
import
isima.f2.services.ImpPoubelle
;
@WebMvcTest
(
PoubelleController
.
class
)
public
class
PoubelleControllerTest
{
@MockBean
private
ImpPoubelle
service
;
@Autowired
private
MockMvc
mockMvc
;
@Test
public
void
verificationGetPoubellesMethode
()
throws
Exception
{
List
<
Poubelle
>
listRes
=
new
ArrayList
();
listRes
.
add
(
new
Poubelle
());
//Return null car Il n'y pas une initialisation de constructeur
when
(
service
.
getPoubelles
()).
thenReturn
(
listRes
);
this
.
mockMvc
.
perform
(
get
(
"/poubelles/"
)).
andDo
(
print
()).
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"\"id\":null"
)));
}
}
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