1
0
mirror of https://github.com/mc1arke/sonarqube-community-branch-plugin.git synced 2025-02-21 19:20:09 +02:00

#972: Ensure a consistent timezone is used in comparisons

The service code uses DateUtils to convert a long into a String format,
which DateUtils converting the long to an instant, then an
OffsetDateTime before passing this through a formatter, using the local
timezone during the OffsetDateTime conversion.
As the test was using a pre-created String based on the UTC timezone,
the test does not correctly compare the values when being executed in a
different timezone. To overcome this, the test has been altered to use
the same DateUtils methods to convert from the long to a String, thereby
ensuring the same timezone handling is using in both test and live code.
This commit is contained in:
Michael Clarke 2024-10-05 12:01:49 +01:00 committed by Michael Clarke
parent 5932956c29
commit a228d9f7ef

View File

@ -33,6 +33,7 @@ import org.mockito.ArgumentCaptor;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.DateUtils;
import org.sonar.db.DbClient;
import org.sonar.db.component.BranchDao;
import org.sonar.db.component.BranchDto;
@ -157,7 +158,7 @@ class ListActionTest {
.setKey("prKey2")
.setTitle("title2")
.setBranch("prBranch2")
.setAnalysisDate("2009-02-13T23:31:31+0000")
.setAnalysisDate(DateUtils.formatDateTime(1234567891234L))
.setStatus(ProjectPullRequests.Status.newBuilder()
.build())
.setIsOrphan(true)