I have a test method that is provided,
@Test
public void calculateReward() throws Exception {
when(userService.findById(any(Long.class))).thenReturn(Optional.of(user));
int steps = 1000;
user.setCurrentSteps(steps);
user.setTotalSteps(steps);
when(userService.save(any(User.class))).thenReturn(user);
Map<String, Double> map = new HashMap<>();
map.put("EUR", 1.0);
when(currencyUtilities.getCurrencyMap()).thenReturn(map);
mockMvc.perform(put("/api/v1/users/calculateReward")
.param("userId", String.valueOf(user.getId())))
.andExpect(
status().isCreated()
).andExpect(
content().contentType(MediaType.APPLICATION_JSON_UTF8)
).andDo(print())
.andExpect(
jsonPath("$.name", is(user.getName()))
).andExpect(
jsonPath("$.currency", is(user.getCurrencyName()))
).andExpect(
jsonPath("$.reward", is(1.0)));
}
I get the error message,
java.lang.AssertionError: JSON path "$.reward"
Expected: is <1.0>
but: was "1.00"
Expected :is <1.0>
Actual :"1.00"
What is the issue here?