18
18
import java .util .HashMap ;
19
19
import java .util .Map ;
20
20
21
+ import static org .elasticsearch .cluster .ClusterName .DEFAULT ;
22
+
21
23
public class TransportPutDatabaseConfigurationActionTests extends ESTestCase {
22
24
23
25
public void testValidatePrerequisites () {
24
26
ProjectId projectId = randomProjectIdOrDefault ();
25
27
// Test that we reject two configurations with the same database name but different ids:
26
28
String name = randomAlphaOfLengthBetween (1 , 50 );
27
29
IngestGeoIpMetadata ingestGeoIpMetadata = randomIngestGeoIpMetadata (name );
28
- ClusterState state = ClusterState .builder (ClusterState . EMPTY_STATE )
30
+ ClusterState state = ClusterState .builder (DEFAULT )
29
31
.putProjectMetadata (ProjectMetadata .builder (projectId ).putCustom (IngestGeoIpMetadata .TYPE , ingestGeoIpMetadata ).build ())
30
32
.build ();
31
33
DatabaseConfiguration databaseConfiguration = randomDatabaseConfiguration (randomIdentifier (), name );
@@ -40,7 +42,11 @@ public void testValidatePrerequisites() {
40
42
TransportPutDatabaseConfigurationAction .validatePrerequisites (projectId , databaseConfigurationForDifferentName , state );
41
43
42
44
// Test that we do not reject a configuration if none already exists:
43
- TransportPutDatabaseConfigurationAction .validatePrerequisites (projectId , databaseConfiguration , ClusterState .EMPTY_STATE );
45
+ TransportPutDatabaseConfigurationAction .validatePrerequisites (
46
+ projectId ,
47
+ databaseConfiguration ,
48
+ ClusterState .builder (DEFAULT ).putProjectMetadata (ProjectMetadata .builder (projectId )).build ()
49
+ );
44
50
45
51
// Test that we do not reject a configuration if one with the same database name AND id already exists:
46
52
DatabaseConfiguration databaseConfigurationSameNameSameId = ingestGeoIpMetadata .getDatabases ()
0 commit comments