Skip to content

Commit

Permalink
Merge pull request #1068 from embrace-io/fix-compiler-warnings
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
fractalwrench authored Jul 10, 2024
2 parents d1f4040 + d8e51cf commit 4374d13
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ public class PreSdkStartTest {
@NonNull
private final Embrace embrace = testRule.getEmbrace();

@SuppressWarnings("deprecation")
@Test
public void testStartWithNullContext() {
embrace.start(null);
embrace.start(null, Embrace.AppFramework.NATIVE);
assertFalse(embrace.isStarted());
}

@SuppressWarnings("deprecation")
@Test
public void testStartWithNullAppFramework() {
Context context = testRule.harness.getOverriddenCoreModule().getContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ internal class IntegrationTestRule(
Embrace.getImpl().stop()
}

@Suppress("DEPRECATION")
fun startSdk(
context: Context = harness.overriddenCoreModule.context,
appFramework: AppFramework = harness.appFramework,
Expand All @@ -139,6 +140,7 @@ internal class IntegrationTestRule(
/**
* Test harness for which an instance is generated each test run and provided to the test by the Rule
*/
@Suppress("DEPRECATION")
internal class Harness @JvmOverloads constructor(
currentTimeMs: Long = DEFAULT_SDK_START_TIME_MS,
val startImmediately: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class SessionPropertiesTest {
embrace.addSessionProperty("temp", "tempVal", false)
})

val spans = checkNotNull(session1.data?.spans)
val spans = checkNotNull(session1.data.spans)
with(checkNotNull(spans.find { it.hasFixedAttribute(EmbType.Ux.Session) })) {
assertEquals("thurr", getSessionProperty("always"))
assertEquals("permVal", getSessionProperty("perm"))
Expand All @@ -40,7 +40,7 @@ internal class SessionPropertiesTest {
embrace.removeSessionProperty("perm")
})

val spans2 = checkNotNull(session2.data?.spans)
val spans2 = checkNotNull(session2.data.spans)
with(checkNotNull(spans2.find { it.hasFixedAttribute(EmbType.Ux.Session) })) {
assertEquals("thurr", getSessionProperty("always"))
assertEquals("value", getSessionProperty("newTemp"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal class OtelSessionGatingTest {
assertEquals(!gated, sessionSpan.hasEventOfType(EmbType.Ux.Tap))
assertEquals(!gated, sessionSpan.hasEventOfType(EmbType.Ux.WebView))

val spans = checkNotNull(payload.data?.spans)
val spans = checkNotNull(payload.data.spans)
val anrSpans = spans.filter { it.name == "emb-thread-blockage" }
val expectedCount = when (gated) {
true -> 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ internal class CrashTest {
assertEquals(crashId, attrs.findAttributeValue(LogIncubatingAttributes.LOG_RECORD_UID.key))
}

@Suppress("DEPRECATION")
@Test
fun `React Native crash generates an OTel Log and matches the crashId in the session`() {
with(testRule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import org.robolectric.annotation.Config
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@RunWith(AndroidJUnit4::class)
internal class FlutterInternalInterfaceTest {

@Suppress("DEPRECATION")
@Rule
@JvmField
val testRule: IntegrationTestRule = IntegrationTestRule {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.testcases

import android.os.Build.VERSION_CODES.TIRAMISU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import org.robolectric.annotation.Config
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@RunWith(AndroidJUnit4::class)
internal class ReactNativeInternalInterfaceTest {

@Suppress("DEPRECATION")
@Rule
@JvmField
val testRule: IntegrationTestRule = IntegrationTestRule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal class TracingApiTest {
val sessionEndTime = harness.overriddenClock.now()
val session = checkNotNull(envelope)
val allSpans = getSdkInitSpanFromBackgroundActivity() +
checkNotNull(session.data?.spans) +
checkNotNull(session.data.spans) +
harness.overriddenOpenTelemetryModule.spanSink.completedSpans().map(EmbraceSpanData::toNewPayload)

val spansMap = allSpans.associateBy { it.name }
Expand Down Expand Up @@ -238,7 +238,7 @@ internal class TracingApiTest {
private = false
)

val snapshots = checkNotNull(envelope.data?.spanSnapshots).associateBy { it.name }
val snapshots = checkNotNull(envelope.data.spanSnapshots).associateBy { it.name }
val unendingSpanSnapshot = checkNotNull(snapshots["unending-span"])
unendingSpanSnapshot.assertIsTypePerformance()
assertEmbraceSpanData(
Expand Down Expand Up @@ -305,7 +305,7 @@ internal class TracingApiTest {

private fun getSdkInitSpanFromBackgroundActivity(): List<Span> {
val lastSentBackgroundActivity = testRule.harness.getSentBackgroundActivities().last()
val spans = checkNotNull(lastSentBackgroundActivity.data?.spans)
val spans = checkNotNull(lastSentBackgroundActivity.data.spans)
return spans.filter { it.name == "emb-sdk-init" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.robolectric.annotation.Config
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@RunWith(AndroidJUnit4::class)
internal class UnityInternalInterfaceTest {

@Suppress("DEPRECATION")
@Rule
@JvmField
val testRule: IntegrationTestRule = IntegrationTestRule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ internal class EmbraceImpl @JvmOverloads constructor(
private val nativeThreadSampler by embraceImplInject { bootstrapper.nativeModule.nativeThreadSamplerService }
private val nativeThreadSamplerInstaller by embraceImplInject { bootstrapper.nativeModule.nativeThreadSamplerInstaller }

@Suppress("DEPRECATION")
override fun start(context: Context) = start(context, Embrace.AppFramework.NATIVE) { null }

@Suppress("DEPRECATION")
@Deprecated("Use {@link #start(Context)} instead.")
override fun start(context: Context, appFramework: Embrace.AppFramework) =
start(context, appFramework) { null }

@Suppress("DEPRECATION")
@Deprecated("Use {@link #start(Context)} instead. The isDevMode parameter has no effect.")
override fun start(context: Context, isDevMode: Boolean) =
start(context, Embrace.AppFramework.NATIVE) { null }

@Suppress("DEPRECATION")
@Deprecated("Use {@link #start(Context, Embrace.AppFramework)} instead. The isDevMode parameter has no effect.")
override fun start(context: Context, isDevMode: Boolean, appFramework: Embrace.AppFramework) =
start(context, appFramework) { null }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.junit.Test

internal class AppInfoTest {

@Suppress("DEPRECATION")
private val info = AppInfo(
appVersion = "1.0",
appFramework = Embrace.AppFramework.NATIVE.value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.embrace.android.embracesdk

import android.content.Context
import io.embrace.android.embracesdk.Embrace.AppFramework.REACT_NATIVE
import io.embrace.android.embracesdk.capture.crash.CrashService
import io.embrace.android.embracesdk.capture.metadata.HostedSdkVersionInfo
import io.embrace.android.embracesdk.fakes.FakeMetadataService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal class PayloadFactoryBaTest {

// there should be 1 completed span: the session span
checkNotNull(msg)
assertEquals(1, msg.data?.spans?.size)
assertEquals(1, msg.data.spans?.size)
assertEquals(0, spanSink.completedSpans().size)
}

Expand All @@ -130,7 +130,7 @@ internal class PayloadFactoryBaTest {

// there should be 1 completed span: the session span
checkNotNull(msg)
assertEquals(1, msg.data?.spans?.size)
assertEquals(1, msg.data.spans?.size)
assertEquals(0, spanSink.completedSpans().size)
}

Expand All @@ -143,7 +143,7 @@ internal class PayloadFactoryBaTest {

// there should be 1 completed span: the session span
checkNotNull(msg)
assertEquals(1, msg.data?.spans?.size)
assertEquals(1, msg.data.spans?.size)
assertEquals(0, spanSink.completedSpans().size)
}

Expand Down

0 comments on commit 4374d13

Please sign in to comment.