Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
todo-list-example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IT1901
todo-list-example
Commits
812bd033
Commit
812bd033
authored
4 years ago
by
Hallvard Trætteberg
Browse files
Options
Downloads
Patches
Plain Diff
La til applikasjonen som kontekst-objekt
parent
99fef2d8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
todolist/springboot/restserver/src/test/java/todolist/springboot/restserver/TodoModelApplicationTest.java
+10
-5
10 additions, 5 deletions
...olist/springboot/restserver/TodoModelApplicationTest.java
with
10 additions
and
5 deletions
todolist/springboot/restserver/src/test/java/todolist/springboot/restserver/TodoModelApplicationTest.java
+
10
−
5
View file @
812bd033
...
@@ -23,7 +23,7 @@ import todolist.core.TodoModel;
...
@@ -23,7 +23,7 @@ import todolist.core.TodoModel;
import
todolist.json.TodoModule
;
import
todolist.json.TodoModule
;
@AutoConfigureMockMvc
@AutoConfigureMockMvc
@ContextConfiguration
(
classes
=
{
TodoModelController
.
class
,
TodoModelService
.
class
})
@ContextConfiguration
(
classes
=
{
TodoModelController
.
class
,
TodoModelService
.
class
,
TodoModelApplication
.
class
})
@WebMvcTest
@WebMvcTest
public
class
TodoModelApplicationTest
{
public
class
TodoModelApplicationTest
{
...
@@ -37,15 +37,20 @@ public class TodoModelApplicationTest {
...
@@ -37,15 +37,20 @@ public class TodoModelApplicationTest {
objectMapper
=
new
ObjectMapper
().
registerModule
(
new
TodoModule
(
false
));;
objectMapper
=
new
ObjectMapper
().
registerModule
(
new
TodoModule
(
false
));;
}
}
private
String
todoUrl
(
String
...
segments
)
{
String
url
=
"/"
+
TodoModelController
.
TODO_MODEL_SERVICE_PATH
;
for
(
String
segment
:
segments
)
{
url
=
url
+
"/"
+
segment
;
}
return
url
;
}
@Test
@Test
public
void
testGet_todo
()
throws
Exception
{
public
void
testGet_todo
()
throws
Exception
{
MvcResult
result
=
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/todo"
)
MvcResult
result
=
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
todoUrl
())
// .content(birthday)
// .contentType(MediaType.APPLICATION_JSON)
.
accept
(
MediaType
.
APPLICATION_JSON
))
.
accept
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
())
.
andReturn
();
.
andReturn
();
try
{
try
{
TodoModel
todoModel
=
objectMapper
.
readValue
(
result
.
getResponse
().
getContentAsString
(),
TodoModel
.
class
);
TodoModel
todoModel
=
objectMapper
.
readValue
(
result
.
getResponse
().
getContentAsString
(),
TodoModel
.
class
);
Iterator
<
AbstractTodoList
>
it
=
todoModel
.
iterator
();
Iterator
<
AbstractTodoList
>
it
=
todoModel
.
iterator
();
...
...
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