mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-31 19:54:29 +01:00
51 lines
1.8 KiB
Java
51 lines
1.8 KiB
Java
package de.cotto.lndmanagej.controller;
|
|
|
|
import de.cotto.lndmanagej.controller.dto.ObjectMapperConfiguration;
|
|
import de.cotto.lndmanagej.model.ChannelIdResolver;
|
|
import de.cotto.lndmanagej.service.ChannelService;
|
|
import de.cotto.lndmanagej.service.OwnNodeService;
|
|
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.context.annotation.Import;
|
|
import org.springframework.test.web.servlet.MockMvc;
|
|
|
|
import java.util.Set;
|
|
|
|
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
|
|
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.content;
|
|
|
|
@WebMvcTest(controllers = StatusController.class)
|
|
@Import(ObjectMapperConfiguration.class)
|
|
class ObjectMapperConfigurationIT {
|
|
private static final String PREFIX = "/api/status/";
|
|
|
|
@Autowired
|
|
private MockMvc mockMvc;
|
|
|
|
@MockBean
|
|
@SuppressWarnings("unused")
|
|
private ChannelIdResolver channelIdResolver;
|
|
|
|
@MockBean
|
|
private ChannelService channelService;
|
|
|
|
@MockBean
|
|
@SuppressWarnings("unused")
|
|
private OwnNodeService ownNodeService;
|
|
|
|
@Test
|
|
void output_is_pretty_printed() throws Exception {
|
|
when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL));
|
|
String expectedString = """
|
|
{
|
|
"channels" : [ "712345x123x1" ]
|
|
}""";
|
|
mockMvc.perform(get(PREFIX + "/open-channels/"))
|
|
.andExpect(content().string(expectedString));
|
|
}
|
|
}
|