add remote pubkey and alias to channel details

This commit is contained in:
Carsten Otto
2021-11-19 17:12:08 +01:00
parent 854786c1e2
commit 840938676e
4 changed files with 37 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ 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.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@@ -12,6 +13,8 @@ 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.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.argThat;
@@ -26,6 +29,9 @@ class ChannelDetailsControllerTest {
@Mock
private ChannelService channelService;
@Mock
private NodeService nodeService;
@Mock
private Metrics metrics;
@@ -37,9 +43,11 @@ class ChannelDetailsControllerTest {
@Test
void getChannelDetails() throws NotFoundException {
ChannelDetailsDto expectedDetails = new ChannelDetailsDto(CHANNEL_ID, PUBKEY_2, ALIAS_2);
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
assertThat(channelDetailsController.getChannelDetails(CHANNEL_ID))
.isEqualTo(new ChannelDetailsDto(CHANNEL_ID));
assertThat(channelDetailsController.getChannelDetails(CHANNEL_ID)).isEqualTo(expectedDetails);
verify(metrics).mark(argThat(name -> name.endsWith(".getChannelDetails")));
}
}