PaymentMethodComponent extends CompactComponent<ReviewAndConfirmViewModel, PaymentMethodComponent.Actions> { @VisibleForTesting() CompactComponent resolveComponent() { if (PaymentTypes.isCardPaymentType(props.getPaymentType())) { return new MethodCard(MethodCard.Props.createFrom(props)); } else if (PaymentTypes.isAccountMoney(props.getPaymentType()) || PaymentMethods.CONSUMER_CREDITS.equals(props.paymentMethodId)) { return new MethodAccountMoney(MethodAccountMoney.Props.createFrom(props)); } else { return new MethodOff(MethodOff.Props.createFrom(props)); } } PaymentMethodComponent(final ReviewAndConfirmViewModel props, final Actions actions); @Override View render(@NonNull final ViewGroup parent);  }
@Test public void whenPaymentTypeIsCardResolveComponentReturnsAMethodCardInstance() { when(model.getPaymentType()).thenReturn(PaymentTypes.CREDIT_CARD); final CompactComponent instance = component.resolveComponent(); assertTrue(instance instanceof MethodCard); }
@Test public void whenPaymentTypeIsOffThenResolveComponentReturnsAMethodOffInstance() { when(model.getPaymentType()).thenReturn(PaymentTypes.BANK_TRANSFER); final CompactComponent instance = component.resolveComponent(); assertTrue(instance instanceof MethodOff); }
@Test public void whenPaymentTypeIsAccountMoneyThenResolveComponentReturnsAMethodAccountMoneyInstance() { when(model.getPaymentType()).thenReturn(PaymentTypes.ACCOUNT_MONEY); final CompactComponent instance = component.resolveComponent(); assertTrue(instance instanceof MethodAccountMoney); }