Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IntegrationProjet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abbenhoumi
IntegrationProjet
Commits
442fcd30
Commit
442fcd30
authored
Mar 29, 2020
by
benhoumine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
25c467df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
3 deletions
+64
-3
src/main/java/isima/f2/model/Poubelle.java
src/main/java/isima/f2/model/Poubelle.java
+2
-1
src/test/java/isima/F2/RamassagePoubleDepotApplicationTests.java
...t/java/isima/F2/RamassagePoubleDepotApplicationTests.java
+18
-2
src/test/java/isima/F2/controller/PoubelleControllerTest.java
...test/java/isima/F2/controller/PoubelleControllerTest.java
+44
-0
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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