From dc9d08522faef2b82d70214dd8384a9640ab7ec4 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Mon, 19 Apr 2021 20:10:13 +0200 Subject: [PATCH] refactor: Refactor data scratch-orientation --- .../ftl/adapter/GoogleOrientationFetch.kt | 16 +++++++ .../ftl/adapter/google/OrientationsAdapter.kt | 14 ++++++ .../src/main/kotlin/ftl/api/Orientation.kt | 18 +++++++ .../ftl/args/PrepareAndroidCommonConfig.kt | 2 +- .../kotlin/ftl/args/ValidateAndroidArgs.kt | 12 ++--- .../google}/AndroidCatalog.kt | 13 ++--- .../ftl/domain/DescribeAndroidLocales.kt | 2 +- .../ftl/domain/DescribeAndroidModels.kt | 2 +- .../domain/DescribeAndroidTestEnvironment.kt | 7 ++- .../ftl/domain/DescribeAndroidVersions.kt | 2 +- .../ftl/domain/DescribeIosTestEnvironment.kt | 6 ++- .../kotlin/ftl/domain/ListAndroidLocales.kt | 2 +- .../kotlin/ftl/domain/ListAndroidModels.kt | 2 +- .../ftl/domain/ListAndroidOrientations.kt | 11 ++++- .../kotlin/ftl/domain/ListAndroidVersions.kt | 2 +- .../kotlin/ftl/domain/ListIosOrientations.kt | 12 ++++- .../NetworkConfigurationCatalog.kt | 4 +- .../environment/android/ListAndroidDevices.kt | 2 +- .../android/ListAndroidSofwareVersions.kt | 2 +- .../common/ListNetworkConfiguration.kt | 2 +- .../environment/common/ListOrientations.kt | 4 +- .../src/main/kotlin/ftl/ios/IosCatalog.kt | 6 +-- .../ftl/reports/api/PerformanceMetrics.kt | 2 +- .../ftl/reports/outcome/BillableMinutes.kt | 4 +- .../adapter/google/OrientationsAdapterTest.kt | 47 +++++++++++++++++++ .../kotlin/ftl/android/AndroidCatalogTest.kt | 13 ++++- .../AndroidLocalesDescribeCommandTest.kt | 2 +- .../locales/AndroidLocalesListCommandTest.kt | 2 +- .../AndroidOrientationCommandListTest.kt | 4 +- .../AndroidVersionsDescribeCommandTest.kt | 2 +- .../IosOrientationCommandListTest.kt | 2 +- .../ftl/reports/api/PerformanceMetricsTest.kt | 2 +- .../reports/outcome/BillableMinutesTest.kt | 2 +- 33 files changed, 177 insertions(+), 48 deletions(-) create mode 100644 test_runner/src/main/kotlin/ftl/adapter/GoogleOrientationFetch.kt create mode 100644 test_runner/src/main/kotlin/ftl/adapter/google/OrientationsAdapter.kt create mode 100644 test_runner/src/main/kotlin/ftl/api/Orientation.kt rename test_runner/src/main/kotlin/ftl/{android => client/google}/AndroidCatalog.kt (91%) create mode 100644 test_runner/src/test/kotlin/ftl/adapter/google/OrientationsAdapterTest.kt diff --git a/test_runner/src/main/kotlin/ftl/adapter/GoogleOrientationFetch.kt b/test_runner/src/main/kotlin/ftl/adapter/GoogleOrientationFetch.kt new file mode 100644 index 0000000000..52193c23d8 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/adapter/GoogleOrientationFetch.kt @@ -0,0 +1,16 @@ +package ftl.adapter + +import ftl.adapter.google.toApiModel +import ftl.api.Orientation +import ftl.api.Platform +import ftl.client.google.AndroidCatalog +import ftl.ios.IosCatalog + +object GoogleOrientationFetch : + Orientation.Fetch, + (String, Platform) -> List by { projectId, platform -> + when (platform) { + Platform.ANDROID -> AndroidCatalog.supportedOrientations(projectId).toApiModel() + Platform.IOS -> IosCatalog.supportedOrientations(projectId).toApiModel() + } + } diff --git a/test_runner/src/main/kotlin/ftl/adapter/google/OrientationsAdapter.kt b/test_runner/src/main/kotlin/ftl/adapter/google/OrientationsAdapter.kt new file mode 100644 index 0000000000..59fa68dfca --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/adapter/google/OrientationsAdapter.kt @@ -0,0 +1,14 @@ +package ftl.adapter.google + +import ftl.api.Orientation +import com.google.testing.model.Orientation as GoogleApiOrientation + +internal fun List.toApiModel(): List = map { googleApiOrientation -> + Orientation( + id = googleApiOrientation.id ?: UNABLE, + name = googleApiOrientation.name ?: UNABLE, + tags = googleApiOrientation.tags ?: emptyList() + ) +} + +private const val UNABLE = "[Unable to fetch]" diff --git a/test_runner/src/main/kotlin/ftl/api/Orientation.kt b/test_runner/src/main/kotlin/ftl/api/Orientation.kt new file mode 100644 index 0000000000..27725ffb0f --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/api/Orientation.kt @@ -0,0 +1,18 @@ +package ftl.api + +import ftl.adapter.GoogleOrientationFetch + +val fetchOrientation: Orientation.Fetch get() = GoogleOrientationFetch + +data class Orientation( + val id: String, + val name: String, + val tags: List, +) { + interface Fetch : (String, Platform) -> List +} + +enum class Platform { + ANDROID, + IOS +} diff --git a/test_runner/src/main/kotlin/ftl/args/PrepareAndroidCommonConfig.kt b/test_runner/src/main/kotlin/ftl/args/PrepareAndroidCommonConfig.kt index f218e40bb6..e5d2288b14 100644 --- a/test_runner/src/main/kotlin/ftl/args/PrepareAndroidCommonConfig.kt +++ b/test_runner/src/main/kotlin/ftl/args/PrepareAndroidCommonConfig.kt @@ -1,6 +1,6 @@ package ftl.args -import ftl.android.AndroidCatalog +import ftl.client.google.AndroidCatalog import ftl.config.AndroidConfig import ftl.config.Device import ftl.config.containsPhysicalDevices diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt index 730a13e7a6..0d31e21dbf 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt @@ -1,13 +1,13 @@ package ftl.args import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.android.AndroidCatalog.getSupportedVersionId -import ftl.android.IncompatibleModelVersion -import ftl.android.SupportedDeviceConfig -import ftl.android.UnsupportedModelId -import ftl.android.UnsupportedVersionId import ftl.args.yml.Type +import ftl.client.google.AndroidCatalog +import ftl.client.google.AndroidCatalog.getSupportedVersionId +import ftl.client.google.IncompatibleModelVersion +import ftl.client.google.SupportedDeviceConfig +import ftl.client.google.UnsupportedModelId +import ftl.client.google.UnsupportedVersionId import ftl.config.containsPhysicalDevices import ftl.config.containsVirtualDevices import ftl.run.exception.FlankConfigurationError diff --git a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt b/test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt similarity index 91% rename from test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt rename to test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt index 9e13df92be..9ca3481e37 100644 --- a/test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt @@ -1,13 +1,14 @@ -package ftl.android +package ftl.client.google import com.google.testing.model.AndroidDevice import com.google.testing.model.AndroidDeviceCatalog +import com.google.testing.model.Orientation import flank.common.logLn import ftl.config.Device -import ftl.environment.android.asPrintableTable import ftl.environment.android.getDescription +import ftl.environment.android.toCliTable import ftl.environment.asPrintableTable -import ftl.environment.common.asPrintableTable +import ftl.environment.common.toCliTable import ftl.environment.getLocaleDescription import ftl.gc.GcTesting import ftl.http.executeWithRetry @@ -29,7 +30,7 @@ object AndroidCatalog { .androidDeviceCatalog } - fun devicesCatalogAsTable(projectId: String) = getModels(projectId).asPrintableTable() + fun devicesCatalogAsTable(projectId: String) = getModels(projectId).toCliTable() fun describeModel(projectId: String, modelId: String) = getModels(projectId).getDescription(modelId) @@ -38,13 +39,13 @@ object AndroidCatalog { fun Device.getSupportedVersionId(projectId: String): List = getModels(projectId).find { it.id == model }?.supportedVersionIds ?: emptyList() - fun supportedVersionsAsTable(projectId: String) = getVersionsList(projectId).asPrintableTable() + fun supportedVersionsAsTable(projectId: String) = getVersionsList(projectId).toCliTable() fun describeSoftwareVersion(projectId: String, versionId: String) = getVersionsList(projectId).getDescription(versionId) private fun getVersionsList(projectId: String) = deviceCatalog(projectId).versions - fun supportedOrientationsAsTable(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable() + fun supportedOrientations(projectId: String): List = deviceCatalog(projectId).runtimeConfiguration.orientations fun localesAsTable(projectId: String) = getLocales(projectId).asPrintableTable() diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt index 265bc7b488..a0917348a2 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.log -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import ftl.run.exception.FlankConfigurationError import java.nio.file.Paths diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt index ddfbb04a06..ea4ac86976 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import ftl.run.exception.FlankConfigurationError import java.nio.file.Paths diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt index 9effcb100a..ca2f950397 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt @@ -2,7 +2,11 @@ package ftl.domain import flank.common.logLn import ftl.android.AndroidCatalog +import ftl.api.Platform +import ftl.api.fetchOrientation import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog +import ftl.environment.common.toCliTable import ftl.environment.ipBlocksListAsTable import ftl.environment.networkConfigurationAsTable import ftl.environment.providedSoftwareAsTable @@ -19,6 +23,7 @@ fun DescribeAndroidTestEnvironment.invoke() { logLn(AndroidCatalog.localesAsTable(projectId)) logLn(providedSoftwareAsTable()) logLn(networkConfigurationAsTable()) - logLn(AndroidCatalog.supportedOrientationsAsTable(projectId)) + // TODO move toCliTable() to presentation layer during refactor of presentation after #1728 + logLn(fetchOrientation(projectId, Platform.ANDROID).toCliTable()) logLn(ipBlocksListAsTable()) } diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt index 3324c73268..6ab327d931 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import ftl.run.exception.FlankConfigurationError import java.nio.file.Paths diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt index c6abf64a0d..ebcf371bb8 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt @@ -1,7 +1,10 @@ package ftl.domain import flank.common.logLn +import ftl.api.Platform +import ftl.api.fetchOrientation import ftl.args.IosArgs +import ftl.environment.common.toCliTable import ftl.environment.ipBlocksListAsTable import ftl.environment.networkConfigurationAsTable import ftl.environment.providedSoftwareAsTable @@ -19,6 +22,7 @@ operator fun DescribeIosTestEnvironment.invoke() { logLn(IosCatalog.localesAsTable(projectId)) logLn(providedSoftwareAsTable()) logLn(networkConfigurationAsTable()) - logLn(IosCatalog.supportedOrientationsAsTable(projectId)) + // TODO move toCliTable() and printing presentation layer during refactor of presentation after #1728 + logLn(fetchOrientation(projectId, Platform.IOS).toCliTable()) logLn(ipBlocksListAsTable()) } diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt index 7dce3479ea..f61ed9fc82 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import java.nio.file.Paths interface ListAndroidLocales { diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt index b3a1f1fa13..f008c9796f 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import java.nio.file.Paths interface ListAndroidModels { diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt index 11e83bc167..82036e4bfe 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt @@ -1,8 +1,10 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog +import ftl.api.Platform +import ftl.api.fetchOrientation import ftl.args.AndroidArgs +import ftl.environment.common.toCliTable import java.nio.file.Paths interface ListAndroidOrientations { @@ -10,5 +12,10 @@ interface ListAndroidOrientations { } operator fun ListAndroidOrientations.invoke() { - logLn(AndroidCatalog.supportedOrientationsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) + logLn( + fetchOrientation( + AndroidArgs.loadOrDefault(Paths.get(configPath)).project, + Platform.ANDROID + ).toCliTable() + ) } diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt index 0bfb3219c0..47f710431c 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt @@ -1,8 +1,8 @@ package ftl.domain import flank.common.logLn -import ftl.android.AndroidCatalog import ftl.args.AndroidArgs +import ftl.client.google.AndroidCatalog import java.nio.file.Paths interface ListAndroidVersions { diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt b/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt index bb657594da..2fcb2656d8 100644 --- a/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt +++ b/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt @@ -1,8 +1,10 @@ package ftl.domain import flank.common.logLn +import ftl.api.Platform +import ftl.api.fetchOrientation import ftl.args.IosArgs -import ftl.ios.IosCatalog +import ftl.environment.common.toCliTable import java.nio.file.Paths interface ListIosOrientations { @@ -10,5 +12,11 @@ interface ListIosOrientations { } operator fun ListIosOrientations.invoke() { - logLn(IosCatalog.supportedOrientationsAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) + // TODO move toCliTable() to presentation layer during refactor of presentation after #1728 + logLn( + fetchOrientation( + IosArgs.loadOrDefault(Paths.get(configPath)).project, + Platform.IOS + ).toCliTable() + ) } diff --git a/test_runner/src/main/kotlin/ftl/environment/NetworkConfigurationCatalog.kt b/test_runner/src/main/kotlin/ftl/environment/NetworkConfigurationCatalog.kt index 049b37729f..42adcda172 100644 --- a/test_runner/src/main/kotlin/ftl/environment/NetworkConfigurationCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/environment/NetworkConfigurationCatalog.kt @@ -1,10 +1,10 @@ package ftl.environment -import ftl.environment.common.asPrintableTable +import ftl.environment.common.toCliTable import ftl.gc.GcTesting import ftl.http.executeWithRetry -fun networkConfigurationAsTable() = getNetworkConfiguration().asPrintableTable() +fun networkConfigurationAsTable() = getNetworkConfiguration().toCliTable() fun getNetworkConfiguration() = GcTesting.get.testEnvironmentCatalog() .get("NETWORK_CONFIGURATION") diff --git a/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidDevices.kt b/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidDevices.kt index c0daf40110..fc4eefc0b9 100644 --- a/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidDevices.kt +++ b/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidDevices.kt @@ -20,7 +20,7 @@ import ftl.util.SystemOutColor import ftl.util.applyColorsUsing import ftl.util.buildTable -fun List.asPrintableTable() = createTestEnvironmentInfo().createAndroidDevicesTable() +fun List.toCliTable() = createTestEnvironmentInfo().createAndroidDevicesTable() private fun List.createTestEnvironmentInfo() = fold(mutableMapOf>()) { devicesInfo, androidDevice -> diff --git a/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidSofwareVersions.kt b/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidSofwareVersions.kt index 13b472cab5..bef0896a9d 100644 --- a/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidSofwareVersions.kt +++ b/test_runner/src/main/kotlin/ftl/environment/android/ListAndroidSofwareVersions.kt @@ -13,7 +13,7 @@ import ftl.reports.api.twoDigitString import ftl.util.applyColorsUsing import ftl.util.buildTable -fun List.asPrintableTable() = createTestEnvironmentInfo().createAndroidSoftwareVersionsTable() +fun List.toCliTable() = createTestEnvironmentInfo().createAndroidSoftwareVersionsTable() private fun List.createTestEnvironmentInfo() = fold(mutableMapOf>()) { softwareInfo, softwareVersion -> diff --git a/test_runner/src/main/kotlin/ftl/environment/common/ListNetworkConfiguration.kt b/test_runner/src/main/kotlin/ftl/environment/common/ListNetworkConfiguration.kt index e8e4c25640..5d3fb61a15 100644 --- a/test_runner/src/main/kotlin/ftl/environment/common/ListNetworkConfiguration.kt +++ b/test_runner/src/main/kotlin/ftl/environment/common/ListNetworkConfiguration.kt @@ -7,7 +7,7 @@ import ftl.environment.getOrCreateList import ftl.util.TableStyle import ftl.util.buildTable -fun List.asPrintableTable() = createConfigurationDetails().createConfigurationsTable() +fun List.toCliTable() = createConfigurationDetails().createConfigurationsTable() private fun List.createConfigurationDetails() = fold(mutableMapOf>()) { networkInfo, networkConfiguration -> networkInfo.apply { diff --git a/test_runner/src/main/kotlin/ftl/environment/common/ListOrientations.kt b/test_runner/src/main/kotlin/ftl/environment/common/ListOrientations.kt index eefe5f9001..10d4c67b55 100644 --- a/test_runner/src/main/kotlin/ftl/environment/common/ListOrientations.kt +++ b/test_runner/src/main/kotlin/ftl/environment/common/ListOrientations.kt @@ -1,6 +1,6 @@ package ftl.environment.common -import com.google.testing.model.Orientation +import ftl.api.Orientation import ftl.environment.TestEnvironmentInfo import ftl.environment.createTableColumnFor import ftl.environment.getOrCreateList @@ -8,7 +8,7 @@ import ftl.environment.tagToSystemOutColorMapper import ftl.util.applyColorsUsing import ftl.util.buildTable -fun List.asPrintableTable() = createOrientationsDetails().createOrientationsTable() +fun List.toCliTable() = createOrientationsDetails().createOrientationsTable() private fun List.createOrientationsDetails() = fold(mutableMapOf>()) { orientationInfo, orientation -> orientationInfo.apply { diff --git a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt index eb8421ab7d..f38fb4efd1 100644 --- a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt @@ -1,9 +1,9 @@ package ftl.ios import com.google.testing.model.IosDeviceCatalog +import com.google.testing.model.Orientation import ftl.config.Device import ftl.environment.asPrintableTable -import ftl.environment.common.asPrintableTable import ftl.environment.getLocaleDescription import ftl.environment.ios.asPrintableTable import ftl.environment.ios.getDescription @@ -38,8 +38,8 @@ object IosCatalog { private fun getLocales(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.locales - fun supportedOrientationsAsTable(projectId: String) = - iosDeviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable() + fun supportedOrientations(projectId: String): List = + iosDeviceCatalog(projectId).runtimeConfiguration.orientations fun supportedXcode(version: String, projectId: String) = xcodeVersions(projectId).contains(version) diff --git a/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt b/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt index 74a0558498..c6d469d617 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt @@ -2,8 +2,8 @@ package ftl.reports.api import com.google.api.services.toolresults.model.PerfMetricsSummary import com.google.testing.model.TestExecution -import ftl.android.AndroidCatalog import ftl.args.IArgs +import ftl.client.google.AndroidCatalog import ftl.gc.GcStorage import ftl.gc.GcToolResults import kotlinx.coroutines.Dispatchers diff --git a/test_runner/src/main/kotlin/ftl/reports/outcome/BillableMinutes.kt b/test_runner/src/main/kotlin/ftl/reports/outcome/BillableMinutes.kt index 6946d04874..d811f34828 100644 --- a/test_runner/src/main/kotlin/ftl/reports/outcome/BillableMinutes.kt +++ b/test_runner/src/main/kotlin/ftl/reports/outcome/BillableMinutes.kt @@ -1,8 +1,8 @@ package ftl.reports.outcome import com.google.api.services.toolresults.model.Step -import ftl.android.AndroidCatalog -import ftl.android.DeviceType +import ftl.client.google.AndroidCatalog +import ftl.client.google.DeviceType import ftl.environment.orUnknown import ftl.util.billableMinutes import kotlin.math.min diff --git a/test_runner/src/test/kotlin/ftl/adapter/google/OrientationsAdapterTest.kt b/test_runner/src/test/kotlin/ftl/adapter/google/OrientationsAdapterTest.kt new file mode 100644 index 0000000000..5b248a40b6 --- /dev/null +++ b/test_runner/src/test/kotlin/ftl/adapter/google/OrientationsAdapterTest.kt @@ -0,0 +1,47 @@ +package ftl.adapter.google + +import com.google.common.truth.Truth.assertThat +import com.google.testing.model.Date +import com.google.testing.model.DeviceIpBlock +import ftl.api.IpBlock +import org.junit.Test + +class OrientationsAdapterTest { + + @Test + fun `Should properly map ip blocks`() { + // given + val testItem = DeviceIpBlock() + .setBlock("block") + .setForm("form") + .setAddedDate(Date().setDay(1).setMonth(1).setYear(2000)) + val expected = IpBlock( + "block", + "form", + "2000-01-01" + ) + + // when + val actual = listOf(testItem).toApiModel() + + // then + assertThat(actual).isEqualTo(listOf(expected)) + } + + @Test + fun `Should properly map ip blocks with missing fields`() { + // given + val testItem = DeviceIpBlock() + val expected = IpBlock( + "[Unable to fetch]", + "[Unable to fetch]", + "[Unable to fetch]" + ) + + // when + val actual = listOf(testItem).toApiModel() + + // then + assertThat(actual).isEqualTo(listOf(expected)) + } +} diff --git a/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt b/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt index 0eeedce4cc..7a38560c8e 100644 --- a/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt +++ b/test_runner/src/test/kotlin/ftl/android/AndroidCatalogTest.kt @@ -2,6 +2,11 @@ package ftl.android import com.google.common.truth.Truth.assertThat import com.google.testing.model.AndroidDevice +import ftl.client.google.AndroidCatalog +import ftl.client.google.IncompatibleModelVersion +import ftl.client.google.SupportedDeviceConfig +import ftl.client.google.UnsupportedModelId +import ftl.client.google.UnsupportedVersionId import ftl.test.util.FlankTestRunner import io.mockk.every import io.mockk.mockk @@ -28,8 +33,12 @@ class AndroidCatalogTest { @Test fun supportedDeviceConfig() { assertThat(AndroidCatalog.supportedDeviceConfig("ios", "23", projectId)).isEqualTo(UnsupportedModelId) - assertThat(AndroidCatalog.supportedDeviceConfig("NexusLowRes", "twenty-three", projectId)).isEqualTo(UnsupportedVersionId) - assertThat(AndroidCatalog.supportedDeviceConfig("NexusLowRes", "21", projectId)).isEqualTo(IncompatibleModelVersion) + assertThat(AndroidCatalog.supportedDeviceConfig("NexusLowRes", "twenty-three", projectId)).isEqualTo( + UnsupportedVersionId + ) + assertThat(AndroidCatalog.supportedDeviceConfig("NexusLowRes", "21", projectId)).isEqualTo( + IncompatibleModelVersion + ) assertThat(AndroidCatalog.supportedDeviceConfig("NexusLowRes", "23", projectId)).isEqualTo(SupportedDeviceConfig) assertThat(AndroidCatalog.supportedDeviceConfig("brokenModel", "23", projectId)).isEqualTo(UnsupportedModelId) assertThat(AndroidCatalog.supportedDeviceConfig("does not exist", "23", projectId)).isEqualTo(UnsupportedModelId) diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesDescribeCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesDescribeCommandTest.kt index f8ddf28360..f3b87caff8 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesDescribeCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesDescribeCommandTest.kt @@ -1,6 +1,6 @@ package ftl.cli.firebase.test.android.locales -import ftl.android.AndroidCatalog +import ftl.client.google.AndroidCatalog import ftl.presentation.cli.firebase.test.android.locales.AndroidLocalesDescribeCommand import ftl.run.exception.FlankConfigurationError import ftl.test.util.TestHelper.getThrowable diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesListCommandTest.kt index 898a214a5e..87a223c37a 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesListCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/locales/AndroidLocalesListCommandTest.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase.test.android.locales import com.google.common.truth.Truth.assertThat -import ftl.android.AndroidCatalog +import ftl.client.google.AndroidCatalog import ftl.presentation.cli.firebase.test.android.locales.AndroidLocalesListCommand import io.mockk.mockkObject import io.mockk.verify diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationCommandListTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationCommandListTest.kt index b5becb1f41..9078fb3427 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationCommandListTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationCommandListTest.kt @@ -1,6 +1,6 @@ package ftl.cli.firebase.test.android.orientations -import ftl.android.AndroidCatalog +import ftl.client.google.AndroidCatalog import ftl.presentation.cli.firebase.test.android.orientations.AndroidOrientationsListCommand import ftl.presentation.cli.firebase.test.android.versions.AndroidVersionsListCommand import io.mockk.mockkObject @@ -14,7 +14,7 @@ class AndroidOrientationCommandListTest { fun `should execute AndroidCatalog supportedOrientationsAsTable when run AndroidOrientationsListCommand`() { mockkObject(AndroidCatalog) { CommandLine(AndroidOrientationsListCommand()).execute() - verify { AndroidCatalog.supportedOrientationsAsTable(any()) } + verify { AndroidCatalog.supportedOrientations(any()) } } } diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommandTest.kt index 513d68db61..ba927a8be1 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommandTest.kt @@ -1,6 +1,6 @@ package ftl.cli.firebase.test.android.versions -import ftl.android.AndroidCatalog +import ftl.client.google.AndroidCatalog import ftl.presentation.cli.firebase.test.android.versions.AndroidVersionsDescribeCommand import ftl.presentation.cli.firebase.test.ios.versions.IosVersionsDescribeCommand import ftl.run.exception.FlankConfigurationError diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationCommandListTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationCommandListTest.kt index fa7b62da6f..3c5d8bc311 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationCommandListTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationCommandListTest.kt @@ -13,7 +13,7 @@ class IosOrientationCommandListTest { fun `should execute IosCatalog supportedOrientationsAsTable when run IosOrientationsListCommand`() { mockkObject(IosCatalog) { CommandLine(IosOrientationsListCommand()).execute() - verify { IosCatalog.supportedOrientationsAsTable(any()) } + verify { IosCatalog.supportedOrientations(any()) } } } diff --git a/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt b/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt index db25448b02..82f8ba5895 100644 --- a/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt @@ -4,8 +4,8 @@ import com.google.common.truth.Truth.assertThat import com.google.testing.model.AndroidDevice import com.google.testing.model.TestExecution import com.google.testing.model.ToolResultsStep -import ftl.android.AndroidCatalog import ftl.args.IArgs +import ftl.client.google.AndroidCatalog import ftl.gc.GcStorage import ftl.gc.GcToolResults import ftl.test.util.FlankTestRunner diff --git a/test_runner/src/test/kotlin/ftl/reports/outcome/BillableMinutesTest.kt b/test_runner/src/test/kotlin/ftl/reports/outcome/BillableMinutesTest.kt index 7f851a9aa6..f2a5cd3016 100644 --- a/test_runner/src/test/kotlin/ftl/reports/outcome/BillableMinutesTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/outcome/BillableMinutesTest.kt @@ -2,7 +2,7 @@ package ftl.reports.outcome import com.google.api.services.toolresults.model.Step import com.google.testing.model.AndroidModel -import ftl.android.DeviceType +import ftl.client.google.DeviceType import ftl.gc.GcTesting import ftl.http.executeWithRetry import io.mockk.every