use metrics library for spring integration

This commit is contained in:
Carsten Otto
2021-11-30 15:43:04 +01:00
parent 7835750ac3
commit f7e76e3e8c
30 changed files with 116 additions and 273 deletions

View File

@@ -1,7 +1,6 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
import de.cotto.lndmanagej.metrics.Metrics;
import de.cotto.lndmanagej.model.Coins;
import de.cotto.lndmanagej.service.OnChainCostService;
import org.junit.jupiter.api.Test;
@@ -16,8 +15,6 @@ import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
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)
@@ -28,18 +25,14 @@ class OnChainCostsControllerTest {
@Mock
private OnChainCostService onChainCostService;
@Mock
private Metrics metrics;
@Test
void getCostsForPeer() throws CostException {
void getCostsForPeer() {
Coins openCosts = Coins.ofSatoshis(123);
Coins closeCosts = Coins.ofSatoshis(456);
when(onChainCostService.getOpenCostsWith(PUBKEY)).thenReturn(openCosts);
when(onChainCostService.getCloseCostsWith(PUBKEY)).thenReturn(closeCosts);
OnChainCostsDto expected = new OnChainCostsDto(openCosts, closeCosts);
assertThat(onChainCostsController.getCostsForPeer(PUBKEY)).isEqualTo(expected);
verify(metrics).mark(argThat(name -> name.endsWith(".getCostsForPeer")));
}
@Test
@@ -47,7 +40,6 @@ class OnChainCostsControllerTest {
Coins coins = Coins.ofSatoshis(123);
when(onChainCostService.getOpenCosts(CHANNEL_ID)).thenReturn(Optional.of(coins));
assertThat(onChainCostsController.getOpenCostsForChannel(CHANNEL_ID)).isEqualTo(coins.satoshis());
verify(metrics).mark(argThat(name -> name.endsWith(".getOpenCostsForChannel")));
}
@Test
@@ -62,7 +54,6 @@ class OnChainCostsControllerTest {
Coins coins = Coins.ofSatoshis(123);
when(onChainCostService.getCloseCosts(CHANNEL_ID)).thenReturn(Optional.of(coins));
assertThat(onChainCostsController.getCloseCostsForChannel(CHANNEL_ID)).isEqualTo(coins.satoshis());
verify(metrics).mark(argThat(name -> name.endsWith(".getCloseCostsForChannel")));
}
@Test