testing

MockMVC in junit tests - checking result for List<Object> and Map<Enum, Object>

Deadly 提交于 2020-08-27 07:51:29
问题 I have problems with mockMVC and test written with that. My tests fails. I have two tests methods: @Test public void getPersonsForApiConsumerTest() throws Exception { mockMvc.perform(get(getUri("/consumers/1/persons"))) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(2))) .andExpect(jsonPath("$[1].name", is("Ligza"))) .andExpect(jsonPath("$[2].name", is("Vekrir"))); } @Test public void getPersonsForApiConsumerMapTest() throws Exception { mockMvc.perform(get(getUri("/consumers/1

mock case class in scala : Mockito

天涯浪子 提交于 2020-08-26 03:40:22
问题 In my play application i intend to mock a case class. I am able to do so but it creates an object with all member variables null. Is there a way to create mock objects of a case classes such that the object can have some members initialized? case class User(name: String, address: String) val mockUser = mock[User] user.name // null user.address //null how do i create a mockUser such that i can assign some values to name and address? Edit: I need the ability to mock the object because i want to

mock case class in scala : Mockito

£可爱£侵袭症+ 提交于 2020-08-26 03:39:08
问题 In my play application i intend to mock a case class. I am able to do so but it creates an object with all member variables null. Is there a way to create mock objects of a case classes such that the object can have some members initialized? case class User(name: String, address: String) val mockUser = mock[User] user.name // null user.address //null how do i create a mockUser such that i can assign some values to name and address? Edit: I need the ability to mock the object because i want to

What is the best way to make a POST request from cucumber to create a new object?

谁说我不能喝 提交于 2020-08-25 08:41:17
问题 For several of my cuke scenarios, I want to POST the user to a page with an object in the params, so that Rails will make a new object in the database. Is there a convenient way to send a POST+params to an action (either using something in cucumber or rails) or do I have to write my own function using Net::Http? 回答1: Just visit the controller you want to post some parameters to in order to create an object. You do not need a form to do this. Just post the values to whatever controller is