Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nullability Annotations to Java Classes] Add Missing Nullability Annotations to Media Network Client Classes (safe) #2878

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
af01ceb
Refactor: Reformat media rest client
ParaskP7 Oct 17, 2023
dff7ec5
Refactor: Reformat media xmlrpc client
ParaskP7 Oct 17, 2023
b2e3a7c
Refactor: Replace anonymous classes with lambda on media rest client
ParaskP7 Oct 17, 2023
68aedbf
Refactor: Replace anonymous classes with lambda on media xmlrpc client
ParaskP7 Oct 17, 2023
8afc67a
Analysis: Add missing final to ok http client field on media clients
ParaskP7 Oct 17, 2023
b7c74c1
Analysis: Add missing final to media response utils field on media rest
ParaskP7 Oct 17, 2023
224c637
Analysis: Add missing final to cnt upload calls field on media clients
ParaskP7 Oct 17, 2023
05c2fb5
Analysis: Un-guard usages of media error on media rest client
ParaskP7 Oct 17, 2023
db21abf
Analysis: Change type of request to include the missing generic type
ParaskP7 Oct 17, 2023
46901f1
Docs: Replace url with html link on media rest client
ParaskP7 Oct 17, 2023
0381ccc
Analysis: Guard usages of media list on media rest client
ParaskP7 Oct 17, 2023
ea3a3fd
Analysis: Remove unnecessary is response null checks on media xmlrpc clt
ParaskP7 Oct 18, 2023
935071b
Docs: Replace urls with html links on media xmlrpc client
ParaskP7 Oct 18, 2023
54b6c24
Analysis: Remove io exception from throws list on media xmlrpc client
ParaskP7 Oct 18, 2023
8e4e95c
Analysis: Suppress use of parameterized class map on media xmlrpc client
ParaskP7 Oct 18, 2023
d87de3d
Analysis: Replace string/charset with std charsets utf8 on media xmlrpc
ParaskP7 Oct 18, 2023
7853865
Analysis: Simplify if/else on media xmlrpc client
ParaskP7 Oct 18, 2023
24f6093
Analysis: Add missing nn-a to ok http client field on media clients
ParaskP7 Oct 18, 2023
e06b986
Analysis: Add missing nn-a to media response utils field on media rest
ParaskP7 Oct 18, 2023
3db2009
Analysis: Add missing nn-a to current upload calls field on media clts
ParaskP7 Oct 18, 2023
1f879ab
Analysis: Add missing n-a to on progress on media clients
ParaskP7 Oct 18, 2023
02345c9
Analysis: Add missing n-a to push media on media clients
ParaskP7 Oct 18, 2023
806ae6e
Analysis: Add missing n-a to upload media on media clients
ParaskP7 Oct 18, 2023
95eb024
Analysis: Add missing n-a to fetch media list on media clients
ParaskP7 Oct 18, 2023
e01e7c1
Refactor: Reformat error responses on media clients
ParaskP7 Oct 18, 2023
b9c247b
Analysis: Add missing n-a to fetch media on media clients
ParaskP7 Oct 18, 2023
2175a47
Analysis: Add missing n-a to delete media on media clients
ParaskP7 Oct 18, 2023
03a3cbe
Analysis: Add missing n-a to cancel upload on media clients
ParaskP7 Oct 18, 2023
605dad9
Analysis: Add missing n-a to get media list frm response on media xmlrpc
ParaskP7 Oct 18, 2023
1b14ce1
Analysis: Add missing n-a to get map frm upload response on media xmlrpc
ParaskP7 Oct 18, 2023
5a21c03
Analysis: Add missing n-a to deprecated upload response on media xmlrpc
ParaskP7 Oct 18, 2023
a848034
Analysis: Add missing n-a to media from xmlrpc response on media xmlrpc
ParaskP7 Oct 18, 2023
79bd324
Analysis: Add missing n-a to get basic params on media xmlrpc client
ParaskP7 Oct 18, 2023
3f3b664
Analysis: Add missing n-a to is 404 response on media xmlrpc client
ParaskP7 Oct 18, 2023
e7500da
Analysis: Add missing n-a to media error from exception on media xmlrpc
ParaskP7 Oct 18, 2023
c00fa5c
Analysis: Add missing n-a to get file (url) for size on media xmlrpc
ParaskP7 Oct 18, 2023
2a6e10e
Analysis: Guard usages of media title on media xmlrpc client
ParaskP7 Oct 18, 2023
315a7cc
Analysis: Create missing switch cases for media store errors
ParaskP7 Oct 18, 2023
1679912
Analysis: Remove unnecessary is split msg null checks on media store
ParaskP7 Oct 19, 2023
69ef729
Analysis: Replace explicit type argument with <> on on media changed
ParaskP7 Oct 19, 2023
ed685c1
Analysis: Suppress raw types warning on media store
ParaskP7 Oct 19, 2023
26ecb15
Analysis: Use inserted media on instantiate media model store method
ParaskP7 Oct 19, 2023
590c55d
Analysis: Suppress unused warning on media related payload constructor
ParaskP7 Oct 19, 2023
3501ffb
Analysis: Suppress unused warnings on get related media methods
ParaskP7 Oct 19, 2023
0bfd72c
Analysis: Suppress same parameter value warning on media store
ParaskP7 Oct 19, 2023
339e909
Analysis: Add missing n-a to media payload on media store
ParaskP7 Oct 18, 2023
48d95ac
Analysis: Add missing n-a to upload mediaPayload on media store
ParaskP7 Oct 19, 2023
0adabd3
Analysis: Add missing n-a to fetch media list payload on media store
ParaskP7 Oct 19, 2023
2085742
Analysis: Add missing n-a to fetch media list response pl on media store
ParaskP7 Oct 19, 2023
0189477
Analysis: Add missing n-a to progress payload on media store
ParaskP7 Oct 19, 2023
7d49bff
Analysis: Add missing n-a to cancel media payload on media store
ParaskP7 Oct 20, 2023
da9a621
Refactor: Reformat media store
ParaskP7 Oct 20, 2023
9ddce58
Test: Suppress kotlin internal in java on media store test
ParaskP7 Oct 20, 2023
88f415f
Test: Add missing final to media store on media store test
ParaskP7 Oct 20, 2023
572bf85
Test: Resolve robolectric related application deprecation warnings
ParaskP7 Oct 20, 2023
ad21ea5
Test: Simplify assert true assertions on media store test
ParaskP7 Oct 20, 2023
af02aff
Test: Suppress new class naming convention for connected tests
ParaskP7 Oct 20, 2023
8f235d6
Test: Suppress throws count for ms media test
ParaskP7 Oct 20, 2023
7d2084e
Test: Simplify new media model helper func. on ms media test
ParaskP7 Oct 20, 2023
6a652a5
Test: Guard usages of remote id queue poll on ms media test
ParaskP7 Oct 20, 2023
e370b84
Test: Fix typo with we're on ms media test
ParaskP7 Oct 20, 2023
4485395
Test: Simplify new media model helper function on ms upload test
ParaskP7 Oct 20, 2023
e4c6d1f
Test: Remove unnecessary media path length on ms upload test
ParaskP7 Oct 20, 2023
2800252
Test: Make create new post method void on ms upload test
ParaskP7 Oct 20, 2023
68151b6
Test: Remove interrupted exception from throws list on ms upload test
ParaskP7 Oct 20, 2023
66b4d27
Test: Insert <p> on ms upload store test
ParaskP7 Oct 20, 2023
c9d440d
Test: Simplify new media model helper function on ms upload store test
ParaskP7 Oct 20, 2023
034f800
Test: Remove unnecessary media path length on ms upload store test
ParaskP7 Oct 20, 2023
e28b960
Test: Delete unused account store file on rs media test jetpack
ParaskP7 Oct 20, 2023
61deec7
Test: Simplify new media model helper function on rs media test jetpack
ParaskP7 Oct 20, 2023
3be1fc6
Test: Remove unnecessary media path length on rs media test jetpack
ParaskP7 Oct 20, 2023
6c96bca
Test: Simplify new media model helper function on rs media test wp com
ParaskP7 Oct 20, 2023
d3c8146
Test: Simplify new media model helper function on rs media test xmlrpc
ParaskP7 Oct 20, 2023
ec6e158
Docs: Improve documentation on rest upload request body
ParaskP7 Oct 20, 2023
3db2be4
Analysis: Guard usages of params get key on rest upload request body
ParaskP7 Oct 20, 2023
17118ee
Analysis: Suppress request body create deprecation on rest upload rb
ParaskP7 Oct 20, 2023
2f2875a
Analysis: Suppress string escape utils deprecation on xmlrpc upload rb
ParaskP7 Oct 20, 2023
007716e
Analysis: Replace fi stream with try with resource on xmlrpc upload rb
ParaskP7 Oct 20, 2023
b54bd63
Docs: Improve documentation on base upload request body
ParaskP7 Oct 20, 2023
e145b90
Analysis: Add missing n-a to counting sink on base upload request body
ParaskP7 Oct 20, 2023
1b6399d
Docs: Improve documentation on media wp com rest response
ParaskP7 Oct 20, 2023
61b71b4
Analysis: Make inner classes static on media wp com rest response
ParaskP7 Oct 20, 2023
8b8c7ae
Analysis: Delete unused thumbnails field on media wp com rest response
ParaskP7 Oct 20, 2023
a12ad85
Analysis: Add missing nl-a to s method parameter on media fragment
ParaskP7 Oct 20, 2023
971a8bc
Analysis: Delete unused multiple fields on media wp com rest response
ParaskP7 Oct 20, 2023
e57e227
Analysis: Add missing nn-a to multi field on media wp com rest response
ParaskP7 Oct 20, 2023
3334cf0
Analysis: Add missing n-a to media wp com rest response fields
ParaskP7 Oct 23, 2023
b93600e
Merge branch 'trunk' of github.com:wordpress-mobile/WordPress-FluxC-A…
ParaskP7 Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlin.properties.Delegates.notNull

