Skip to content

Commit

Permalink
Add logging for test
Browse files Browse the repository at this point in the history
  • Loading branch information
bifrurcated committed Jan 14, 2024
1 parent 17115b2 commit 88d28a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -26,7 +28,7 @@
@AutoConfigureMockMvc
@ActiveProfiles("test")
class WalletControllerTest {

private static final Logger logger = LoggerFactory.getLogger(WalletControllerTest.class);
private static final String END_POINT_PATH = "/api/v1";
@Autowired
private MockMvc mockMvc;
Expand All @@ -35,6 +37,7 @@ class WalletControllerTest {
@Autowired
private WalletRepo repository;


@BeforeEach
public void setup() {
repository.deleteAll();
Expand Down Expand Up @@ -74,6 +77,7 @@ record WalletResponse(UUID id, Float amount) {}
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().json(response));
logger.info("Test passed");
}
@Test
public void testWalletDepositNotFound() throws Exception {
Expand All @@ -86,6 +90,7 @@ record WalletRequest(UUID valletId, String operationType, Float amount){}
.content(requestBody))
.andDo(print())
.andExpect(status().isNotFound());
logger.info("Test passed");
}

@Test
Expand All @@ -106,6 +111,7 @@ record WalletResponse(UUID id, Float amount) {}
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().json(response));
logger.info("Test passed");
}

@Test
Expand All @@ -121,6 +127,7 @@ record WalletRequest(UUID valletId, String operationType, Float amount){}
.content(requestBody))
.andDo(print())
.andExpect(status().isPaymentRequired());
logger.info("Test passed");
}

@Test
Expand All @@ -134,6 +141,7 @@ record WalletRequest(UUID valletId, String operationType, Float amount){}
.content(requestBody))
.andDo(print())
.andExpect(status().isUnsupportedMediaType());
logger.info("Test passed");
}

@Test
Expand All @@ -146,6 +154,7 @@ record BalanceResponse(Float amount){}
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().json(response));
logger.info("Test passed");
}

@Test
Expand All @@ -154,5 +163,6 @@ public void testWalletGetAmountNotFound() throws Exception {
this.mockMvc.perform(get(END_POINT_PATH+"/wallets/"+id))
.andDo(print())
.andExpect(status().isNotFound());
logger.info("Test passed");
}
}
4 changes: 3 additions & 1 deletion src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server:
port: 8000

logging:
level:
root: INFO
spring:
datasource:
url: jdbc:tc:postgresql:14.1:///test
Expand Down

0 comments on commit 88d28a5

Please sign in to comment.