Skip to content

Commit

Permalink
fixed notes after self review #4
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Jul 28, 2022
1 parent 8915a64 commit bca9afe
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TestSuitesSourceService(
) = testSuitesSourceRepository.save(
TestSuitesSource(
organization = organization,
name = TestSuitesSourceDto.defaultTestSuitesSourceName(git.url, branch, testRootPath),
name = defaultTestSuitesSourceName(git.url, branch, testRootPath),
description = "auto created test suites source by git coordinates",
git = git,
branch = branch,
Expand All @@ -112,5 +112,21 @@ class TestSuitesSourceService(

// FIXME: a hardcoded value of url for standard test suites
private const val STANDARD_TEST_SUITE_URL = "https://github.com/saveourtool/save-cli"

/**
* @return default name fot [com.saveourtool.save.entities.TestSuitesSource]
*/
private fun defaultTestSuitesSourceName(
url: String,
branch: String,
subDirectory: String
): String = buildString {
append(url)
append("/tree/")
append(branch)
if (subDirectory.isNotBlank()) {
append("/$subDirectory")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ sealed class ExecutionRequestBase {
*/
abstract val executionId: Long?

/**
* null in [ExecutionRequest]
*/
abstract val execCmd: String?

/**
* null in [ExecutionRequest]
*/
abstract val batchSizeForAnalyzer: String?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.saveourtool.save.entities.Organization
import kotlinx.serialization.Serializable

/**
* @param organization
* @param organizationName
* @param name
* @param description
* @param gitDto
Expand All @@ -14,28 +14,10 @@ import kotlinx.serialization.Serializable
*/
@Serializable
data class TestSuitesSourceDto(
val organization: Organization,
val organizationName: String,
val name: String,
val description: String?,
val gitDto: GitDto,
val branch: String,
val testRootPath: String,
) {
companion object {
/**
* @return default name fot [com.saveourtool.save.entities.TestSuitesSource]
*/
fun defaultTestSuitesSourceName(
url: String,
branch: String,
subDirectory: String
): String = buildString {
append(url)
append("/tree/")
append(branch)
if (subDirectory.isNotBlank()) {
append("/$subDirectory")
}
}
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class TestSuitesSourceSnapshotKey(
* @param creationTimeInMills
*/
constructor(testSuitesSourceDto: TestSuitesSourceDto, version: String, creationTimeInMills: Long) : this(
testSuitesSourceDto.organization.name,
testSuitesSourceDto.organizationName,
testSuitesSourceDto.name,
version,
creationTimeInMills,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestSuitesSource(
* @return entity as dto [TestSuitesSourceDto]
*/
fun toDto(): TestSuitesSourceDto = TestSuitesSourceDto(
organization = organization,
organizationName = organization.name,
name = name,
description = description,
gitDto = git.toDto(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PreprocessorToBackendBridge(
content: Flux<ByteBuffer>
): Mono<Unit> = webClientBackend.post()
.uri("/test-suites-source/{organizationName}/{testSuitesSourceName}/upload-snapshot?version={version}&creationTime={creationTime}",
testSuitesSource.organization.name, testSuitesSource.name,
testSuitesSource.organizationName, testSuitesSource.name,
version, creationTime.toEpochMilli())
.contentType(MediaType.MULTIPART_FORM_DATA)
.bodyValue(content)
Expand Down Expand Up @@ -75,10 +75,16 @@ class PreprocessorToBackendBridge(
fun doesTestSuitesSourceContainVersion(testSuitesSource: TestSuitesSourceDto, version: String): Mono<Boolean> =
webClientBackend.get()
.uri("/test-suites-source/{organizationName}/{testSuitesSourceName}/contains?version={version}",
testSuitesSource.organization.name, testSuitesSource.name, version)
testSuitesSource.organizationName, testSuitesSource.name, version)
.retrieve()
.bodyToMono()

/**
* @param organizationName
* @param testSuitesSourceName
* @param version
* @return list of [TestSuite]
*/
fun getTestSuites(organizationName: String, testSuitesSourceName: String, version: String) = webClientBackend.get()
.uri(
"/test-suites-source/{organizationName}/{testSuitesSourceName}/{version}/get-test-suites",
Expand All @@ -87,20 +93,6 @@ class PreprocessorToBackendBridge(
.retrieve()
.bodyToMono<List<TestSuite>>()

fun getTestSuites(testSuitesSource: TestSuitesSourceDto, version: String) = getTestSuites(testSuitesSource.organization.name, testSuitesSource.name, version)

fun getTestSuitesSource(
organizationName: String,
name: String
): Mono<TestSuitesSourceDto> = webClientBackend.post()
.uri(
"/test-suites-source/{organizationName}/{name}",
organizationName,
name
)
.retrieve()
.bodyToMono()

/**
* @param organizationName
* @param gitUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestDiscoveringServiceTest {
rootTestConfig = testDiscoveringService.getRootTestConfig(tmpDir.resolve("examples/kotlin-diktat").toString())
val organization = Organization.stub(42)
testSuitesSourceDto = TestSuitesSourceDto(
organization,
organization.name,
"Test",
null,
GitDto("https://github.com/saveourtool/save-cli"),
Expand Down

0 comments on commit bca9afe

Please sign in to comment.