mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-21 15:04:22 +01:00
return channels for peer
This commit is contained in:
@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.controller;
|
||||
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.Node;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
import de.cotto.lndmanagej.service.NodeService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -9,6 +10,15 @@ 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 java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_2;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL_2;
|
||||
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL_3;
|
||||
import static de.cotto.lndmanagej.model.NodeFixtures.ALIAS_2;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
@@ -27,6 +37,9 @@ class NodeControllerIT {
|
||||
@MockBean
|
||||
private NodeService nodeService;
|
||||
|
||||
@MockBean
|
||||
private ChannelService channelService;
|
||||
|
||||
@MockBean
|
||||
@SuppressWarnings("unused")
|
||||
private Metrics metrics;
|
||||
@@ -41,9 +54,22 @@ class NodeControllerIT {
|
||||
@Test
|
||||
void getDetails() throws Exception {
|
||||
when(nodeService.getNode(PUBKEY_2)).thenReturn(new Node(PUBKEY_2, ALIAS_2, 0, true));
|
||||
when(channelService.getOpenChannelsWith(PUBKEY_2)).thenReturn(Set.of(LOCAL_OPEN_CHANNEL, LOCAL_OPEN_CHANNEL_2));
|
||||
List<String> channelIds = List.of(CHANNEL_ID.toString(), CHANNEL_ID_2.toString());
|
||||
mockMvc.perform(get(NODE_PREFIX + "/details"))
|
||||
.andExpect(jsonPath("$.pubkey", is(PUBKEY_2.toString())))
|
||||
.andExpect(jsonPath("$.node", is(PUBKEY_2.toString())))
|
||||
.andExpect(jsonPath("$.alias", is(ALIAS_2)))
|
||||
.andExpect(jsonPath("$.channels", is(channelIds)))
|
||||
.andExpect(jsonPath("$.online", is(true)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getOpenChannelIds_for_peer() throws Exception {
|
||||
when(channelService.getOpenChannelsWith(PUBKEY_2)).thenReturn(Set.of(LOCAL_OPEN_CHANNEL, LOCAL_OPEN_CHANNEL_3));
|
||||
List<String> channelIds = List.of(CHANNEL_ID.toString(), CHANNEL_ID_3.toString());
|
||||
mockMvc.perform(get(NODE_PREFIX + "/open-channels"))
|
||||
.andExpect(jsonPath("$.node", is(PUBKEY_2.toString())))
|
||||
.andExpect(jsonPath("$.channels", is(channelIds)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user