Skip to content

Commit

Permalink
fix: Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Niedermann <[email protected]>
  • Loading branch information
stefan-niedermann committed Jan 19, 2024
1 parent 712d8a5 commit a24af19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import com.nextcloud.android.sso.api.EmptyResponse;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void testCreateAccountWithFailingFirstBoardCall() {
when(dataBaseAdapter.createAccountDirectly(any(Account.class))).thenReturn(account);
doAnswer(invocation -> {
((ResponseCallback<ParsedResponse<Capabilities>>) invocation.getArgument(0))
.onError(new NextcloudHttpRequestFailedException(404, new RuntimeException()));
.onError(new NextcloudHttpRequestFailedException(ApplicationProvider.getApplicationContext(), 404, new RuntimeException()));
return null;
}).when(serverAdapter).getBoards(any());

Expand Down Expand Up @@ -269,7 +269,6 @@ public void testReadAccountsDirectly() {
public void testRefreshCapabilities() throws ExecutionException, InterruptedException {
final var account = new Account(1337L, "Test", "Peter", "example.com");
account.setEtag("This-Is-The-Old_ETag");
//noinspection unchecked
final var mockedResponse = mock(ParsedResponse.class);
final var serverResponse = new Capabilities();
serverResponse.setDeckVersion(Version.of("1.0.0"));
Expand Down Expand Up @@ -309,7 +308,7 @@ public void onError(Throwable throwable) {
doAnswer(invocation -> {
//noinspection unchecked
((ResponseCallback<ParsedResponse<Capabilities>>) invocation.getArgument(1))
.onError(new NextcloudHttpRequestFailedException(304, new RuntimeException()));
.onError(new NextcloudHttpRequestFailedException(ApplicationProvider.getApplicationContext(), 304, new RuntimeException()));
return null;
}).when(serverAdapter).getCapabilities(anyString(), any());

Expand All @@ -335,7 +334,7 @@ public void onError(Throwable throwable) {
doAnswer(invocation -> {
//noinspection unchecked
((ResponseCallback<ParsedResponse<Capabilities>>) invocation.getArgument(1))
.onError(new NextcloudHttpRequestFailedException(500, new RuntimeException()));
.onError(new NextcloudHttpRequestFailedException(ApplicationProvider.getApplicationContext(), 500, new RuntimeException()));
return null;
}).when(serverAdapter).getCapabilities(anyString(), any());

Expand All @@ -358,7 +357,7 @@ public void onError(Throwable throwable) {
doAnswer(invocation -> {
//noinspection unchecked
((ResponseCallback<ParsedResponse<Capabilities>>) invocation.getArgument(1))
.onError(new NextcloudHttpRequestFailedException(503, new RuntimeException("{\"ocs\": {\"meta\": {\"statuscode\": 503}, \"data\": {\"version\": {\"major\": 20, \"minor\": 0, \"patch\": 1}}}}")));
.onError(new NextcloudHttpRequestFailedException(ApplicationProvider.getApplicationContext(), 503, new RuntimeException("{\"ocs\": {\"meta\": {\"statuscode\": 503}, \"data\": {\"version\": {\"major\": 20, \"minor\": 0, \"patch\": 1}}}}")));
return null;
}).when(serverAdapter).getCapabilities(anyString(), any());

Expand Down

0 comments on commit a24af19

Please sign in to comment.