Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void createItem() throws Exception {
validateItemResponse(properties, itemResponse);

properties = getDocumentDefinition(UUID.randomUUID().toString());
logger.info("Testing log");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep or remove?

CosmosItemResponse<InternalObjectNode> itemResponse1 = container.createItem(properties, new CosmosItemRequestOptions());
validateItemResponse(properties, itemResponse1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.data.cosmos.common.PropertyLoader;
import java.lang.reflect.Field;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;

import java.lang.reflect.Field;

/**
* Factory class for CosmosDb to create client
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;

import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class MemoizerUnitTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class TestConstants {
public static final List<Address> ADDRESSES = Arrays.asList(ADDRESS_1, ADDRESS_2);

public static final int DEFAULT_TIME_TO_LIVE = -1;
public static final String DEFAULT_MINIMUM_RU = "400";
public static final boolean DEFAULT_INDEXING_POLICY_AUTOMATIC = true;
public static final IndexingMode DEFAULT_INDEXING_POLICY_MODE = IndexingMode.CONSISTENT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ public void createWithAutoscale() throws ClassNotFoundException {
assertNotNull(throughput);
assertEquals(Integer.parseInt(TestConstants.AUTOSCALE_MAX_THROUGHPUT),
throughput.getProperties().getAutoscaleMaxThroughput());
collectionManager.deleteContainer(autoScaleSampleInfo);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in a try finally block - just in case somehow we got some failures

}

@Test
Expand All @@ -987,6 +988,7 @@ public void createDatabaseWithThroughput() throws ClassNotFoundException {
final CosmosAsyncDatabase database = client.getDatabase(configuredThroughputDbName);
final ThroughputResponse response = database.readThroughput().block();
assertEquals(expectedRequestUnits, response.getProperties().getManualThroughput());
deleteDatabaseIfExists(configuredThroughputDbName);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
package com.azure.spring.data.cosmos.core;

import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosBridgeInternal;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.models.PartitionKey;
import com.azure.cosmos.models.SqlQuerySpec;
import com.azure.spring.data.cosmos.CosmosFactory;
import com.azure.spring.data.cosmos.IntegrationTestCollectionManager;
import com.azure.spring.data.cosmos.common.PageTestUtils;
Expand All @@ -16,7 +14,6 @@
import com.azure.spring.data.cosmos.common.TestUtils;
import com.azure.spring.data.cosmos.config.CosmosConfig;
import com.azure.spring.data.cosmos.core.convert.MappingCosmosConverter;
import com.azure.spring.data.cosmos.core.generator.FindQuerySpecGenerator;
import com.azure.spring.data.cosmos.core.mapping.CosmosMappingContext;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
import com.azure.spring.data.cosmos.core.query.CosmosQuery;
Expand All @@ -42,7 +39,6 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static com.azure.spring.data.cosmos.common.TestConstants.ADDRESSES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import static com.azure.spring.data.cosmos.common.TestConstants.ID_1;
import static com.azure.spring.data.cosmos.common.TestConstants.LAST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.NEW_PASSPORT_IDS_BY_COUNTRY;
import static com.azure.spring.data.cosmos.common.TestConstants.NOT_EXIST_ID;
import static com.azure.spring.data.cosmos.common.TestConstants.PASSPORT_IDS_BY_COUNTRY;
import static com.azure.spring.data.cosmos.common.TestConstants.PATCH_AGE_1;
import static com.azure.spring.data.cosmos.common.TestConstants.PATCH_AGE_INCREMENT;
Expand Down Expand Up @@ -649,6 +648,7 @@ public void createWithAutoscale() {
assertNotNull(throughput);
assertEquals(Integer.parseInt(TestConstants.AUTOSCALE_MAX_THROUGHPUT),
throughput.getProperties().getAutoscaleMaxThroughput());
cosmosTemplate.deleteContainer(autoScaleSampleInfo.getContainerName());
}

@Test
Expand All @@ -669,6 +669,7 @@ public void createDatabaseWithThroughput() throws ClassNotFoundException {
final CosmosAsyncDatabase database = client.getDatabase(configuredThroughputDbName);
final ThroughputResponse response = database.readThroughput().block();
assertEquals(expectedRequestUnits, response.getProperties().getManualThroughput());
deleteDatabaseIfExists(configuredThroughputDbName);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.core.mapping.event;

import static org.assertj.core.api.Assertions.*;

import com.azure.spring.data.cosmos.domain.IPerson;
import com.azure.spring.data.cosmos.domain.Person;
import com.azure.spring.data.cosmos.domain.Student;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class CosmosEventListenerUnitTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import java.util.Objects;

@Container()
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we will have to specifically configure the RU here (default is 400 I think )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be needed, the default is already 400 ru's isn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be needed, the default is already 400 ru's isn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be needed, the default is already 400 ru's isn't it?

public class Address {

public static final Address TEST_ADDRESS1_PARTITION1 = new Address(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
Expand All @@ -12,7 +13,7 @@

import java.time.OffsetDateTime;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class AuditableEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.GeneratedValue;
import org.springframework.data.annotation.CreatedBy;
Expand All @@ -12,7 +13,7 @@

import java.time.OffsetDateTime;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class AuditableIdGeneratedEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container()
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class BasicItem {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.CompositeIndex;
import com.azure.spring.data.cosmos.core.mapping.CompositeIndexPath;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.CosmosIndexingPolicy;
import org.springframework.data.annotation.Id;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
@CosmosIndexingPolicy(
includePaths = {"/field/?"},
excludePaths = {"/*", "/\"_etag\"/?"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
package com.azure.spring.data.cosmos.domain;

import com.azure.cosmos.models.CompositePathSortOrder;
import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.CompositeIndex;
import com.azure.spring.data.cosmos.core.mapping.CompositeIndexPath;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.CosmosIndexingPolicy;
import org.springframework.data.annotation.Id;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
@CosmosIndexingPolicy(compositeIndexes = {
@CompositeIndex(paths = {
@CompositeIndexPath(path = "/fieldOne"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container()
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class Contact {
@Id
private String logicId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class Course {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;

import java.util.Objects;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class CourseWithEtag {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class Customer {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.GeneratedValue;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class GenIdEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.CosmosIndexingPolicy;
import org.springframework.data.annotation.Id;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
@CosmosIndexingPolicy
public class IndexPolicyEntity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.CosmosIndexingPolicy;
import org.springframework.data.annotation.Id;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
@CosmosIndexingPolicy(
overwritePolicy = true,
includePaths = {"/\"_etag\"/?"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class IntegerIdDomain {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class LongIdDomain {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import org.springframework.data.annotation.Id;

import java.util.Objects;

@Container
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class LongIdDomainPartition {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.domain;

import com.azure.spring.data.cosmos.common.TestConstants;
import com.azure.spring.data.cosmos.core.mapping.Container;

import java.util.Date;
Expand All @@ -10,7 +11,7 @@
/**
* For testing date and enum purpose
*/
@Container()
@Container(ru = TestConstants.DEFAULT_MINIMUM_RU)
public class Memo {
private String id;
private String message;
Expand Down
Loading