Skip to content

Commit

Permalink
Feature/can update data source (Azure#244)
Browse files Browse the repository at this point in the history
* canUpdateDataSource
  • Loading branch information
AdanOrtiz authored and navalev committed Nov 12, 2019
1 parent 083c932 commit 9258b06
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.Response;
import com.azure.search.models.DataContainer;
import com.azure.search.models.DataSource;
import com.azure.search.models.DataSourceCredentials;
import com.azure.search.models.DataSourceType;
import com.azure.search.models.HighWaterMarkChangeDetectionPolicy;
import com.azure.search.models.RequestOptions;
import com.azure.search.models.SoftDeleteColumnDeletionDetectionPolicy;
import com.azure.search.models.SqlIntegratedChangeTrackingPolicy;
import com.azure.search.models.DataSourceCredentials;
import com.azure.search.models.DataSourceType;
import com.azure.search.models.RequestOptions;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
Expand Down Expand Up @@ -84,17 +85,24 @@ public void deleteDataSourceIsIdempotent() {

@Override
public void canUpdateDataSource() {
DataSource initial = createTestBlobDataSource(null);
DataSource initial = createTestDataSource();

// Create the data source
client.createOrUpdateDataSource(initial).block();

DataSource expected = updateDatasource(initial);
DataSource actual = client.createOrUpdateDataSource(expected).block();

removeConnectionString(expected);

assertDataSourcesEqual(expected, actual);
DataSource updatedExpected = createTestDataSource()
.setName(initial.getName())
.setContainer(new DataContainer().setName("somethingdifferent"))
.setDescription("somethingdifferent")
.setDataChangeDetectionPolicy(new HighWaterMarkChangeDetectionPolicy().setHighWaterMarkColumnName("rowversion"))
.setDataDeletionDetectionPolicy(new SoftDeleteColumnDeletionDetectionPolicy().setSoftDeleteColumnName("isDeleted"));

StepVerifier.create(client.createOrUpdateDataSource(updatedExpected))
.assertNext(updatedActual -> {
updatedExpected.getCredentials().setConnectionString(null); // Create doesn't return connection strings.
assertDataSourcesEqual(updatedExpected, updatedActual);
})
.verifyComplete();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.search.models.DataContainer;
import com.azure.search.models.DataSource;
import com.azure.search.models.DataSourceCredentials;
import com.azure.search.models.DataSourceType;
import com.azure.search.models.HighWaterMarkChangeDetectionPolicy;
import com.azure.search.models.RequestOptions;
import com.azure.search.models.SoftDeleteColumnDeletionDetectionPolicy;
import com.azure.search.models.SqlIntegratedChangeTrackingPolicy;
import com.azure.search.models.DataSourceCredentials;
import com.azure.search.models.DataSourceType;
import com.azure.search.models.RequestOptions;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
Expand Down Expand Up @@ -100,17 +101,22 @@ public void createDataSourceFailsWithUsefulMessageOnUserError() {

@Override
public void canUpdateDataSource() {
DataSource initial = createTestBlobDataSource(null);
DataSource initial = createTestDataSource();

// Create the data source
client.createOrUpdateDataSource(initial);

DataSource expected = updateDatasource(initial);
DataSource actual = client.createOrUpdateDataSource(expected);
DataSource updatedExpected = createTestDataSource()
.setName(initial.getName())
.setContainer(new DataContainer().setName("somethingdifferent"))
.setDescription("somethingdifferent")
.setDataChangeDetectionPolicy(new HighWaterMarkChangeDetectionPolicy().setHighWaterMarkColumnName("rowversion"))
.setDataDeletionDetectionPolicy(new SoftDeleteColumnDeletionDetectionPolicy().setSoftDeleteColumnName("isDeleted"));

removeConnectionString(expected);
DataSource updatedActual = client.createOrUpdateDataSource(updatedExpected);

assertDataSourcesEqual(expected, actual);
updatedExpected.getCredentials().setConnectionString(null); // Create doesn't return connection strings.
assertDataSourcesEqual(updatedExpected, updatedActual);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ protected DataSource createTestBlobDataSource(DataDeletionDetectionPolicy deleti
);
}

protected DataSource createTestDataSource() {
return createTestSqlDataSource(null, null);
}

protected DataSource createTestTableStorageDataSource(DataDeletionDetectionPolicy deletionDetectionPolicy) {
return DataSources.azureTableStorage(
"azs-java-test-tablestorage",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://azs-sdk75f40905f288.search-dogfood.windows-int.net/datasources('azs-java-test-blob')?api-version=2019-05-06",
"Uri" : "https://azs-sdk44967083808f.search-dogfood.windows-int.net/datasources('azs-java-test-sql')?api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "018b5bae-1bb1-4892-8ecd-4dd00b5cdf87",
"request-id" : "78d48a36-e230-4ea4-b4c4-4fa871428e04",
"StatusCode" : "201",
"Date" : "Tue, 29 Oct 2019 20:53:56 GMT",
"Date" : "Thu, 07 Nov 2019 22:25:22 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D75CB21DB11705\"",
"elapsed-time" : "57",
"ETag" : "W/\"0x8D763D1612B5B13\"",
"elapsed-time" : "59",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "410",
"Body" : "{\"@odata.context\":\"https://azs-sdk75f40905f288.search-dogfood.windows-int.net/$metadata#datasources/$entity\",\"@odata.etag\":\"\\\"0x8D75CB21DB11705\\\"\",\"name\":\"azs-java-test-blob\",\"description\":\"Some data source\",\"type\":\"azureblob\",\"subtype\":null,\"credentials\":{\"connectionString\":null},\"container\":{\"name\":\"fakecontainer\",\"query\":\"/fakefolder/\"},\"dataChangeDetectionPolicy\":null,\"dataDeletionDetectionPolicy\":null}",
"Content-Length" : "395",
"Body" : "{\"@odata.context\":\"https://azs-sdk44967083808f.search-dogfood.windows-int.net/$metadata#datasources/$entity\",\"@odata.etag\":\"\\\"0x8D763D1612B5B13\\\"\",\"name\":\"azs-java-test-sql\",\"description\":\"Some data source\",\"type\":\"azuresql\",\"subtype\":null,\"credentials\":{\"connectionString\":null},\"container\":{\"name\":\"GeoNamesRI\",\"query\":null},\"dataChangeDetectionPolicy\":null,\"dataDeletionDetectionPolicy\":null}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal",
"Location" : "https://azs-sdk75f40905f288.search-dogfood.windows-int.net/datasources('azs-java-test-blob')?api-version=2019-05-06"
"Location" : "https://azs-sdk44967083808f.search-dogfood.windows-int.net/datasources('azs-java-test-sql')?api-version=2019-05-06"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://azs-sdk75f40905f288.search-dogfood.windows-int.net/datasources('azs-java-test-blob')?api-version=2019-05-06",
"Uri" : "https://azs-sdk44967083808f.search-dogfood.windows-int.net/datasources('azs-java-test-sql')?api-version=2019-05-06",
"Headers" : {
"Content-Type" : "application/json; charset=utf-8"
},
"Response" : {
"Pragma" : "no-cache",
"retry-after" : "0",
"request-id" : "dc1d0270-4140-441e-8e41-d84756837e75",
"request-id" : "3d257064-97ad-430c-8f91-84e6642be80e",
"StatusCode" : "200",
"Date" : "Tue, 29 Oct 2019 20:53:56 GMT",
"Date" : "Thu, 07 Nov 2019 22:25:22 GMT",
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains",
"Cache-Control" : "no-cache",
"ETag" : "W/\"0x8D75CB21DD23AA3\"",
"elapsed-time" : "26",
"ETag" : "W/\"0x8D763D1614CCCE1\"",
"elapsed-time" : "148",
"OData-Version" : "4.0",
"Expires" : "-1",
"Content-Length" : "547",
"Body" : "{\"@odata.context\":\"https://azs-sdk75f40905f288.search-dogfood.windows-int.net/$metadata#datasources/$entity\",\"@odata.etag\":\"\\\"0x8D75CB21DD23AA3\\\"\",\"name\":\"azs-java-test-blob\",\"description\":\"somethingdifferent\",\"type\":\"azureblob\",\"subtype\":null,\"credentials\":{\"connectionString\":null},\"container\":{\"name\":\"somethingdifferent\",\"query\":null},\"dataChangeDetectionPolicy\":null,\"dataDeletionDetectionPolicy\":{\"@odata.type\":\"#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy\",\"softDeleteColumnName\":\"isDeleted\",\"softDeleteMarkerValue\":\"1\"}}",
"Content-Length" : "657",
"Body" : "{\"@odata.context\":\"https://azs-sdk44967083808f.search-dogfood.windows-int.net/$metadata#datasources/$entity\",\"@odata.etag\":\"\\\"0x8D763D1614CCCE1\\\"\",\"name\":\"azs-java-test-sql\",\"description\":\"somethingdifferent\",\"type\":\"azuresql\",\"subtype\":null,\"credentials\":{\"connectionString\":null},\"container\":{\"name\":\"somethingdifferent\",\"query\":null},\"dataChangeDetectionPolicy\":{\"@odata.type\":\"#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy\",\"highWaterMarkColumnName\":\"rowversion\"},\"dataDeletionDetectionPolicy\":{\"@odata.type\":\"#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy\",\"softDeleteColumnName\":\"isDeleted\",\"softDeleteMarkerValue\":null}}",
"Preference-Applied" : "odata.include-annotations=\"*\"",
"Content-Type" : "application/json; odata.metadata=minimal"
},
Expand Down

0 comments on commit 9258b06

Please sign in to comment.