mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-21 23:14:27 +01:00
add node warnings functionality (at the moment: only online percentage)
This commit is contained in:
@@ -97,6 +97,7 @@ class NodeControllerIT {
|
||||
.andExpect(jsonPath("$.balance.remoteAvailable", is("203")))
|
||||
.andExpect(jsonPath("$.feeReport.earned", is("1234")))
|
||||
.andExpect(jsonPath("$.feeReport.sourced", is("567")))
|
||||
.andExpect(jsonPath("$.nodeWarnings[0].onlinePercentage", is(51)))
|
||||
.andExpect(jsonPath("$.onChainCosts.openCosts", is("1000")))
|
||||
.andExpect(jsonPath("$.onChainCosts.closeCosts", is("2000")))
|
||||
.andExpect(jsonPath("$.onChainCosts.sweepCosts", is("3000")))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import de.cotto.lndmanagej.model.ChannelIdResolver;
|
||||
import de.cotto.lndmanagej.model.NodeWarnings;
|
||||
import de.cotto.lndmanagej.service.NodeWarningsService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static de.cotto.lndmanagej.model.NodeWarningsFixtures.NODE_WARNINGS;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
|
||||
@WebMvcTest(controllers = WarningsController.class)
|
||||
class WarningsControllerIT {
|
||||
private static final String NODE_PREFIX = "/api/node/" + PUBKEY;
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
@SuppressWarnings("unused")
|
||||
private ChannelIdResolver channelIdResolver;
|
||||
|
||||
@MockBean
|
||||
private NodeWarningsService nodeWarningsService;
|
||||
|
||||
@Test
|
||||
void getWarningsForNode() throws Exception {
|
||||
when(nodeWarningsService.getNodeWarnings(PUBKEY)).thenReturn(NODE_WARNINGS);
|
||||
mockMvc.perform(get(NODE_PREFIX + "/warnings"))
|
||||
.andExpect(jsonPath("$.nodeWarnings[0].onlinePercentage", is(51)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWarningsForNode_empty() throws Exception {
|
||||
when(nodeWarningsService.getNodeWarnings(PUBKEY)).thenReturn(NodeWarnings.NONE);
|
||||
mockMvc.perform(get(NODE_PREFIX + "/warnings"))
|
||||
.andExpect(jsonPath("$.nodeWarnings", hasSize(0)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user