33import com .dtsx .astra .sdk .db .DatabaseClient ;
44import com .dtsx .astra .sdk .db .domain .*;
55import com .dtsx .astra .sdk .db .exception .KeyspaceAlreadyExistException ;
6+ import com .dtsx .astra .sdk .db .exception .KeyspaceNotFoundException ;
67import com .dtsx .astra .sdk .db .exception .RegionAlreadyExistException ;
78import com .dtsx .astra .sdk .db .exception .RegionNotFoundException ;
89import com .dtsx .astra .sdk .utils .TestUtils ;
@@ -27,7 +28,7 @@ public void shouldCreateKeyspacesTest() {
2728 Assertions .assertThrows (IllegalArgumentException .class , () -> getSdkTestDatabaseClient ().keyspaces ().create ("" ));
2829 Assertions .assertThrows (IllegalArgumentException .class , () -> getSdkTestDatabaseClient ().keyspaces ().create (null ));
2930 // Given
30- Assertions .assertFalse (getSdkTestDatabaseClient ().find ().get (). getInfo (). getKeyspaces (). contains (SDK_TEST_KEYSPACE2 ));
31+ Assertions .assertFalse (getSdkTestDatabaseClient ().keyspaces ().exist (SDK_TEST_KEYSPACE2 ));
3132 // When
3233 getSdkTestDatabaseClient ().keyspaces ().create (SDK_TEST_KEYSPACE2 );
3334 Assertions .assertEquals (DatabaseStatusType .MAINTENANCE , getSdkTestDatabaseClient ().find ().get ().getStatus ());
@@ -36,16 +37,31 @@ public void shouldCreateKeyspacesTest() {
3637 // When
3738 Assertions .assertEquals (DatabaseStatusType .ACTIVE , getSdkTestDatabaseClient ().find ().get ().getStatus ());
3839 // Then
39- Database db = getSdkTestDatabaseClient ().get ();
40- Assertions .assertTrue (db .getInfo ().getKeyspaces ().contains (SDK_TEST_KEYSPACE2 ));
40+ Assertions .assertTrue (getSdkTestDatabaseClient ().keyspaces ().exist (SDK_TEST_KEYSPACE2 ));
4141 // Cannot create keyspace that already exist
4242 Assertions .assertThrows (KeyspaceAlreadyExistException .class ,
4343 () -> getSdkTestDatabaseClient ().keyspaces ().create (SDK_TEST_KEYSPACE2 ));
4444 }
4545
4646 @ Test
4747 @ Order (2 )
48- @ DisplayName ("02. Download Default Cloud SecureBundle" )
48+ @ DisplayName ("02. Delete a new Keyspace" )
49+ public void shouldDeleteKeyspacesTest () {
50+ // Givem
51+ Assertions .assertThrows (KeyspaceNotFoundException .class ,
52+ () -> getSdkTestDatabaseClient ().keyspaces ().delete ("invalid" ));
53+ // Given
54+ Assertions .assertTrue (getSdkTestDatabaseClient ().keyspaces ().exist (SDK_TEST_KEYSPACE2 ));
55+ // When
56+ getSdkTestDatabaseClient ().keyspaces ().delete (SDK_TEST_KEYSPACE2 );
57+ // Then
58+ TestUtils .waitForDbStatus (getSdkTestDatabaseClient (), DatabaseStatusType .ACTIVE , 300 );
59+ Assertions .assertFalse (getSdkTestDatabaseClient ().keyspaces ().exist (SDK_TEST_KEYSPACE2 ));
60+ }
61+
62+ @ Test
63+ @ Order (3 )
64+ @ DisplayName ("03. Download Default Cloud SecureBundle" )
4965 public void shouldDownloadDefaultScbTest () {
5066 // Given
5167 String randomFile = "/tmp/" + UUID .randomUUID ().toString ().replaceAll ("-" , "" ) + ".zip" ;
@@ -58,8 +74,8 @@ public void shouldDownloadDefaultScbTest() {
5874 }
5975
6076 @ Test
61- @ Order (3 )
62- @ DisplayName ("03 . Download Region Cloud SecureBundle" )
77+ @ Order (4 )
78+ @ DisplayName ("04 . Download Region Cloud SecureBundle" )
6379 public void shouldDownloadRegionScbTest () {
6480 // Given
6581 String randomFile = "/tmp/" + UUID .randomUUID ().toString ().replaceAll ("-" , "" ) + ".zip" ;
@@ -73,8 +89,8 @@ public void shouldDownloadRegionScbTest() {
7389 }
7490
7591 @ Test
76- @ Order (4 )
77- @ DisplayName ("04 . Download All Cloud Secured Bundle" )
92+ @ Order (5 )
93+ @ DisplayName ("05 . Download All Cloud Secured Bundle" )
7894 public void shouldDownloadAllScbTest () {
7995 // When
8096 Assertions .assertThrows (IllegalArgumentException .class , () ->
@@ -91,63 +107,63 @@ public void shouldDownloadAllScbTest() {
91107 }
92108
93109 @ Test
94- @ Order (5 )
95- @ DisplayName ("05 . Should not PARK Serverless" )
110+ @ Order (6 )
111+ @ DisplayName ("06 . Should not PARK Serverless" )
96112 public void shouldNotParkServerlessTest () {
97113 Assertions .assertThrows (IllegalArgumentException .class , () -> getSdkTestDatabaseClient ().park ());
98114 }
99115
100116 @ Test
101- @ Order (6 )
102- @ DisplayName ("06 . Should not UNPARK Serverless" )
117+ @ Order (7 )
118+ @ DisplayName ("07 . Should not UNPARK Serverless" )
103119 public void shouldNotUnParkServerlessTest () {
104120 Assertions .assertThrows (IllegalArgumentException .class , () -> getSdkTestDatabaseClient ().unpark ());
105121 }
106122
107123 @ Test
108- @ Order (7 )
109- @ DisplayName ("07 . Should not RESIZE Serverless" )
124+ @ Order (8 )
125+ @ DisplayName ("08 . Should not RESIZE Serverless" )
110126 public void shouldNotResizeServerlessTest () {
111127 Assertions .assertThrows (IllegalArgumentException .class ,
112128 () -> getSdkTestDatabaseClient ().resize (2 ));
113129 }
114130
115131 @ Test
116- @ Order (8 )
117- @ DisplayName ("08 . Should not RESET PASSWORD Serverless" )
132+ @ Order (9 )
133+ @ DisplayName ("09 . Should not RESET PASSWORD Serverless" )
118134 public void shouldNotResetPasswordTest () {
119135 Assertions .assertThrows (RuntimeException .class ,
120136 () -> getSdkTestDatabaseClient ().resetPassword ("token" , "cedrick1" ));
121137 }
122138
123139 @ Test
124- @ Order (9 )
125- @ DisplayName ("09 . Should List regions" )
140+ @ Order (10 )
141+ @ DisplayName ("10 . Should List regions" )
126142 public void shouldListRegionsTest () {
127143 List <Datacenter > regions = getSdkTestDatabaseClient ().datacenters ().findAll ().collect (Collectors .toList ());
128144 Assertions .assertEquals (1 , regions .size ());
129145 Assertions .assertEquals (SDK_TEST_DB_REGION , regions .get (0 ).getRegion ());
130146 }
131147
132148 @ Test
133- @ Order (10 )
134- @ DisplayName ("10 . Should find region" )
149+ @ Order (11 )
150+ @ DisplayName ("11 . Should find region" )
135151 public void shouldFindRegionsTest () {
136152 Assertions .assertTrue (getSdkTestDatabaseClient ().datacenters ().findByRegionName (SDK_TEST_DB_REGION ).isPresent ());
137153 Assertions .assertFalse (getSdkTestDatabaseClient ().datacenters ().findByRegionName ("eu-west-1" ).isPresent ());
138154 }
139155
140156 @ Test
141- @ Order (11 )
142- @ DisplayName ("11 . Should not remove invalid region" )
157+ @ Order (12 )
158+ @ DisplayName ("12 . Should not remove invalid region" )
143159 public void shouldNotRemoveRegionsTest () {
144160 Assertions .assertThrows (RegionNotFoundException .class ,
145161 () -> getSdkTestDatabaseClient ().datacenters ().delete ("eu-west-1" ));
146162 }
147163
148164 @ Test
149- @ Order (12 )
150- @ DisplayName ("12 . Should not add existing region" )
165+ @ Order (13 )
166+ @ DisplayName ("13 . Should not add existing region" )
151167 public void shouldNotAddRegionsTest () {
152168 Assertions .assertThrows (RegionAlreadyExistException .class ,
153169 () -> getSdkTestDatabaseClient ()
@@ -157,7 +173,8 @@ public void shouldNotAddRegionsTest() {
157173
158174
159175 @ Test
160- @ DisplayName ("Should add a region" )
176+ @ Order (14 )
177+ @ DisplayName ("14. Should add a region" )
161178 public void shouldAddRegionTest () {
162179 // create an AWS DB
163180// if (getDatabasesClient().findByName("aws_multiple_regions").count() == 0) {
@@ -174,14 +191,15 @@ public void shouldAddRegionTest() {
174191 }
175192
176193 @ Test
177- @ DisplayName ("Should delete a region" )
194+ @ Order (15 )
195+ @ DisplayName ("14. Should delete a region" )
178196 public void shouldDeleteRegionTest () {
179197// getDatabasesClient().databaseByName("aws_multiple_regions").datacenters().delete("eu-central-1");
180198 }
181199
182200 @ Test
183- @ Order (13 )
184- @ DisplayName ("13 . Should terminate DB" )
201+ @ Order (16 )
202+ @ DisplayName ("16 . Should terminate DB" )
185203 public void shouldTerminateDbTest () {
186204 Assert .assertTrue (getSdkTestDatabaseClient ().exist ());
187205 //getSdkTestDatabaseClient().delete();
0 commit comments