Search in sources :

Example 16 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosDbApiImplIntegrationTest method prepare.

@BeforeAll
static void prepare() {
    var client = CosmosTestClient.createClient();
    CosmosDatabaseResponse response = client.createDatabaseIfNotExists(DATABASE_NAME);
    database = client.getDatabase(response.getProperties().getId());
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosDbApiImplIntegrationTest method cleanup.

@AfterAll
static void cleanup() {
    if (database != null) {
        CosmosDatabaseResponse delete = database.delete();
        assertThat(delete.getStatusCode()).isGreaterThanOrEqualTo(200).isLessThan(300);
    }
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse) AfterAll(org.junit.jupiter.api.AfterAll)

Example 18 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosPolicyStoreIntegrationTest method deleteDatabase.

@AfterAll
static void deleteDatabase() {
    if (database != null) {
        CosmosDatabaseResponse delete = database.delete();
        assertThat(delete.getStatusCode()).isGreaterThanOrEqualTo(200).isLessThan(300);
    }
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse) AfterAll(org.junit.jupiter.api.AfterAll)

Example 19 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class DatabaseCRUDQuickstart method createDatabaseIfNotExists.

// Database Create
private void createDatabaseIfNotExists() throws Exception {
    logger.info("Create database " + databaseName + " if not exists...");
    // Create database if not exists
    CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName);
    database = client.getDatabase(databaseResponse.getProperties().getId());
    logger.info("Done.");
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Example 20 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class DatabaseCRUDQuickstart method deleteADatabase.

// Database delete
private void deleteADatabase() throws Exception {
    logger.info("Last step: delete database " + databaseName + " by ID.");
    // Delete database
    CosmosDatabaseResponse dbResp = client.getDatabase(databaseName).delete(new CosmosDatabaseRequestOptions());
    logger.info("Status code for database delete: {}", dbResp.getStatusCode());
    logger.info("Done.");
}
Also used : CosmosDatabaseRequestOptions(com.azure.cosmos.models.CosmosDatabaseRequestOptions) CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Aggregations

CosmosDatabaseResponse (com.azure.cosmos.models.CosmosDatabaseResponse)31 CosmosDatabaseRequestOptions (com.azure.cosmos.models.CosmosDatabaseRequestOptions)8 AfterAll (org.junit.jupiter.api.AfterAll)5 BeforeAll (org.junit.jupiter.api.BeforeAll)4 CosmosClientBuilder (com.azure.cosmos.CosmosClientBuilder)3 CosmosContainerResponse (com.azure.cosmos.models.CosmosContainerResponse)3 ThroughputProperties (com.azure.cosmos.models.ThroughputProperties)3 CosmosDiagnostics (com.azure.cosmos.CosmosDiagnostics)2 CosmosContainerProperties (com.azure.cosmos.models.CosmosContainerProperties)2 ArrayList (java.util.ArrayList)2 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)2 ConsistencyLevel (com.azure.cosmos.ConsistencyLevel)1 CosmosAsyncClient (com.azure.cosmos.CosmosAsyncClient)1 CosmosClient (com.azure.cosmos.CosmosClient)1 CosmosContainer (com.azure.cosmos.CosmosContainer)1 CosmosDatabase (com.azure.cosmos.CosmosDatabase)1 AccountSettings (com.azure.cosmos.examples.common.AccountSettings)1 Profile (com.azure.cosmos.examples.common.Profile)1 CosmosItemResponse (com.azure.cosmos.models.CosmosItemResponse)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1