Questions tagged [mockmvc]

MockMVC is the key part of the Spring MVC Test framework is. It simulates the internals of Spring MVC.

MockMVC is the key part of the Spring MVC Test framework is. It simulates the internals of Spring MVC.

742 questions
0
votes
1 answer

How and Where to use failOnUndocumentedParams in Spring Auto REST Docs?

I am working with Spring Auto REST Docs, and want to know the use of failOnUndocumentedParams, and how to use it. I want that documentation should not be generated if I miss a field from the POJO. I believe using failOnUndocumentedParams is my…
GoPro
  • 642
  • 1
  • 10
  • 24
0
votes
1 answer

How test method with formData, without RequestBody or RequestParam with MockMVC

i have this method in my rest controller (I can not use @RequestBody or @RequestParam for a couple of complicated reasons, so I need it this way): @PostMapping(value="/crear") public Resultado crear(Candidato candidato) throws IOException…
jaxonjma
  • 177
  • 3
  • 15
0
votes
0 answers

Spring MockMvc testing with Java based config

I am using MockMvc for testing web application, but have faced with some issues. When I tried to run simple request without getting any bean from appContext it works perfect, but for example get bean of password encoder from appContext - returns…
rolyanos
  • 143
  • 2
  • 9
0
votes
3 answers

Spring Boot - REST controller, test with MockMvc, Environment properties

I have a REST controller in a Spring boot application, simplyfied: @RestController @RequestMapping("/api") public class MyRestController { @Autowired private Environment env; private String property1; @PostConstruct private…
neblaz
  • 683
  • 10
  • 32
0
votes
0 answers

MockMvc expected Entity{field, field} but obtained {field, field}

i'm making a test of a Client, specifically i'm getting all clients, and i have this piece of code: ClientMockMvc.perform(get("/clients?sort=id,desc")) .andExpect(status().isOk()) …
Rohr Facu
  • 607
  • 1
  • 12
  • 29
0
votes
0 answers

MockMvc - Configuration error : org.springframework.beans.factory.UnsatisfiedDependencyException

I have gone through many solutions but I am unable to figure out what is the problem, also I am new to MockMvc so I might missing some basic thing, but don't know what. Problem: I have existing application on which I am trying to do Integration…
Darshan Thakkar
  • 224
  • 1
  • 8
0
votes
0 answers

How to pass hidden entity id field through MockMvc?

In my thymeleaf template I add a hidden field for a field on my form object:
fap
  • 663
  • 1
  • 5
  • 14
0
votes
2 answers

MockMVC returns 404 and pageNotFound warning in SpringTest

I have been researching for the past week and cannot find a explanation as to why my test case in springMVC is throwing a 404. It logs a warning that the page is not found. I quite certain that my config is correct and the application context is…
Corey Davis
  • 37
  • 2
  • 6
0
votes
0 answers

Sending an object with files using the MockMvc test

I want to send an object to the controller that has several lists with files and several fields with plain text. public class ContributionNew { private List elementsToAdd; private Map elementsToUpdate; …
sdafasdf
  • 451
  • 1
  • 4
  • 6
0
votes
1 answer

Is it possible to address one specific form using MockMvc

Hello there, I wanted to aks if it's possible to address one specific form in a html template using MockMvc. I have got a template which has 3 forms, and I am not able to address one of them. This is my test: @Test public void…
iPSAlex
  • 3
  • 2
0
votes
1 answer

UnitTesting SQL Database in Java

We have kinda stuck in one point of unit testing. We would like to test, what happens if the database server is not connected or not reachable. We have already written the testcode, but we are not able to imitate, if the server is not…
vdominika
  • 1
  • 1
0
votes
0 answers

Java Mockito donothing not working when calling MockMvc

For Testing, I am using MockMvc to make a POST request to a Controller and I would like to Mock a particular service call so that it does nothing (with the Mockito.doNothing()). If I call that method within the @Test, then it works perfectly and the…
patri
  • 59
  • 9
0
votes
1 answer

Spring and Unit Testing DeferredResult

I have this REST controller @RequestMapping(path = "/hello", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ApiOperation(code = CREATED, value = "Blah", response = SomeResponse.class) @ApiResponses(value = { …
user3301081
0
votes
1 answer

MockMvc saves Json with null fields in RestController test

The Context I am working on small REST application in Spring Boot. I would like to perform test Controller (POST.METHOD) which add new object to database. The Problem I create new entity through constructor and I specify fields in my object. Then I…
mastach
  • 23
  • 5
0
votes
1 answer

Spring Boot MockMvc escapes dots from URL

If I make: @Autowired protected MockMvc mockMvc; mockMvc.perform(delete("/example/test@email.com"); Controller gets test@email instead of test@email.com. How to pass URL with dot to MockMvc?
Justinas Jakavonis
  • 8,220
  • 10
  • 69
  • 114