All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.deviniti.testflo.testsender.TestResultSender.kt Maven / Gradle / Ivy

There is a newer version: 1.0.11
Show newest version
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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy