chore: Migrate FileUtilsTest.kt, NdkConfiguratorUtilsTest.kt and AgpConfiguratorUtilsTest.kt to AssertJ (#45665)

Summary:
Issue: [https://github.com/facebook/react-native/issues/45596](https://github.com/facebook/react-native/issues/45596)

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[INTERNAL] [CHANGED] - Migrated to AssertJ within files FileUtilsTest.kt, NdkConfiguratorUtilsTest.kt and AgpConfiguratorUtilsTest.kt

Pull Request resolved: https://github.com/facebook/react-native/pull/45665

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: GijsWeterings

Differential Revision: D60276163

Pulled By: cortinico

fbshipit-source-id: c730acafc37606f1db8d53a61fc9443d88bccdfc
This commit is contained in:
Henrique Cicero
2024-07-26 05:21:33 -07:00
committed by Facebook GitHub Bot
parent f9ebc1d9ed
commit f4435115cc
3 changed files with 19 additions and 28 deletions
@@ -8,7 +8,7 @@
package com.facebook.react.utils
import java.io.File
import org.junit.Assert.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
@@ -23,7 +23,7 @@ class AgpConfiguratorUtilsTest {
val manifest = File(mainFolder, "AndroidManifest.xml").apply { writeText("") }
val actual = getPackageNameFromManifest(manifest)
assertNull(actual)
assertThat(actual).isNull()
}
@Test
@@ -41,7 +41,7 @@ class AgpConfiguratorUtilsTest {
}
val actual = getPackageNameFromManifest(manifest)
assertNull(actual)
assertThat(actual).isNull()
}
@Test
@@ -59,7 +59,7 @@ class AgpConfiguratorUtilsTest {
}
val actual = getPackageNameFromManifest(manifest)
assertNotNull(actual)
assertEquals("com.facebook.react", actual)
assertThat(actual).isNotNull()
assertThat(actual).isEqualTo("com.facebook.react")
}
}
@@ -8,7 +8,7 @@
package com.facebook.react.utils
import java.io.File
import org.junit.Assert.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
@@ -25,8 +25,8 @@ class FileUtilsTest {
fileToMove.moveTo(destFile)
assertEquals("42", destFile.readText())
assertFalse(fileToMove.exists())
assertThat(destFile).hasContent("42")
assertThat(fileToMove).doesNotExist()
}
@Test
@@ -39,7 +39,7 @@ class FileUtilsTest {
subFolder.recreateDir()
assertTrue(subFolder.exists())
assertEquals(0, subFolder.listFiles()?.size)
assertThat(subFolder).exists()
assertThat(subFolder.listFiles()).hasSize(0)
}
}
@@ -8,8 +8,7 @@
package com.facebook.react.utils
import com.facebook.react.utils.NdkConfiguratorUtils.getPackagingOptionsForVariant
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class NdkConfiguratorUtilsTest {
@@ -18,29 +17,21 @@ class NdkConfiguratorUtilsTest {
fun getPackagingOptionsForVariant_withHermesEnabled() {
val (excludes, includes) = getPackagingOptionsForVariant(hermesEnabled = true)
assertTrue("**/libjsc.so" in excludes)
assertTrue("**/libjscexecutor.so" in excludes)
assertFalse("**/libjsc.so" in includes)
assertFalse("**/libjscexecutor.so" in includes)
assertThat(excludes).containsExactly("**/libjsc.so", "**/libjscexecutor.so")
assertThat(includes).doesNotContain("**/libjsc.so", "**/libjscexecutor.so")
assertTrue("**/libhermes.so" in includes)
assertTrue("**/libhermes_executor.so" in includes)
assertFalse("**/libhermes.so" in excludes)
assertFalse("**/libhermes_executor.so" in excludes)
assertThat(includes).containsExactly("**/libhermes.so", "**/libhermes_executor.so")
assertThat(excludes).doesNotContain("**/libhermes.so", "**/libhermes_executor.so")
}
@Test
fun getPackagingOptionsForVariant_withHermesDisabled() {
val (excludes, includes) = getPackagingOptionsForVariant(hermesEnabled = false)
assertTrue("**/libhermes.so" in excludes)
assertTrue("**/libhermes_executor.so" in excludes)
assertFalse("**/libhermes.so" in includes)
assertFalse("**/libhermes_executor.so" in includes)
assertThat(excludes).containsExactly("**/libhermes.so", "**/libhermes_executor.so")
assertThat(includes).doesNotContain("**/libhermes.so", "**/libhermes_executor.so")
assertTrue("**/libjsc.so" in includes)
assertTrue("**/libjscexecutor.so" in includes)
assertFalse("**/libjsc.so" in excludes)
assertFalse("**/libjscexecutor.so" in excludes)
assertThat(includes).containsExactly("**/libjsc.so", "**/libjscexecutor.so")
assertThat(excludes).doesNotContain("**/libjsc.so", "**/libjscexecutor.so")
}
}