Skip to content

Commit

Permalink
Fixed method name for LocalDateTime converting (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls authored Dec 16, 2022
1 parent 80022c6 commit 8fe3d32
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.saveourtool.save.agent.TestExecutionDto
import com.saveourtool.save.backend.repository.AgentRepository
import com.saveourtool.save.backend.repository.ExecutionRepository
import com.saveourtool.save.backend.repository.TestExecutionRepository
import com.saveourtool.save.backend.utils.secondsToLocalDateTime
import com.saveourtool.save.core.result.CountWarnings
import com.saveourtool.save.domain.TestResultLocation
import com.saveourtool.save.domain.TestResultStatus
Expand Down Expand Up @@ -179,8 +178,8 @@ class TestExecutionService(
it.status == TestResultStatus.RUNNING
}
.ifPresentOrElse({
it.startTime = testExecDto.startTimeSeconds?.secondsToLocalDateTime()
it.endTime = testExecDto.endTimeSeconds?.secondsToLocalDateTime()
it.startTime = testExecDto.startTimeSeconds?.secondsToJLocalDateTime()
it.endTime = testExecDto.endTimeSeconds?.secondsToJLocalDateTime()
it.status = testExecDto.status
when (testExecDto.status) {
TestResultStatus.PASSED -> counters.passed++
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.saveourtool.save.authservice.utils.AuthenticationDetails
import com.saveourtool.save.backend.repository.LnkExecutionAgentRepository
import com.saveourtool.save.backend.utils.MySqlExtension
import com.saveourtool.save.backend.utils.mutateMockedUser
import com.saveourtool.save.backend.utils.secondsToLocalDateTime
import com.saveourtool.save.domain.TestResultStatus
import com.saveourtool.save.utils.secondsToJLocalDateTime
import com.saveourtool.save.v1

import org.junit.jupiter.api.Assertions.assertEquals
Expand Down Expand Up @@ -153,8 +153,8 @@ class TestExecutionControllerTest {
val tests = getAllTestExecutions()
val passedTestsAfter = getExecutionsTestsResultByAgentContainerId(testExecutionDtoSecond.agentContainerId!!, true)
val failedTestsAfter = getExecutionsTestsResultByAgentContainerId(testExecutionDtoFirst.agentContainerId!!, false)
assertTrue(tests.any { it.startTime == testExecutionDtoFirst.startTimeSeconds!!.secondsToLocalDateTime().withNano(0) })
assertTrue(tests.any { it.endTime == testExecutionDtoFirst.endTimeSeconds!!.secondsToLocalDateTime().withNano(0) })
assertTrue(tests.any { it.startTime == testExecutionDtoFirst.startTimeSeconds!!.secondsToJLocalDateTime().withNano(0) })
assertTrue(tests.any { it.endTime == testExecutionDtoFirst.endTimeSeconds!!.secondsToJLocalDateTime().withNano(0) })
assertEquals(passedTestsBefore, passedTestsAfter - 1)
assertEquals(failedTestsBefore, failedTestsAfter - 1)
assertTrue(tests.any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ package com.saveourtool.save.utils
import kotlinx.datetime.*

/**
* @return [Instant] from epoch time
* @return [Instant] from epoch time in mills
*/
fun Long.secondsToInstant(): Instant = Instant.fromEpochMilliseconds(this)
fun Long.millisToInstant(): Instant = Instant.fromEpochMilliseconds(this)

/**
* @return [Instant] from epoch time in seconds
*/
fun Long.secondsToInstant(): Instant = Instant.fromEpochSeconds(this)

/**
* @return pretty string representation of [Instant]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Utility methods related to a Date and Time in JVM
*/

package com.saveourtool.save.utils

import java.time.LocalDateTime
import java.time.ZoneOffset

import kotlinx.datetime.toJavaInstant

/**
* Function to convert long number of seconds to LocalDateTime
*
* @return an instance of [LocalDateTime]
*/
@Suppress("FUNCTION_NAME_INCORRECT_CASE")
fun Long.secondsToJLocalDateTime(): LocalDateTime = LocalDateTime.ofInstant(secondsToInstant().toJavaInstant(), ZoneOffset.UTC)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ package com.saveourtool.save.frontend.components.basic.organizations
import com.saveourtool.save.frontend.externals.fontawesome.*
import com.saveourtool.save.frontend.utils.buttonBuilder
import com.saveourtool.save.testsuite.*
import com.saveourtool.save.utils.millisToInstant
import com.saveourtool.save.utils.prettyPrint
import com.saveourtool.save.utils.secondsToInstant

import csstype.ClassName
import csstype.Cursor
Expand Down Expand Up @@ -192,7 +192,7 @@ fun ChildrenBuilder.showTestSuitesSourceSnapshotKeys(
}
div {
className = ClassName("float-right")
+testSuitesSourceSnapshotKey.creationTimeInMills.secondsToInstant().prettyPrint()
+testSuitesSourceSnapshotKey.creationTimeInMills.millisToInstant().prettyPrint()
}
}
}
Expand Down

0 comments on commit 8fe3d32

Please sign in to comment.