Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
breedx-splk committed May 1, 2024
1 parent 66cb9ad commit 1b3617f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,13 @@ public OpenTelemetryRum build() {
}

private StorageConfiguration createStorageConfiguration() throws IOException {
PreferencesService preferencesService = ServiceManager.get().getService(PreferencesService.class);
CacheStorageService storageService = ServiceManager.get().getService(CacheStorageService.class);
DiskManager diskManager = new DiskManager(storageService, preferencesService, config.getDiskBufferingConfiguration());
PreferencesService preferencesService =
ServiceManager.get().getService(PreferencesService.class);
CacheStorageService storageService =
ServiceManager.get().getService(CacheStorageService.class);
DiskManager diskManager =
new DiskManager(
storageService, preferencesService, config.getDiskBufferingConfiguration());
return StorageConfiguration.builder()
.setMaxFileSize(diskManager.getMaxCacheFileSize())
.setMaxFolderSize(diskManager.getMaxFolderSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.features.persistence

import io.opentelemetry.contrib.disk.buffering.internal.files.TemporaryFileProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.features.persistence

import io.mockk.Called
Expand Down Expand Up @@ -89,9 +90,9 @@ internal class DiskManagerTest {
val maxCacheFileSize = 1024 * 1024 // 1 MB
every { diskBufferingConfiguration.maxCacheSize }.returns(maxCacheSize.toInt())
every { diskBufferingConfiguration.maxCacheFileSize }.returns(maxCacheFileSize)
every { cacheStorageService.ensureCacheSpaceAvailable(maxCacheSize)}.returns(maxCacheSize)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1)}.returns(-1)
every { preferencesService.store(any(), any())} just Runs
every { cacheStorageService.ensureCacheSpaceAvailable(maxCacheSize) }.returns(maxCacheSize)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1) }.returns(-1)
every { preferencesService.store(any(), any()) } just Runs

// Expects the size of a single signal type folder minus the size of a cache file, to use as
// temporary space for reading.
Expand All @@ -103,15 +104,15 @@ internal class DiskManagerTest {

// On a second call, should get the value from the preferences.
clearMocks(cacheStorageService, diskBufferingConfiguration, preferencesService)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1)}.returns(expected)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1) }.returns(expected)
assertThat(diskManager.maxFolderSize).isEqualTo(expected)

verify {
preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1)
}
confirmVerified(preferencesService)
verify { cacheStorageService wasNot Called}
verify { diskBufferingConfiguration wasNot Called}
verify { cacheStorageService wasNot Called }
verify { diskBufferingConfiguration wasNot Called }
}

@Test
Expand All @@ -120,12 +121,12 @@ internal class DiskManagerTest {
val maxCacheFileSize = 1024 * 1024 // 1 MB
every { diskBufferingConfiguration.maxCacheSize }.returns(maxCacheSize.toInt())
every { diskBufferingConfiguration.maxCacheFileSize }.returns(maxCacheFileSize)
every { cacheStorageService.ensureCacheSpaceAvailable(maxCacheSize)}.returns(maxCacheSize)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1)}.returns(-1)
every { cacheStorageService.ensureCacheSpaceAvailable(maxCacheSize) }.returns(maxCacheSize)
every { preferencesService.retrieveInt(MAX_FOLDER_SIZE_KEY, -1) }.returns(-1)
// Expects the size of a single signal type folder minus the size of a cache file, to use as
// temporary space for reading.
assertThat(diskManager.maxFolderSize).isEqualTo(0)
verify(inverse=true) {
verify(inverse = true) {
preferencesService.store(any(), any())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.features.persistence

import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
Expand All @@ -13,6 +13,7 @@ import java.io.File
internal class SimpleTemporaryFileProviderTest {
@TempDir
lateinit var tempDir: File

@Test
fun createUniqueFilesBasedOnCurrentTimeAndPrefix() {
val provider = SimpleTemporaryFileProvider(tempDir)
Expand Down

0 comments on commit 1b3617f

Please sign in to comment.