Skip to content

Commit

Permalink
fix: ParseFileControllerTest.testSaveAsyncSuccessWithUri
Browse files Browse the repository at this point in the history
  • Loading branch information
abubkr-hago committed Aug 19, 2024
1 parent 18c9ad2 commit ed42721
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions parse/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
includeAndroidResources = true

all {
jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED'
// Configure JaCoCo options
jacoco {
includeNoLocationClasses = true
Expand Down
3 changes: 2 additions & 1 deletion parse/src/main/java/com/parse/ParseUriHttpBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private static long getUriLength(Uri uri) {
long length = -1;

try (Cursor cursor =
getApplicationContext()
ParsePlugins.get()
.applicationContext()
.getContentResolver()
.query(uri, null, null, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
Expand Down
8 changes: 7 additions & 1 deletion parse/src/test/java/com/parse/ParseFileControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.net.Uri;
import androidx.test.platform.app.InstrumentationRegistry;
import com.parse.boltsinternal.Task;
import com.parse.http.ParseHttpRequest;
import com.parse.http.ParseHttpResponse;
Expand All @@ -42,7 +44,7 @@

// For org.json
@RunWith(RobolectricTestRunner.class)
public class ParseFileControllerTest {
public class ParseFileControllerTest extends ResetPluginsParseTest {

@Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder();

Expand Down Expand Up @@ -216,6 +218,10 @@ public void testSaveAsyncSuccessWithUri() throws Exception {
when(restClient.execute(any(ParseHttpRequest.class))).thenReturn(mockResponse);

File root = temporaryFolder.getRoot();
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
ParsePlugins plugins = mock(ParsePlugins.class);
when(plugins.applicationContext()).thenReturn(context);
ParsePlugins.set(plugins);
ParseFileController controller = new ParseFileController(restClient, root);

File file = new File(root, "test");
Expand Down

0 comments on commit ed42721

Please sign in to comment.