/*
 * This file is part of Bisq.
 *
 * Bisq is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 *
 * Bisq is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Bisq. If not, see <http://www.gnu.org/licenses/>.
 */

package bisq.core.payment;

import bisq.core.account.witness.AccountAgeWitness;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.offer.Offer;
import bisq.core.payment.payload.PaymentAccountPayload;

import java.util.Collections;

import org.junit.Test;

import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class PaymentAccountsTest {
    @Test
    public void testGetOldestPaymentAccountForOfferWhenNoValidAccounts() {
        PaymentAccounts accounts = new PaymentAccounts(Collections.emptySet(), mock(AccountAgeWitnessService.class));
        PaymentAccount actual = accounts.getOldestPaymentAccountForOffer(mock(Offer.class));

        assertNull(actual);
    }

//    @Test
//    public void testGetOldestPaymentAccountForOffer() {
//        AccountAgeWitnessService service = mock(AccountAgeWitnessService.class);
//
//        PaymentAccount oldest = createAccountWithAge(service, 3);
//        Set<PaymentAccount> accounts = Sets.newHashSet(
//                oldest,
//                createAccountWithAge(service, 2),
//                createAccountWithAge(service, 1));
//
//        BiFunction<Offer, PaymentAccount, Boolean> dummyValidator = (offer, account) -> true;
//        PaymentAccounts testedEntity = new PaymentAccounts(accounts, service, dummyValidator);
//
//        PaymentAccount actual = testedEntity.getOldestPaymentAccountForOffer(mock(Offer.class));
//        assertEquals(oldest, actual);
//    }

    private static PaymentAccount createAccountWithAge(AccountAgeWitnessService service, long age) {
        PaymentAccountPayload payload = mock(PaymentAccountPayload.class);

        PaymentAccount account = mock(PaymentAccount.class);
        when(account.getPaymentAccountPayload()).thenReturn(payload);

        AccountAgeWitness witness = mock(AccountAgeWitness.class);
        when(service.getAccountAge(eq(witness), any())).thenReturn(age);

        when(service.getMyWitness(payload)).thenReturn(witness);

        return account;
    }
}

@@ -1546,768 +1546,8 @@
  %7D%0A%0A
-//    @Test%0A//    public void testGetOldestPaymentAccountForOffer() %7B%0A//        AccountAgeWitnessService service = mock(AccountAgeWitnessService.class);%0A//%0A//        PaymentAccount oldest = createAccountWithAge(service, 3);%0A//        Set%3CPaymentAccount%3E accounts = Sets.newHashSet(%0A//                oldest,%0A//                createAccountWithAge(service, 2),%0A//                createAccountWithAge(service, 1));%0A//%0A//        BiFunction%3COffer, PaymentAccount, Boolean%3E dummyValidator = (offer, account) -%3E true;%0A//        PaymentAccounts testedEntity = new PaymentAccounts(accounts, service, dummyValidator);%0A//%0A//        PaymentAccount actual = testedEntity.getOldestPaymentAccountForOffer(mock(Offer.class));%0A//        assertEquals(oldest, actual);%0A//    %7D%0A%0A
     

Remove commented out test