com.deviniti.testflo.testsender.TestResultSender.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-results-sender Show documentation
Show all versions of test-results-sender Show documentation
TestFLO - Test result sender
package com.deviniti.testflo.testsender
import com.deviniti.testflo.jira.JiraRestClient
import com.github.kittinunf.fuel.core.FuelError
import java.util.concurrent.TimeUnit
interface TestResultSender {
fun send(configuration: Configuration): FuelError?
}
class TestResultSenderImpl(private val jiraRestClient: JiraRestClient) : TestResultSender {
override fun send(configuration: Configuration): FuelError? {
val validTestResultFiles = configuration.testResultFiles.filter { TestResultFileValidator.isValid(it, configuration.testResultsType) }
if (validTestResultFiles.isNotEmpty()) {
val resultZipFile = createZipFile(validTestResultFiles)
val error = jiraRestClient.sendTestResultFileAsync(configuration, resultZipFile)
resultZipFile.delete()
return if (error != null) {
error
} else {
var importTestResultsActive = jiraRestClient.isImportTestResultsActive(configuration)
while (importTestResultsActive.isActive == true) {
TimeUnit.SECONDS.sleep(5)
importTestResultsActive = jiraRestClient.isImportTestResultsActive(configuration)
}
importTestResultsActive.error
}
}
return null
}
}