@Suppress("ClassNaming")
@SuppressLint("UseSparseArrays")
class MockedStack_MediaTest : MockedStack_Base() {
@Inject lateinit var dispatcher: Dispatcher
Expand Down Expand Up @@ -66,7 +67,7 @@ class MockedStack_MediaTest : MockedStack_Base() {
interceptor.respondWithSticky("media-upload-response-success.json")

// First, try canceling an image with the default behavior (canceled image is deleted from the store)
newMediaModel("Test Title", sampleImagePath, "image/jpeg").let { testMedia ->
newMediaModel("Test Title", sampleImagePath).let { testMedia ->
countDownLatch = CountDownLatch(1)
nextEvent = TestEvents.CANCELED_MEDIA
val payload = UploadMediaPayload(testSite, testMedia, true)
Expand All @@ -82,7 +83,7 @@ class MockedStack_MediaTest : MockedStack_Base() {
}

// Now, try canceling with delete=false (canceled image should be marked as failed and kept in the store)
newMediaModel("Test Title", sampleImagePath, "image/jpeg").let { testMedia ->
newMediaModel("Test Title", sampleImagePath).let { testMedia ->
countDownLatch = CountDownLatch(1)
nextEvent = TestEvents.CANCELED_MEDIA
val payload = UploadMediaPayload(testSite, testMedia, true)
Expand Down Expand Up @@ -205,7 +206,7 @@ class MockedStack_MediaTest : MockedStack_Base() {
Assert.assertEquals(amountToCancel, mediaStore.getSiteMediaWithState(testSite, MediaUploadState.FAILED).size)
}

@Suppress("unused")
@Suppress("unused", "ThrowsCount")
@Subscribe
fun onMediaUploaded(event: OnMediaUploaded) {
if (event.isError) {
Expand Down Expand Up @@ -244,19 +245,19 @@ class MockedStack_MediaTest : MockedStack_Base() {
}

private fun addMediaModelToUploadArray(title: String) {
val mediaModel = newMediaModel(title, sampleImagePath, "image/jpeg")
val mediaModel = newMediaModel(title, sampleImagePath)
uploadedMediaModels[mediaModel.id] = mediaModel
}

private fun newMediaModel(testTitle: String, mediaPath: String, mimeType: String): MediaModel {
private fun newMediaModel(testTitle: String, mediaPath: String): MediaModel {
val testDescription = "Test Description"
val testCaption = "Test Caption"
val testAlt = "Test Alt"

return mediaStore.instantiateMediaModel().apply {
filePath = mediaPath
fileExtension = mediaPath.substring(mediaPath.lastIndexOf(".") + 1)
this.mimeType = mimeType
this.mimeType = "image/jpeg"
fileName = mediaPath.substring(mediaPath.lastIndexOf("/"))
title = testTitle
description = testDescription
Expand All @@ -278,7 +279,7 @@ class MockedStack_MediaTest : MockedStack_Base() {
// To imitate a real set of media upload requests as much as possible, each one should return a unique
// remote media id. This also makes sure the MediaModel table doesn't treat these as duplicate entries and
// deletes them, failing the test.
defaultId: String -> defaultId.replace("9999", remoteIdQueue.poll().toString())
defaultId: String -> defaultId.replace("9999", remoteIdQueue.poll()?.toString() ?: "")
}

countDownLatch = CountDownLatch(mediaList.size)
Expand All @@ -292,7 +293,7 @@ class MockedStack_MediaTest : MockedStack_Base() {
// Wait a bit and issue the cancel command
TestUtils.waitFor(300)

// We'e only cancelling the first n=howManyFirstToCancel uploads
// We're only cancelling the first n=howManyFirstToCancel uploads
for (i in 0 until howManyFirstToCancel) {
val media = mediaList[i]
val payload = CancelMediaPayload(testSite, media, delete)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@

/**
* Tests using a Mocked Network app component. Test the Store itself and not the underlying network component(s).
*
* <p>
* Tests the interactions between the MediaStore/PostStore and the UploadStore, without directly injecting the
* UploadStore in the test class.
*/
@SuppressWarnings("NewClassNamingConvention")
public class MockedStack_UploadStoreTest extends MockedStack_Base {
@Inject Dispatcher mDispatcher;
@Inject MediaStore mMediaStore;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void setUp() throws Exception {

@Test
public void testUploadMedia() throws InterruptedException {
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
startSuccessfulMediaUpload(testMedia, getTestSite());
assertTrue(mCountDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS));

Expand Down Expand Up @@ -89,21 +90,17 @@ public void onMediaUploaded(OnMediaUploaded event) {
}
}

private MediaModel newMediaModel(String mediaPath, String mimeType) {
return newMediaModel("Test Title", mediaPath, mimeType);
}

private MediaModel newMediaModel(String testTitle, String mediaPath, String mimeType) {
private MediaModel newMediaModel(String mediaPath) {
final String testDescription = "Test Description";
final String testCaption = "Test Caption";
final String testAlt = "Test Alt";

MediaModel testMedia = mMediaStore.instantiateMediaModel();
testMedia.setFilePath(mediaPath);
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1, mediaPath.length()));
testMedia.setMimeType(mimeType);
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/"), mediaPath.length()));
testMedia.setTitle(testTitle);
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1));
testMedia.setMimeType("image/jpeg");
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/")));
testMedia.setTitle("Test Title");
testMedia.setDescription(testDescription);
testMedia.setCaption(testCaption);
testMedia.setAlt(testAlt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
/**
* Tests using a Mocked Network app component. Test the Store itself and not the underlying network component(s).
*/
@SuppressWarnings("NewClassNamingConvention")
public class MockedStack_UploadTest extends MockedStack_Base {
private static final String POST_DEFAULT_TITLE = "UploadTest base post";
private static final String POST_DEFAULT_DESCRIPTION = "Hi there, I'm a post from FluxC!";
Expand Down Expand Up @@ -88,7 +89,7 @@ public void setUp() throws Exception {

@Test
public void testUploadMedia() throws InterruptedException {
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
startSuccessfulMediaUpload(testMedia, getTestSite());
assertTrue(mCountDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS));

Expand All @@ -101,7 +102,7 @@ public void testUploadMedia() throws InterruptedException {

@Test
public void testUploadMediaError() throws InterruptedException {
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
startFailingMediaUpload(testMedia, getTestSite());
assertTrue(mCountDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS));

Expand All @@ -120,7 +121,7 @@ public void testCancelImageUpload() throws InterruptedException {
mInterceptor.respondWithSticky("media-upload-response-success.json", 1000L, null);

// First, try canceling an image with the default behavior (canceled image is deleted from the store)
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
mCountDownLatch = new CountDownLatch(1);
mNextEvent = TestEvents.CANCELED_MEDIA;
UploadMediaPayload payload = new UploadMediaPayload(getTestSite(), testMedia, true);
Expand All @@ -141,7 +142,7 @@ public void testCancelImageUpload() throws InterruptedException {
assertNull(mediaUploadModel);

// Now, try canceling with delete=false (canceled image should be marked as failed and kept in the store)
testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
testMedia = newMediaModel(getSampleImagePath());
mCountDownLatch = new CountDownLatch(1);
mNextEvent = TestEvents.CANCELED_MEDIA;
payload = new UploadMediaPayload(getTestSite(), testMedia, true);
Expand Down Expand Up @@ -174,7 +175,7 @@ public void testRegisterPostAndUploadMediaWithError() throws InterruptedExceptio
setupPostAttributes();

// Start uploading media
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
testMedia.setLocalPostId(mPost.getId());
startFailingMediaUpload(testMedia, site);

Expand Down Expand Up @@ -271,7 +272,7 @@ public void testRegisterPostAndUploadMediaWithPostCancellation() throws Interrup
setupPostAttributes();

// Start uploading media
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
testMedia.setLocalPostId(mPost.getId());
startSuccessfulMediaUpload(testMedia, site);

Expand Down Expand Up @@ -341,7 +342,7 @@ public void testUploadMediaInCancelledPost() throws InterruptedException {
setupPostAttributes();

// Start uploading media
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
testMedia.setLocalPostId(mPost.getId());
startFailingMediaUpload(testMedia, site);

Expand Down Expand Up @@ -372,7 +373,7 @@ public void testUploadMediaInCancelledPost() throws InterruptedException {
clearMedia(mPost, mUploadStore.getFailedMediaForPost(mPost));

// Upload a new media item to the cancelled post
testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
testMedia = newMediaModel(getSampleImagePath());
testMedia.setLocalPostId(mPost.getId());
startFailingMediaUpload(testMedia, site);

Expand All @@ -398,7 +399,7 @@ public void testUpdateMediaModelState() throws InterruptedException {
setupPostAttributes();

// Start uploading media
MediaModel testMedia = newMediaModel(getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(getSampleImagePath());
testMedia.setLocalPostId(mPost.getId());
startSuccessfulMediaUpload(testMedia, site);

Expand Down Expand Up @@ -513,31 +514,26 @@ public void onUploadChanged(OnUploadChanged event) {
}
}

private MediaModel newMediaModel(String mediaPath, String mimeType) {
return newMediaModel("Test Title", mediaPath, mimeType);
}

private MediaModel newMediaModel(String testTitle, String mediaPath, String mimeType) {
private MediaModel newMediaModel(String mediaPath) {
final String testDescription = "Test Description";
final String testCaption = "Test Caption";
final String testAlt = "Test Alt";

MediaModel testMedia = mMediaStore.instantiateMediaModel();
testMedia.setFilePath(mediaPath);
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1, mediaPath.length()));
testMedia.setMimeType(mimeType);
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/"), mediaPath.length()));
testMedia.setTitle(testTitle);
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1));
testMedia.setMimeType("image/jpeg");
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/")));
testMedia.setTitle("Test Title");
testMedia.setDescription(testDescription);
testMedia.setCaption(testCaption);
testMedia.setAlt(testAlt);

return testMedia;
}

private PostModel createNewPost(SiteModel site) throws InterruptedException {
private void createNewPost(SiteModel site) {
mPost = mPostStore.instantiatePostModel(site, false);
return mPost;
}

private void setupPostAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.wordpress.android.fluxc.generated.SiteActionBuilder;
import org.wordpress.android.fluxc.model.MediaModel;
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.fluxc.store.AccountStore;
import org.wordpress.android.fluxc.store.AccountStore.AuthenticatePayload;
import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged;
import org.wordpress.android.fluxc.store.AccountStore.OnAuthenticationChanged;
Expand All @@ -33,9 +32,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@SuppressWarnings("NewClassNamingConvention")
public class ReleaseStack_MediaTestJetpack extends ReleaseStack_Base {
@Inject SiteStore mSiteStore;
@Inject AccountStore mAccountStore;
@Inject MediaStore mMediaStore;

private enum TestEvents {
Expand Down Expand Up @@ -72,7 +71,7 @@ public void testUploadMediaLowFilesizeLimit() throws InterruptedException {
site = mSiteStore.getSites().get(0);

// Attempt to upload an image that exceeds the site's maximum upload_max_filesize or post_max_size
MediaModel testMedia = newMediaModel(site, getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(site, getSampleImagePath());
mNextEvent = TestEvents.ERROR_EXCEEDS_FILESIZE_LIMIT;
uploadMedia(site, testMedia);

Expand All @@ -92,7 +91,7 @@ public void testUploadMediaLowMemoryLimit() throws InterruptedException {
site.setMemoryLimit(1985); // Artificially set the site's memory limit, in bytes

// Attempt to upload an image that exceeds the site's memory limit
MediaModel testMedia = newMediaModel(site, getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(site, getSampleImagePath());
mNextEvent = TestEvents.ERROR_EXCEEDS_MEMORY_LIMIT;
uploadMedia(site, testMedia);

Expand All @@ -116,7 +115,7 @@ public void testUploadMediaLowQuotaAvailableLimit() throws InterruptedException
site.setSpaceUsed(50);

// Attempt to upload an image that exceeds the site's memory limit
MediaModel testMedia = newMediaModel(site, getSampleImagePath(), "image/jpeg");
MediaModel testMedia = newMediaModel(site, getSampleImagePath());
mNextEvent = TestEvents.ERROR_EXCEEDS_SITE_SPACE_QUOTA_LIMIT;
uploadMedia(site, testMedia);

Expand Down Expand Up @@ -148,17 +147,17 @@ public void onMediaUploaded(OnMediaUploaded event) {
}
}

private MediaModel newMediaModel(SiteModel site, String mediaPath, String mimeType) {
private MediaModel newMediaModel(SiteModel site, String mediaPath) {
final String testTitle = "Test Title";
final String testDescription = "Test Description";
final String testCaption = "Test Caption";
final String testAlt = "Test Alt";

MediaModel testMedia = mMediaStore.instantiateMediaModel();
testMedia.setFilePath(mediaPath);
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1, mediaPath.length()));
testMedia.setMimeType(mimeType);
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/"), mediaPath.length()));
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1));
testMedia.setMimeType("image/jpeg");
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/")));
testMedia.setTitle(testTitle);
testMedia.setDescription(testDescription);
testMedia.setCaption(testCaption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.junit.Assert.assertTrue;

@SuppressLint("UseSparseArrays")
@SuppressWarnings("NewClassNamingConvention")
public class ReleaseStack_MediaTestWPCom extends ReleaseStack_WPComBase {
@Inject MediaStore mMediaStore;

Expand Down Expand Up @@ -380,10 +381,6 @@ private boolean eventHasKnownImages(OnMediaChanged event) {
}

private MediaModel newMediaModel(String mediaPath, String mimeType) {
return newMediaModel("Test Title", mediaPath, mimeType);
}

private MediaModel newMediaModel(String testTitle, String mediaPath, String mimeType) {
final String testDescription = "Test Description";
final String testCaption = "Test Caption";
final String testAlt = "Test Alt";
Expand All @@ -393,7 +390,7 @@ private MediaModel newMediaModel(String testTitle, String mediaPath, String mime
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1));
testMedia.setMimeType(mimeType);
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/")));
testMedia.setTitle(testTitle);
testMedia.setTitle("Test Title");
testMedia.setDescription(testDescription);
testMedia.setCaption(testCaption);
testMedia.setAlt(testAlt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.junit.Assert.assertTrue;

@SuppressLint("UseSparseArrays")
@SuppressWarnings("NewClassNamingConvention")
public class ReleaseStack_MediaTestXMLRPC extends ReleaseStack_XMLRPCBase {
@SuppressWarnings("unused")
@Inject AccountStore mAccountStore;
Expand Down Expand Up @@ -403,10 +404,6 @@ public void onMediaListFetched(OnMediaListFetched event) {
}

private MediaModel newMediaModel(String mediaPath, String mimeType) {
return newMediaModel("Test Title", mediaPath, mimeType);
}

private MediaModel newMediaModel(String testTitle, String mediaPath, String mimeType) {
final String testDescription = "Test Description";
final String testCaption = "Test Caption";
final String testAlt = "Test Alt";
Expand All @@ -416,7 +413,7 @@ private MediaModel newMediaModel(String testTitle, String mediaPath, String mime
testMedia.setFileExtension(mediaPath.substring(mediaPath.lastIndexOf(".") + 1));
testMedia.setMimeType(mimeType);
testMedia.setFileName(mediaPath.substring(mediaPath.lastIndexOf("/")));
testMedia.setTitle(testTitle);
testMedia.setTitle("Test Title");
testMedia.setDescription(testDescription);
testMedia.setCaption(testCaption);
testMedia.setAlt(testAlt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import org.greenrobot.eventbus.Subscribe;
Expand Down Expand Up @@ -266,8 +267,10 @@ public void onMediaUploaded(OnMediaUploaded event) {
}
}

private void prependToLog(final String s) {
((MainExampleActivity) getActivity()).prependToLog(s);
private void prependToLog(@Nullable final String s) {
if (s != null) {
((MainExampleActivity) getActivity()).prependToLog(s);
}
}

private void fetchMediaList(@NonNull SiteModel site) {
Expand Down
Loading
Loading