Skip to content

Commit

Permalink
Feature/managing index contents (Azure#57)
Browse files Browse the repository at this point in the history
* IndexingTests as defined by user story Azure#928.

* Changed junit to StepVerifier for async test.

* Resolve nit comment.
  • Loading branch information
digimaun authored and navalev committed Sep 8, 2019
1 parent 9a88e77 commit 8229595
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
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();
}
}
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();
}
}
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();
}
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" : [ ]
}

0 comments on commit 8229595

Please sign in to comment.