PeakInvestigatorDefaultProviderFactory implements PeakInvestigatorProviderFactory { @Override public PeakInvestigatorInitProvider createInitProvider(InitAction action) { final Status status = action.getMaxPotentialCost(DEFAULT_RTO) <= action.getFunds() ? Status.ACCEPT : Status.CANCEL; return new PeakInvestigatorInitProvider() { @Override public Status show() { return status; } @Override public String getRto() { return DEFAULT_RTO; } }; }  @Override PeakInvestigatorProjectProvider createProjectProvider(); @Override PeakInvestigatorOptionsProvider createOptionsProvider(PiVersionsAction action,
      final int dataStart, final int dataEnd); @Override PeakInvestigatorInitProvider createInitProvider(InitAction action);  }
@Test public void testInitWithSufficientFunds() { InitAction action = mock(InitAction.class); when(action.getFunds()).thenReturn(100.0); when(action.getMaxPotentialCost("RTO-24")).thenReturn(50.0); PeakInvestigatorInitProvider provider = factory.createInitProvider(action); assertThat(provider.show(), equalTo(PeakInvestigatorProvider.Status.ACCEPT)); assertThat(provider.getRto(), equalTo("RTO-24")); }
@Test public void testInitWithoutSufficientFunds() { InitAction action = mock(InitAction.class); when(action.getFunds()).thenReturn(10.0); when(action.getMaxPotentialCost("RTO-24")).thenReturn(50.0); PeakInvestigatorInitProvider provider = factory.createInitProvider(action); assertThat(provider.show(), equalTo(PeakInvestigatorProvider.Status.CANCEL)); }