use of it.niedermann.owncloud.notes.shared.model.OcsUser in project nextcloud-notes by stefan-niedermann.
the class CapabilitiesClientTest method testGetDisplayName.
@SuppressWarnings("unchecked")
@Test
public void testGetDisplayName() throws IOException {
final var mockOcs = new OcsResponse<OcsUser>();
mockOcs.ocs = new OcsResponse.OcsWrapper<>();
mockOcs.ocs.data = new OcsUser();
mockOcs.ocs.data.displayName = "Peter";
final var responseMock = Response.success(mockOcs);
final var callMock = mock(Call.class);
when(ocsAPI.getUser(any())).thenReturn(callMock);
when(callMock.execute()).thenReturn(responseMock);
assertEquals("Peter", CapabilitiesClient.getDisplayName(ApplicationProvider.getApplicationContext(), ssoAccount, apiProvider));
when(callMock.execute()).thenThrow(new RuntimeException() {
@Override
public void printStackTrace() {
// Do not spam console, this will be printed.
}
});
assertNull(CapabilitiesClient.getDisplayName(ApplicationProvider.getApplicationContext(), ssoAccount, apiProvider));
}
Aggregations