Search in sources :

Example 1 with FirestoreOptions

use of com.google.cloud.firestore.FirestoreOptions in project spring-cloud-gcp by spring-cloud.

the class GcpFirestoreAutoConfigurationTests method testDatastoreOptionsCorrectlySet.

@Test
public void testDatastoreOptionsCorrectlySet() {
    this.contextRunner.run((context) -> {
        FirestoreOptions datastoreOptions = context.getBean(Firestore.class).getOptions();
        assertThat(datastoreOptions.getProjectId()).isEqualTo("test-project");
    });
}
Also used : Firestore(com.google.cloud.firestore.Firestore) FirestoreOptions(com.google.cloud.firestore.FirestoreOptions) Test(org.junit.Test)

Example 2 with FirestoreOptions

use of com.google.cloud.firestore.FirestoreOptions in project spring-cloud-gcp by spring-cloud.

the class GcpFirestoreEmulatorAutoConfigurationTests method testAutoConfigurationDisabled.

@Test
public void testAutoConfigurationDisabled() {
    contextRunner.run(context -> {
        FirestoreOptions firestoreOptions = context.getBean(FirestoreOptions.class);
        String endpoint = ((InstantiatingGrpcChannelProvider) firestoreOptions.getTransportChannelProvider()).getEndpoint();
        assertThat(endpoint).isEqualTo("firestore.googleapis.com:443");
        FirestoreTemplate firestoreTemplate = context.getBean(FirestoreTemplate.class);
        assertThat(firestoreTemplate.isUsingStreamTokens()).isTrue();
    });
}
Also used : InstantiatingGrpcChannelProvider(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider) FirestoreOptions(com.google.cloud.firestore.FirestoreOptions) FirestoreTemplate(org.springframework.cloud.gcp.data.firestore.FirestoreTemplate) Test(org.junit.Test)

Example 3 with FirestoreOptions

use of com.google.cloud.firestore.FirestoreOptions in project spring-cloud-gcp by spring-cloud.

the class GcpFirestoreEmulatorAutoConfigurationTests method testAutoConfigurationEnabled.

@Test
public void testAutoConfigurationEnabled() {
    contextRunner.withPropertyValues("spring.cloud.gcp.firestore.emulator.enabled=true", "spring.cloud.gcp.firestore.host-port=localhost:9000").run(context -> {
        FirestoreOptions firestoreOptions = context.getBean(FirestoreOptions.class);
        String endpoint = ((InstantiatingGrpcChannelProvider) firestoreOptions.getTransportChannelProvider()).getEndpoint();
        assertThat(endpoint).isEqualTo("localhost:9000");
        FirestoreTemplate firestoreTemplate = context.getBean(FirestoreTemplate.class);
        assertThat(firestoreTemplate.isUsingStreamTokens()).isFalse();
        assertThat(firestoreOptions.getProjectId()).isEqualTo("unused");
    });
}
Also used : InstantiatingGrpcChannelProvider(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider) FirestoreOptions(com.google.cloud.firestore.FirestoreOptions) FirestoreTemplate(org.springframework.cloud.gcp.data.firestore.FirestoreTemplate) Test(org.junit.Test)

Example 4 with FirestoreOptions

use of com.google.cloud.firestore.FirestoreOptions in project java-docs-samples by GoogleCloudPlatform.

the class BaseIntegrationTest method baseSetup.

@BeforeClass
public static void baseSetup() throws Exception {
    FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance().toBuilder().setProjectId(projectId).build();
    db = firestoreOptions.getService();
    deleteAllDocuments(db);
}
Also used : FirestoreOptions(com.google.cloud.firestore.FirestoreOptions) BeforeClass(org.junit.BeforeClass)

Example 5 with FirestoreOptions

use of com.google.cloud.firestore.FirestoreOptions in project spring-cloud-gcp by spring-cloud.

the class GcpFirestoreEmulatorAutoConfigurationTests method testThatIfProjectIdIsGivenItWillBeUsed.

@Test
public void testThatIfProjectIdIsGivenItWillBeUsed() {
    contextRunner.withPropertyValues("spring.cloud.gcp.firestore.project-id=demo", "spring.cloud.gcp.firestore.emulator.enabled=true", "spring.cloud.gcp.firestore.host-port=localhost:9000").run(context -> {
        FirestoreOptions firestoreOptions = context.getBean(FirestoreOptions.class);
        assertThat(firestoreOptions.getProjectId()).isEqualTo("demo");
    });
}
Also used : FirestoreOptions(com.google.cloud.firestore.FirestoreOptions) Test(org.junit.Test)

Aggregations

FirestoreOptions (com.google.cloud.firestore.FirestoreOptions)5 Test (org.junit.Test)4 InstantiatingGrpcChannelProvider (com.google.api.gax.grpc.InstantiatingGrpcChannelProvider)2 FirestoreTemplate (org.springframework.cloud.gcp.data.firestore.FirestoreTemplate)2 Firestore (com.google.cloud.firestore.Firestore)1 BeforeClass (org.junit.BeforeClass)1