Search in sources :

Example 6 with ConfirmationProvider

use of com.github.robozonky.api.confirmations.ConfirmationProvider in project robozonky by RoboZonky.

the class InvestorTest method getZonkyProxy.

private Investor getZonkyProxy(final ProxyType proxyType, final RemoteResponse confirmationResponse, final Authenticated auth) {
    switch(proxyType) {
        case SIMPLE:
            return new Investor.Builder().build(auth);
        case CONFIRMING:
            final ConfirmationProvider cp = mock(ConfirmationProvider.class);
            when(cp.getId()).thenReturn("something");
            switch(confirmationResponse) {
                case ACK:
                    when(cp.requestConfirmation(any(), anyInt(), anyInt())).thenReturn(true);
                    break;
                case NAK:
                    when(cp.requestConfirmation(any(), anyInt(), anyInt())).thenReturn(false);
                    break;
                default:
                    throw new IllegalStateException();
            }
            return new Investor.Builder().usingConfirmation(cp).build(auth);
        default:
            throw new IllegalStateException();
    }
}
Also used : ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider)

Example 7 with ConfirmationProvider

use of com.github.robozonky.api.confirmations.ConfirmationProvider in project robozonky by RoboZonky.

the class CheckerTest method confirmationsProper.

@Test
void confirmationsProper() {
    final ConfirmationProvider cp = mock(ConfirmationProvider.class);
    when(cp.requestConfirmation(any(), anyInt(), anyInt())).thenReturn(false);
    final boolean result = Checker.confirmations(cp, "", SECRET, CheckerTest::mockApiThatReturnsOneLoan);
    assertThat(result).isFalse();
}
Also used : ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Test(org.junit.jupiter.api.Test)

Example 8 with ConfirmationProvider

use of com.github.robozonky.api.confirmations.ConfirmationProvider in project robozonky by RoboZonky.

the class ConfirmationProviderLoaderTest method loading.

@Test
void loading() {
    final String id = UUID.randomUUID().toString();
    final ConfirmationProvider cp = new ConfirmationProvider() {

        @Override
        public boolean requestConfirmation(final RequestId auth, final int loanId, final int amount) {
            return false;
        }

        @Override
        public String getId() {
            return id;
        }
    };
    final ConfirmationProviderService cps = strategy -> Optional.of(cp);
    assertThat(ConfirmationProviderLoader.load(id, Collections.singleton(cps))).contains(cp);
}
Also used : ConfirmationProviderService(com.github.robozonky.api.confirmations.ConfirmationProviderService) Test(org.junit.jupiter.api.Test) ConfirmationProviderService(com.github.robozonky.api.confirmations.ConfirmationProviderService) RequestId(com.github.robozonky.api.confirmations.RequestId) Optional(java.util.Optional) Assertions(org.assertj.core.api.Assertions) UUID(java.util.UUID) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Collections(java.util.Collections) RequestId(com.github.robozonky.api.confirmations.RequestId) ConfirmationProvider(com.github.robozonky.api.confirmations.ConfirmationProvider) Test(org.junit.jupiter.api.Test)

Aggregations

ConfirmationProvider (com.github.robozonky.api.confirmations.ConfirmationProvider)8 Test (org.junit.jupiter.api.Test)6 InstallData (com.izforge.izpack.api.data.InstallData)2 DataValidator (com.izforge.izpack.api.installer.DataValidator)2 Collections (java.util.Collections)2 ConfirmationProviderService (com.github.robozonky.api.confirmations.ConfirmationProviderService)1 RequestId (com.github.robozonky.api.confirmations.RequestId)1 Event (com.github.robozonky.api.notifications.Event)1 ExecutionCompletedEvent (com.github.robozonky.api.notifications.ExecutionCompletedEvent)1 ExecutionStartedEvent (com.github.robozonky.api.notifications.ExecutionStartedEvent)1 InvestmentDelegatedEvent (com.github.robozonky.api.notifications.InvestmentDelegatedEvent)1 InvestmentMadeEvent (com.github.robozonky.api.notifications.InvestmentMadeEvent)1 InvestmentRejectedEvent (com.github.robozonky.api.notifications.InvestmentRejectedEvent)1 InvestmentRequestedEvent (com.github.robozonky.api.notifications.InvestmentRequestedEvent)1 InvestmentSkippedEvent (com.github.robozonky.api.notifications.InvestmentSkippedEvent)1 LoanRecommendedEvent (com.github.robozonky.api.notifications.LoanRecommendedEvent)1 ControlApi (com.github.robozonky.api.remote.ControlApi)1 BlockedAmount (com.github.robozonky.api.remote.entities.BlockedAmount)1 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)1 TransactionCategory (com.github.robozonky.api.remote.enums.TransactionCategory)1