0

I have this problem to pass a Date in junit.

I try to pass param dateFrom as String, because as Date is imposible but then i can execute this method because system try to map a Date with a string. Thats the problem.

this is my method in junit.

this.mockMvc
            .perform(
                    get("/findElement/ajax/makeAction").header("Accept", "*/*").sessionAttr(Constants.DATA, this.data)
                            .param("index", "")
                            .param("numElems", "50")
                            .param("dateFrom", "2012-01-01T00:00:00.000Z"))
                            .andExpect(status().isOk());

}

This is my controller.

@RequestMapping(value = "/ajax/makeAction", headers = "Accept=*/*", method = RequestMethod.GET)
@ResponseBody
public List<Liquidacion> consultaMasLiquidaciones(User user, Product product)

where product has product.dateFrom

Thanks.

1 Answer 1

1

Finally it was very simple

.param("dateFrom", "22/09/2015")

Maybe you have to test different formats of string to parse to date.

Thanks

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.