mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-31 19:54:29 +01:00
56 lines
2.2 KiB
Java
56 lines
2.2 KiB
Java
package de.cotto.lndmanagej.controller;
|
|
|
|
import de.cotto.lndmanagej.metrics.Metrics;
|
|
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;
|
|
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.Optional;
|
|
|
|
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
|
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
|
|
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;
|
|
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;
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
@WebMvcTest(controllers = ChannelDetailsController.class)
|
|
class ChannelDetailsControllerIT {
|
|
private static final String CHANNEL_PREFIX = "/api/channel/" + CHANNEL_ID.getShortChannelId();
|
|
|
|
@Autowired
|
|
private MockMvc mockMvc;
|
|
|
|
@MockBean
|
|
private ChannelService channelService;
|
|
|
|
@MockBean
|
|
private NodeService nodeService;
|
|
|
|
@MockBean
|
|
@SuppressWarnings("unused")
|
|
private Metrics metrics;
|
|
|
|
@Test
|
|
void not_found() throws Exception {
|
|
mockMvc.perform(get(CHANNEL_PREFIX + "/details"))
|
|
.andExpect(status().isNotFound());
|
|
}
|
|
|
|
@Test
|
|
void getChannelDetails() throws Exception {
|
|
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
|
|
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
|
|
mockMvc.perform(get(CHANNEL_PREFIX + "/details"))
|
|
.andExpect(jsonPath("$.channelId", is(String.valueOf(CHANNEL_ID.getShortChannelId()))))
|
|
.andExpect(jsonPath("$.remotePubkey", is(PUBKEY_2.toString())))
|
|
.andExpect(jsonPath("$.remoteAlias", is(ALIAS_2)));
|
|
}
|
|
} |