Skip to content

Commit

Permalink
Adding UT to test datasource change (Azure#212)
Browse files Browse the repository at this point in the history
* Verifying that changing a datasource connection string works
  • Loading branch information
eladiw authored Oct 30, 2019
1 parent 632198f commit 0d4bee5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
package com.azure.search;

import com.azure.search.common.DataSources;
import com.azure.search.models.*;
import com.azure.search.models.DataChangeDetectionPolicy;
import com.azure.search.models.DataContainer;
import com.azure.search.models.DataDeletionDetectionPolicy;
import com.azure.search.models.DataSource;
import com.azure.search.models.DataSourceCredentials;
import com.azure.search.models.HighWaterMarkChangeDetectionPolicy;
import com.azure.search.models.SoftDeleteColumnDeletionDetectionPolicy;
import org.junit.Assert;
import org.junit.Test;

import java.util.Objects;
Expand Down Expand Up @@ -41,6 +48,25 @@ protected void beforeTest() {
@Test
public abstract void canUpdateDataSource();

@Test
public void canUpdateConnectionData() {
// Note: since connection string is not returned when queried from the service, actually saving the
// datasource, retrieving it and verifying the change, won't work.
// Hence, we only validate that the properties on the local items can change.

// Create an initial datasource
DataSource initial = createTestBlobDataSource(null);
Assert.assertEquals(initial.getCredentials().getConnectionString(),
"DefaultEndpointsProtocol=https;AccountName=NotaRealAccount;AccountKey=fake;");

// tweak the connection string and verify it was changed
String newConnString =
"DefaultEndpointsProtocol=https;AccountName=NotaRealYetDifferentAccount;AccountKey=AnotherFakeKey;";
initial.setCredentials(new DataSourceCredentials().setConnectionString(newConnString));

Assert.assertEquals(initial.getCredentials().getConnectionString(), newConnString);
}

protected DataSource createTestBlobDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy) {
return DataSources.azureBlobStorage(
"azs-java-test-blob",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"networkCallRecords" : [ ],
"variables" : [ ]
}

0 comments on commit 0d4bee5

Please sign in to comment.