get alias for pubkey via REST controller

This commit is contained in:
Carsten Otto
2021-11-11 18:58:23 +01:00
parent d6ebfcbb78
commit 4901b70600
9 changed files with 126 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.grpc.GrpcNodeInfo;
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 static de.cotto.lndmanagej.model.NodeFixtures.ALIAS;
import static de.cotto.lndmanagej.model.NodeFixtures.NODE;
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
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 = NodeController.class)
class NodeControllerIT {
@Autowired
private MockMvc mockMvc;
@MockBean
private GrpcNodeInfo grpcNodeInfo;
@Test
void getAlias() throws Exception {
when(grpcNodeInfo.getNode(PUBKEY)).thenReturn(NODE);
mockMvc.perform(get("/api/node/" + PUBKEY + "/alias")).andExpect(content().string(ALIAS));
}
}