use of org.vividus.azure.cosmos.model.CosmosDbContainer in project vividus by vividus-framework.
the class CosmosDbServiceTests method testWithContainer.
private void testWithContainer(BiConsumer<CosmosDbContainer, CosmosContainer> testToRun, String containerId) {
CosmosDbContainer dbContainer = new CosmosDbContainer();
dbContainer.setId(containerId);
dbContainer.setDbKey(DB_KEY);
try (CosmosClient client = mock(CosmosClient.class);
MockedConstruction<CosmosClientBuilder> builderConstructor = mockConstruction(CosmosClientBuilder.class, (mock, context) -> {
when(mock.endpoint(ENDPOINT)).thenReturn(mock);
when(mock.key(KEY)).thenReturn(mock);
when(mock.connectionSharingAcrossClientsEnabled(true)).thenReturn(mock);
when(mock.buildClient()).thenReturn(client);
})) {
when(client.getDatabase(DB)).thenReturn(database);
when(database.getContainer(containerId)).thenReturn(container);
testToRun.accept(dbContainer, container);
assertThat(builderConstructor.constructed(), hasSize(1));
}
}
Aggregations