provide details for channel (work in progress, currently only shows channel id)

This commit is contained in:
Carsten Otto
2021-11-19 16:31:06 +01:00
parent 09d0fb1f17
commit 854786c1e2
10 changed files with 258 additions and 48 deletions

View File

@@ -0,0 +1,45 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.metrics.Metrics;
import de.cotto.lndmanagej.service.ChannelService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
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 org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class ChannelDetailsControllerTest {
@InjectMocks
private ChannelDetailsController channelDetailsController;
@Mock
private ChannelService channelService;
@Mock
private Metrics metrics;
@Test
void getChannelDetails_channel_not_found() {
assertThatExceptionOfType(NotFoundException.class)
.isThrownBy(() -> channelDetailsController.getChannelDetails(CHANNEL_ID));
}
@Test
void getChannelDetails() throws NotFoundException {
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
assertThat(channelDetailsController.getChannelDetails(CHANNEL_ID))
.isEqualTo(new ChannelDetailsDto(CHANNEL_ID));
verify(metrics).mark(argThat(name -> name.endsWith(".getChannelDetails")));
}
}