Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shop shop1 = Shop.builder().id(1).latitude(1.1).longitude(2.2).name("shop1").build();
- Shop shop2 = Shop.builder().id(2).latitude(10.1).longitude(20.2).name("shop2").build();
- UserPosition userPosition = new UserPosition(1L, 0.0, 0.0, 10.0);
- when(shopServiceMock.searchWithinRadius(0.0, 0.0, 10.0, 1, 10)).thenReturn(Arrays.asList(shop1, shop2));
- ObjectMapper objectMapper = new ObjectMapper();
- byte[] jsonUserPosition = objectMapper.writeValueAsBytes(userPosition);
- mockMvc.perform(get("/api/shops/searchWithinRadius")
- .contentType(TestUtil.APPLICATION_JSON_UTF8).content(jsonUserPosition)
- .param("page", "1").param("size", "10"))
- .andExpect(status().isOk())
- .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
- .andExpect(jsonPath("$", hasSize(2)))
- .andExpect(jsonPath("$[0].id", is(1)))
- .andExpect(jsonPath("$[0].name", is("shop1")))
- .andExpect(jsonPath("$[1].id", is(2)))
- .andExpect(jsonPath("$[1].name", is("shop2")));
- verify(shopServiceMock, times(1)).searchWithinRadius(0.0, 0.0, 10.0, 1, 10);
Add Comment
Please, Sign In to add comment