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

Fixes 3463 replace assert with assert that #5107

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation 'com.karumi:dexter:5.0.0'
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
// implementation 'com.google.firebase:firebase-firestore:24.1.2'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?


kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
implementation "com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:$ADAPTER_DELEGATES_VERSION"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package fr.free.nrw.commons.media;

import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import static android.view.View.GONE;
Expand All @@ -11,6 +10,11 @@
import static fr.free.nrw.commons.description.EditDescriptionConstants.WIKITEXT;
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION;
import static fr.free.nrw.commons.utils.LangCodeUtils.getLocalizedResources;
//import org.junit.Test;
//import static org.junit.Assert.assertThat;
//import static org.hamcrest.Matchers.is;
//import static org.hamcrest.Matchers.not;
//import static org.hamcrest.Matchers.nullValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
Expand Down Expand Up @@ -991,6 +995,7 @@ public void onActivityResult(final int requestCode, final int resultCode,

if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {

// assertThat(data, not(nullValue()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

assert data != null;
final CameraPosition cameraPosition = LocationPicker.getCameraPosition(data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package fr.free.nrw.commons.auth
import fr.free.nrw.commons.FakeContextWrapper
import fr.free.nrw.commons.FakeContextWrapperWithException
import fr.free.nrw.commons.TestCommonsApplication
import org.junit.Assert
import org.junit.Assert.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind importing only the needed classes, explicitly?

import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import org.hamcrest.CoreMatchers.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind importing only the needed classes, explicitly?

import org.hamcrest.MatcherAssert.assertThat;


@RunWith(RobolectricTestRunner::class)
@Config(sdk = [21], application = TestCommonsApplication::class)
Expand All @@ -28,34 +31,34 @@ class AccountUtilUnitTest {
@Test
@Throws(Exception::class)
fun checkNotNull() {
Assert.assertNotNull(accountUtil)
assertThat(accountUtil, not(nullValue()));
}

@Test
@Throws(Exception::class)
fun testGetUserName() {
Assert.assertEquals(AccountUtil.getUserName(context), "[email protected]")
assertThat(AccountUtil.getUserName(context), equalTo("[email protected]"))
}

@Test
@Throws(Exception::class)
fun testGetUserNameWithException() {
val context =
FakeContextWrapperWithException(RuntimeEnvironment.application.applicationContext)
Assert.assertEquals(AccountUtil.getUserName(context), null)
assertThat(AccountUtil.getUserName(context), not(nullValue()))
}

@Test
@Throws(Exception::class)
fun testAccount() {
Assert.assertEquals(AccountUtil.account(context)?.name, "[email protected]")
assertThat(AccountUtil.account(context)?.name, equalTo("[email protected]"))
}

@Test
@Throws(Exception::class)
fun testAccountWithException() {
val context =
FakeContextWrapperWithException(RuntimeEnvironment.application.applicationContext)
Assert.assertEquals(AccountUtil.account(context), null)
assertThat(AccountUtil.account(context), not(nullValue()))
}
}
4 changes: 2 additions & 2 deletions data-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ version = "${VERSION_NAME}"
group = "${GROUP_ID}"

android {
compileSdkVersion 28
compileSdkVersion 30

defaultConfig {
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

versionCode 1
versionName "${VERSION_NAME}"

Expand Down