File tree Expand file tree Collapse file tree
src/test/java/com/sonar/scanner/api/it Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 <dependency >
2828 <groupId >org.sonarsource.orchestrator</groupId >
2929 <artifactId >sonar-orchestrator</artifactId >
30- <version >3.30 .0.2630 </version >
30+ <version >3.33 .0.2677 </version >
3131 <scope >test</scope >
3232 <exclusions >
3333 <exclusion >
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ public class ProxyTest {
7474
7575 @ Before
7676 public void deleteData () {
77- ORCHESTRATOR .resetData ();
77+ ScannerApiTestSuite .resetData (ORCHESTRATOR );
7878 seenByProxy .clear ();
7979 }
8080
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ public class SSLTest {
7777
7878 @ Before
7979 public void deleteData () {
80- ORCHESTRATOR .resetData ();
80+ ScannerApiTestSuite .resetData (ORCHESTRATOR );
8181 }
8282
8383 @ After
Original file line number Diff line number Diff line change 2020package com .sonar .scanner .api .it ;
2121
2222import com .sonar .orchestrator .Orchestrator ;
23+ import com .sonar .orchestrator .http .HttpMethod ;
2324import com .sonar .orchestrator .locator .MavenLocation ;
25+ import java .time .Instant ;
26+ import java .time .ZoneId ;
27+ import java .time .format .DateTimeFormatter ;
28+ import java .time .temporal .ChronoUnit ;
2429import org .apache .commons .lang .StringUtils ;
2530import org .junit .ClassRule ;
2631import org .junit .runner .RunWith ;
@@ -52,4 +57,21 @@ private static String getSystemPropertyOrFail(String orchestratorPropertiesSourc
5257 return propertyValue ;
5358 }
5459
60+ public static void resetData (Orchestrator orchestrator ) {
61+ // We add one day to ensure that today's entries are deleted.
62+ Instant instant = Instant .now ().plus (1 , ChronoUnit .DAYS );
63+
64+ // The expected format is yyyy-MM-dd.
65+ String currentDateTime = DateTimeFormatter .ISO_LOCAL_DATE
66+ .withZone (ZoneId .of ("UTC" ))
67+ .format (instant );
68+
69+ orchestrator .getServer ()
70+ .newHttpCall ("/api/projects/bulk_delete" )
71+ .setAdminCredentials ()
72+ .setMethod (HttpMethod .POST )
73+ .setParams ("analyzedBefore" , currentDateTime )
74+ .execute ();
75+ }
76+
5577}
You can’t perform that action at this time.
0 commit comments