use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project GreenHouse by utsanjan.
the class DaggerTransportRuntimeComponent method initialize.
private void initialize(Context setApplicationContextParam) {
this.executorProvider = DoubleCheck.provider(ExecutionModule_ExecutorFactory.create());
Factory create = InstanceFactory.create(setApplicationContextParam);
this.setApplicationContextProvider = create;
CreationContextFactory_Factory create2 = CreationContextFactory_Factory.create(create, TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create());
this.creationContextFactoryProvider = create2;
this.metadataBackendRegistryProvider = DoubleCheck.provider(MetadataBackendRegistry_Factory.create(this.setApplicationContextProvider, create2));
this.schemaManagerProvider = SchemaManager_Factory.create(this.setApplicationContextProvider, EventStoreModule_DbNameFactory.create(), EventStoreModule_SchemaVersionFactory.create());
this.sQLiteEventStoreProvider = DoubleCheck.provider(SQLiteEventStore_Factory.create(TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create(), EventStoreModule_StoreConfigFactory.create(), this.schemaManagerProvider));
SchedulingConfigModule_ConfigFactory create3 = SchedulingConfigModule_ConfigFactory.create(TimeModule_EventClockFactory.create());
this.configProvider = create3;
SchedulingModule_WorkSchedulerFactory create4 = SchedulingModule_WorkSchedulerFactory.create(this.setApplicationContextProvider, this.sQLiteEventStoreProvider, create3, TimeModule_UptimeClockFactory.create());
this.workSchedulerProvider = create4;
Provider<Executor> provider = this.executorProvider;
Provider provider2 = this.metadataBackendRegistryProvider;
Provider<SQLiteEventStore> provider3 = this.sQLiteEventStoreProvider;
this.defaultSchedulerProvider = DefaultScheduler_Factory.create(provider, provider2, create4, provider3, provider3);
Provider<Context> provider4 = this.setApplicationContextProvider;
Provider provider5 = this.metadataBackendRegistryProvider;
Provider<SQLiteEventStore> provider6 = this.sQLiteEventStoreProvider;
this.uploaderProvider = Uploader_Factory.create(provider4, provider5, provider6, this.workSchedulerProvider, this.executorProvider, provider6, TimeModule_EventClockFactory.create());
Provider<Executor> provider7 = this.executorProvider;
Provider<SQLiteEventStore> provider8 = this.sQLiteEventStoreProvider;
this.workInitializerProvider = WorkInitializer_Factory.create(provider7, provider8, this.workSchedulerProvider, provider8);
this.transportRuntimeProvider = DoubleCheck.provider(TransportRuntime_Factory.create(TimeModule_EventClockFactory.create(), TimeModule_UptimeClockFactory.create(), this.defaultSchedulerProvider, this.uploaderProvider, this.workInitializerProvider));
}
use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.
the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndSuccessfulUpload_shouldResetCounters.
@Test
public void uploader_withPendingClientMetricsAndSuccessfulUpload_shouldResetCounters() {
TransportRuntime runtime = TransportRuntime.getInstance();
SQLiteEventStore store = component.getEventStore();
String anotherTransport = "anotherTransport";
store.recordLogEventDropped(20, LogEventDropped.Reason.CACHE_FULL, testTransport);
store.recordLogEventDropped(1, LogEventDropped.Reason.MAX_RETRIES_REACHED, testTransport);
store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(2);
String mockBackendName = generateBackendName();
byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
when(mockBackend.send(any())).thenReturn(BackendResponse.ok(1));
Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
EventInternal metricsEvent = component.getUploader().createMetricsEvent(mockBackend);
transport.send(Event.ofTelemetry("TelemetryData"));
verify(mockBackend, times(1)).send(eq(BackendRequest.builder().setEvents(Arrays.asList(expectedEvent, metricsEvent)).setExtras(mockExtras).build()));
verify(spyScheduler, times(0)).schedule(any(), eq(2));
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).isEmpty();
}
use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.
the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndInvalidPayload_shouldNotResetCounters.
@Test
public void uploader_withPendingClientMetricsAndInvalidPayload_shouldNotResetCounters() {
TransportRuntime runtime = TransportRuntime.getInstance();
SQLiteEventStore store = component.getEventStore();
String anotherTransport = "anotherTransport";
store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
String mockBackendName = generateBackendName();
byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
when(mockBackend.send(any())).thenReturn(BackendResponse.invalidPayload());
Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
EventInternal metricsEvent = component.getUploader().createMetricsEvent(mockBackend);
transport.send(Event.ofTelemetry("TelemetryData"));
verify(mockBackend, times(1)).send(eq(BackendRequest.builder().setEvents(Arrays.asList(expectedEvent, metricsEvent)).setExtras(mockExtras).build()));
verify(spyScheduler, times(0)).schedule(any(), eq(2));
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(2);
}
use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.
the class UploaderIntegrationTest method uploader_withPendingClientMetricsAndSuccessfulUploadButNotLegacyTarget_shouldNotResetCounters.
@Test
public void uploader_withPendingClientMetricsAndSuccessfulUploadButNotLegacyTarget_shouldNotResetCounters() {
TransportRuntime runtime = TransportRuntime.getInstance();
SQLiteEventStore store = component.getEventStore();
String anotherTransport = "anotherTransport";
store.recordLogEventDropped(1, LogEventDropped.Reason.INVALID_PAYLOD, anotherTransport);
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
String mockBackendName = generateBackendName();
when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
when(mockBackend.send(any())).thenReturn(BackendResponse.ok(1));
Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, null)).getTransport(testTransport, String.class, String::getBytes);
EventInternal expectedEvent = EventInternal.builder().setEventMillis(3).setUptimeMillis(1).setTransportName(testTransport).setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, "TelemetryData".getBytes(Charset.defaultCharset()))).build();
transport.send(Event.ofTelemetry("TelemetryData"));
verify(mockBackend, times(1)).send(eq(BackendRequest.create(Collections.singletonList(expectedEvent))));
verify(spyScheduler, times(0)).schedule(any(), eq(2));
assertThat(store.loadClientMetrics().getLogSourceMetricsList()).hasSize(1);
}
use of com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore in project firebase-android-sdk by firebase.
the class UploaderIntegrationTest method uploader_invalidPayload_shouldNotReschedule.
@Test
public void uploader_invalidPayload_shouldNotReschedule() {
TransportRuntime runtime = TransportRuntime.getInstance();
SQLiteEventStore store = component.getEventStore();
String mockBackendName = generateBackendName();
byte[] mockExtras = "extras".getBytes(Charset.defaultCharset());
when(mockRegistry.get(mockBackendName)).thenReturn(mockBackend);
when(mockBackend.send(any())).thenReturn(BackendResponse.invalidPayload());
Transport<String> transport = runtime.newFactory(new TestDestination(mockBackendName, mockExtras)).getTransport(testTransport, String.class, String::getBytes);
transport.send(Event.ofTelemetry("TelemetryData"));
verify(spyScheduler, times(0)).schedule(any(), eq(2));
List<LogSourceMetrics> logSourceMetrics = store.loadClientMetrics().getLogSourceMetricsList();
assertThat(logSourceMetrics).hasSize(1);
LogSourceMetrics metrics = logSourceMetrics.get(0);
List<LogEventDropped> logEventDroppedList = metrics.getLogEventDroppedList();
assertThat(logEventDroppedList).hasSize(1);
LogEventDropped logEventDropped = logEventDroppedList.get(0);
assertThat(logEventDropped.getEventsDroppedCount()).isEqualTo(1);
assertThat(logEventDropped.getReason()).isEqualTo(LogEventDropped.Reason.INVALID_PAYLOD);
}
Aggregations