Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

renaming transport gate method #330

Merged
merged 1 commit into from
Mar 31, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class AndroidTransportGate implements ITransportGate {
}

@Override
public boolean isSendingAllowed() {
public boolean isConnected() {
return isConnected(ConnectivityChecker.isConnected(context, logger));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AndroidTransportGateTest {

@Test
fun `isSendingAllowed is not null`() {
assertNotNull(transportGate.isSendingAllowed)
assertNotNull(transportGate.isConnected)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void run() {
.log(SentryLevel.DEBUG, "Disk flush event fired: %s", event.getEventId());
}

if (transportGate.isSendingAllowed()) {
if (transportGate.isConnected()) {
try {
result = transport.send(event);
if (result.isSuccess()) {
Expand Down Expand Up @@ -317,7 +317,7 @@ public void run() {
return TransportResult.success();
}

if (transportGate.isSendingAllowed()) {
if (transportGate.isConnected()) {
try {
result = transport.send(envelope);
if (result.isSuccess()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
public interface ITransportGate {

/** @return true if it is possible to send events to the Sentry server, false otherwise */
boolean isSendingAllowed();
boolean isConnected();
}
4 changes: 2 additions & 2 deletions sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class SentryClientTest {
SentryClient(sentryOptions, connection)

assertNotNull(sentryOptions.transportGate)
assertTrue(sentryOptions.transportGate!!.isSendingAllowed)
assertTrue(sentryOptions.transportGate!!.isConnected)
}

@Test
Expand Down Expand Up @@ -612,7 +612,7 @@ class SentryClientTest {
}

internal class CustomTransportGate : ITransportGate {
override fun isSendingAllowed(): Boolean = false
override fun isConnected(): Boolean = false
}

internal class CustomCachedApplyScopeDataHint : Cached, ApplyScopeData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AsyncConnectionTest {
fun `successful send discards the event from cache`() {
// given
val ev = mock<SentryEvent>()
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEvent>())).thenReturn(TransportResult.success())

// when
Expand All @@ -75,7 +75,7 @@ class AsyncConnectionTest {
fun `successful send discards the session from cache`() {
// given
val envelope = SentryEnvelope.fromSession(fixture.sentryOptions.serializer, createSession())
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEnvelope>())).thenReturn(TransportResult.success())

// when
Expand All @@ -95,7 +95,7 @@ class AsyncConnectionTest {
fun `stores event in cache if sending is not allowed`() {
// given
val ev = mock<SentryEvent>()
whenever(fixture.transportGate.isSendingAllowed).thenReturn(false)
whenever(fixture.transportGate.isConnected).thenReturn(false)

// when
fixture.getSUT().send(ev)
Expand All @@ -109,7 +109,7 @@ class AsyncConnectionTest {
fun `stores session in cache if sending is not allowed`() {
// given
val envelope = SentryEnvelope.fromSession(fixture.sentryOptions.serializer, createSession())
whenever(fixture.transportGate.isSendingAllowed).thenReturn(false)
whenever(fixture.transportGate.isConnected).thenReturn(false)

// when
fixture.getSUT().send(envelope)
Expand All @@ -123,7 +123,7 @@ class AsyncConnectionTest {
fun `stores event after unsuccessful send`() {
// given
val ev = mock<SentryEvent>()
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEvent>())).thenReturn(TransportResult.error(500))

// when
Expand All @@ -147,7 +147,7 @@ class AsyncConnectionTest {
fun `stores session after unsuccessful send`() {
// given
val envelope = SentryEnvelope.fromSession(fixture.sentryOptions.serializer, createSession())
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEnvelope>())).thenReturn(TransportResult.error(500))

// when
Expand All @@ -171,7 +171,7 @@ class AsyncConnectionTest {
fun `stores event after send failure`() {
// given
val ev = mock<SentryEvent>()
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEvent>())).thenThrow(IOException())

// when
Expand All @@ -191,7 +191,7 @@ class AsyncConnectionTest {
fun `stores session after send failure`() {
// given
val envelope = SentryEnvelope.fromSession(fixture.sentryOptions.serializer, createSession())
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEnvelope>())).thenThrow(IOException())

// when
Expand Down Expand Up @@ -267,7 +267,7 @@ class AsyncConnectionTest {

whenever(fixture.transport.isRetryAfter(eq("event"))).thenReturn(false)
whenever(fixture.transport.isRetryAfter(eq("session"))).thenReturn(true)
whenever(fixture.transportGate.isSendingAllowed).thenReturn(true)
whenever(fixture.transportGate.isConnected).thenReturn(true)
whenever(fixture.transport.send(any<SentryEnvelope>())).thenReturn(TransportResult.success())
fixture.getSUT().send(envelope)
verify(fixture.transport).send(check<SentryEnvelope> {
Expand Down