Skip to content

Commit

Permalink
Change not to hardcode the checking
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Dec 10, 2024
1 parent f16d4df commit 68e84a8
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.leungcheng.spring_simple_backend;

import static com.leungcheng.spring_simple_backend.testutil.CustomAssertions.assertBigDecimalEquals;
import static org.hamcrest.Matchers.not;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
Expand Down Expand Up @@ -235,14 +236,16 @@ void shouldGetAccountInfo() throws Exception {
String token = JsonPath.read(result.getResponse().getContentAsString(), "$.accessToken");
setAccessToken(token);

getAccountInfo()
.andExpect(status().isOk())
.andExpect(
jsonPath("$.balance")
.value(
"100.0")) // FIXME: not hardcoding it. Perhaps move INITIAL_BALANCE to sth that
// can be accessed by tests
.andExpect(jsonPath("$.username").value(userCredentials.username));
result =
getAccountInfo()
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value(userCredentials.username))
.andReturn();

BigDecimal actualBalance =
BigDecimal.valueOf(
(Double) JsonPath.read(result.getResponse().getContentAsString(), "$.balance"));
assertBigDecimalEquals(User.INITIAL_BALANCE, actualBalance);
}

private static class CreateProductParams {
Expand Down

0 comments on commit 68e84a8

Please sign in to comment.