mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-25 17:04:22 +01:00
remove dead code
This commit is contained in:
@@ -50,12 +50,6 @@ class SelfPaymentsRepositoryIT {
|
||||
invoicesRepository.save(SettledInvoiceJpaDto.createFromModel(SETTLED_INVOICE_4));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSelfPayments() {
|
||||
assertThat(repository.getAllSelfPayments()).map(SelfPaymentJpaDto::toModel)
|
||||
.containsExactlyInAnyOrder(SELF_PAYMENT, SELF_PAYMENT_2, SELF_PAYMENT_3, SELF_PAYMENT_4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSelfPaymentsToChannel() {
|
||||
assertThat(repository.getSelfPaymentsToChannel(CHANNEL_ID_2.getShortChannelId(), 0))
|
||||
|
||||
@@ -7,8 +7,6 @@ import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
public interface SelfPaymentsDao {
|
||||
List<SelfPayment> getAllSelfPayments();
|
||||
|
||||
List<SelfPayment> getSelfPaymentsToChannel(ChannelId channelId, Duration maxAge);
|
||||
|
||||
List<SelfPayment> getSelfPaymentsFromChannel(ChannelId channelId, Duration maxAge);
|
||||
|
||||
@@ -20,11 +20,6 @@ public class SelfPaymentsDaoImpl implements SelfPaymentsDao {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelfPayment> getAllSelfPayments() {
|
||||
return toModel(repository.getAllSelfPayments());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelfPayment> getSelfPaymentsToChannel(ChannelId channelId, Duration maxAge) {
|
||||
long minimumEpochSecond = getMinimumEpochSecond(maxAge);
|
||||
|
||||
@@ -9,12 +9,6 @@ import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
public interface SelfPaymentsRepository extends JpaRepository<SelfPaymentsRepository.DummyEntity, Long> {
|
||||
@Query("SELECT NEW de.cotto.lndmanagej.selfpayments.persistence.SelfPaymentJpaDto(i, p) " +
|
||||
"FROM PaymentJpaDto p " +
|
||||
"JOIN SettledInvoiceJpaDto i ON p.hash = i.hash " +
|
||||
"ORDER BY i.settleDate ASC")
|
||||
List<SelfPaymentJpaDto> getAllSelfPayments();
|
||||
|
||||
@Query("SELECT NEW de.cotto.lndmanagej.selfpayments.persistence.SelfPaymentJpaDto(i, p) " +
|
||||
"FROM PaymentJpaDto p " +
|
||||
"JOIN SettledInvoiceJpaDto i ON p.hash = i.hash " +
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.cotto.lndmanagej.selfpayments.persistence;
|
||||
|
||||
import de.cotto.lndmanagej.invoices.persistence.SettledInvoiceJpaDto;
|
||||
import de.cotto.lndmanagej.model.Payment;
|
||||
import de.cotto.lndmanagej.model.SettledInvoice;
|
||||
import de.cotto.lndmanagej.payments.persistence.PaymentJpaDto;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -18,12 +16,7 @@ import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.PaymentFixtures.PAYMENT;
|
||||
import static de.cotto.lndmanagej.model.PaymentFixtures.PAYMENT_2;
|
||||
import static de.cotto.lndmanagej.model.SelfPaymentFixtures.SELF_PAYMENT;
|
||||
import static de.cotto.lndmanagej.model.SelfPaymentFixtures.SELF_PAYMENT_2;
|
||||
import static de.cotto.lndmanagej.model.SettledInvoiceFixtures.SETTLED_INVOICE;
|
||||
import static de.cotto.lndmanagej.model.SettledInvoiceFixtures.SETTLED_INVOICE_2;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -46,21 +39,9 @@ class SelfPaymentsDaoImplTest {
|
||||
now = ZonedDateTime.now(ZoneOffset.UTC);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllSelfPayments_empty() {
|
||||
assertThat(selfPaymentsDaoImpl.getAllSelfPayments()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllSelfPayments() {
|
||||
when(repository.getAllSelfPayments())
|
||||
.thenReturn(List.of(getDto(PAYMENT, SETTLED_INVOICE), getDto(PAYMENT_2, SETTLED_INVOICE_2)));
|
||||
assertThat(selfPaymentsDaoImpl.getAllSelfPayments()).containsExactlyInAnyOrder(SELF_PAYMENT, SELF_PAYMENT_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSelfPaymentsToChannel() {
|
||||
SelfPaymentJpaDto dto = getDto(PAYMENT, SETTLED_INVOICE);
|
||||
SelfPaymentJpaDto dto = getDto();
|
||||
when(repository.getSelfPaymentsToChannel(anyLong(), anyLong())).thenReturn(List.of(dto, dto));
|
||||
assertThat(selfPaymentsDaoImpl.getSelfPaymentsToChannel(CHANNEL_ID, MAX_AGE)).hasSize(1);
|
||||
}
|
||||
@@ -71,7 +52,7 @@ class SelfPaymentsDaoImplTest {
|
||||
when(repository.getSelfPaymentsToChannel(
|
||||
eq(CHANNEL_ID.getShortChannelId()),
|
||||
longThat(isWithinAFewSeconds(epochSeconds))
|
||||
)).thenReturn(List.of(getDto(PAYMENT, SETTLED_INVOICE)));
|
||||
)).thenReturn(List.of(getDto()));
|
||||
assertThat(selfPaymentsDaoImpl.getSelfPaymentsToChannel(CHANNEL_ID, MAX_AGE))
|
||||
.containsExactlyInAnyOrder(SELF_PAYMENT);
|
||||
}
|
||||
@@ -82,7 +63,7 @@ class SelfPaymentsDaoImplTest {
|
||||
when(repository.getSelfPaymentsFromChannel(
|
||||
eq(CHANNEL_ID.getShortChannelId()),
|
||||
longThat(isWithinAFewSeconds(epochSeconds))
|
||||
)).thenReturn(List.of(getDto(PAYMENT, SETTLED_INVOICE)));
|
||||
)).thenReturn(List.of(getDto()));
|
||||
assertThat(selfPaymentsDaoImpl.getSelfPaymentsFromChannel(CHANNEL_ID, MAX_AGE))
|
||||
.containsExactlyInAnyOrder(SELF_PAYMENT);
|
||||
}
|
||||
@@ -92,10 +73,10 @@ class SelfPaymentsDaoImplTest {
|
||||
return value -> Math.abs(value - epochSeconds) < 10_000;
|
||||
}
|
||||
|
||||
private SelfPaymentJpaDto getDto(Payment payment, SettledInvoice settledInvoice) {
|
||||
private SelfPaymentJpaDto getDto() {
|
||||
return new SelfPaymentJpaDto(
|
||||
SettledInvoiceJpaDto.createFromModel(settledInvoice),
|
||||
PaymentJpaDto.createFromModel(payment)
|
||||
SettledInvoiceJpaDto.createFromModel(de.cotto.lndmanagej.model.SettledInvoiceFixtures.SETTLED_INVOICE),
|
||||
PaymentJpaDto.createFromModel(de.cotto.lndmanagej.model.PaymentFixtures.PAYMENT)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user