use of com.github.robozonky.common.remote.OAuth in project robozonky by RoboZonky.
the class ZonkySettingsValidatorTest method properLogin.
@Test
void properLogin() {
// mock data
final ZonkyApiToken token = mock(ZonkyApiToken.class);
final OAuth oauth = mock(OAuth.class);
when(oauth.login(any(), any())).thenReturn(token);
final Zonky zonky = mock(Zonky.class);
final ApiProvider provider = mockApiProvider(oauth, token, zonky);
// execute SUT
final ZonkySettingsValidator validator = new ZonkySettingsValidator(() -> provider);
final InstallData d = ZonkySettingsValidatorTest.mockInstallData();
final DataValidator.Status result = validator.validateData(d);
// test
assertThat(result).isEqualTo(DataValidator.Status.OK);
verify(oauth).login(eq(ZonkySettingsValidatorTest.USERNAME), eq(ZonkySettingsValidatorTest.PASSWORD.toCharArray()));
verify(zonky).logout();
}
use of com.github.robozonky.common.remote.OAuth in project robozonky by RoboZonky.
the class ZonkySettingsValidatorTest method error.
@Test
void error() {
// mock data
final OAuth oauth = mock(OAuth.class);
when(oauth.login(any(), any())).thenThrow(new ServerErrorException(Response.Status.INTERNAL_SERVER_ERROR));
final ApiProvider provider = mockApiProvider(oauth);
final InstallData d = ZonkySettingsValidatorTest.mockInstallData();
// execute SUT
final ZonkySettingsValidator validator = new ZonkySettingsValidator(() -> provider);
final DataValidator.Status result = validator.validateData(d);
// test
assertThat(result).isEqualTo(DataValidator.Status.ERROR);
}
Aggregations