forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/managing index contents (Azure#57)
* IndexingTests as defined by user story Azure#928. * Changed junit to StepVerifier for async test. * Resolve nit comment.
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...earch/azure-search-data/src/test/java/com/azure/search/data/tests/IndexingAsyncTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.search.data.tests; | ||
|
||
import com.azure.search.data.SearchIndexAsyncClient; | ||
import reactor.core.publisher.Mono; | ||
import reactor.test.StepVerifier; | ||
|
||
public class IndexingAsyncTests extends IndexingTestBase { | ||
private SearchIndexAsyncClient client; | ||
|
||
@Override | ||
public void countingDocsOfNewIndexGivesZero() { | ||
Mono<Long> result = client.countDocuments(); | ||
Long expected = 0L; | ||
|
||
StepVerifier.create(result).expectNext(expected).expectComplete().verify(); | ||
} | ||
|
||
@Override | ||
protected void initializeClient() { | ||
client = builderSetup().indexName(INDEX_NAME).buildAsyncClient(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...search/azure-search-data/src/test/java/com/azure/search/data/tests/IndexingSyncTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.search.data.tests; | ||
|
||
import com.azure.search.data.SearchIndexClient; | ||
import org.junit.Assert; | ||
|
||
public class IndexingSyncTests extends IndexingTestBase { | ||
private SearchIndexClient client; | ||
|
||
@Override | ||
public void countingDocsOfNewIndexGivesZero() { | ||
Long actual = client.countDocuments(); | ||
Long expected = 0L; | ||
|
||
Assert.assertEquals(expected, actual); | ||
} | ||
|
||
@Override | ||
protected void initializeClient() { | ||
client = builderSetup().indexName(INDEX_NAME).buildClient(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
sdk/search/azure-search-data/src/test/java/com/azure/search/data/tests/IndexingTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.search.data.tests; | ||
|
||
import com.azure.search.data.env.SearchIndexClientTestBase; | ||
import org.junit.Test; | ||
|
||
public abstract class IndexingTestBase extends SearchIndexClientTestBase { | ||
protected static final String INDEX_NAME = "hotels"; | ||
|
||
@Override | ||
protected void beforeTest() { | ||
super.beforeTest(); | ||
initializeClient(); | ||
} | ||
|
||
@Test | ||
public abstract void countingDocsOfNewIndexGivesZero(); | ||
|
||
protected abstract void initializeClient(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...azure-search-data/src/test/resources/session-records/countingDocsOfNewIndexGivesZero.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"networkCallRecords" : [ { | ||
"Method" : "GET", | ||
"Uri" : "https://azs-sdkfc967636577b.search.windows.net/indexes('hotels')/docs/$count?api-version=2019-05-06", | ||
"Headers" : { }, | ||
"Response" : { | ||
"Pragma" : "no-cache", | ||
"retry-after" : "0", | ||
"request-id" : "1fa44fac-55fd-4dc8-89ea-9cfea0d520c6", | ||
"StatusCode" : "200", | ||
"Date" : "Thu, 05 Sep 2019 01:38:15 GMT", | ||
"Strict-Transport-Security" : "max-age=15724800; includeSubDomains", | ||
"Cache-Control" : "no-cache", | ||
"elapsed-time" : "109", | ||
"OData-Version" : "4.0", | ||
"Expires" : "-1", | ||
"Content-Length" : "4", | ||
"Body" : "0", | ||
"Preference-Applied" : "odata.include-annotations=\"*\"", | ||
"Content-Type" : "text/plain" | ||
} | ||
} ], | ||
"variables" : [ ] | ||
} |