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.
* Adding http client to client builder * adding setter * Adding TestBase for tests * adding setter * rename * session record * checkstyle fix * rename variable * minor naming changes
- Loading branch information
Showing
8 changed files
with
303 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
60 changes: 60 additions & 0 deletions
60
search/data-plane/data/src/test/java/com/azure/search/data/SearchIndexAsyncClientTest.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,60 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.search.data; | ||
|
||
import com.azure.search.data.generated.models.DocumentIndexResult; | ||
import com.azure.search.data.generated.models.IndexAction; | ||
import com.azure.search.data.generated.models.IndexActionType; | ||
import com.azure.search.data.generated.models.IndexBatch; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.Reader; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class SearchIndexAsyncClientTest extends SearchIndexClientTestBase { | ||
|
||
private SearchIndexAsyncClient searchIndexAsyncClient; | ||
private static final String HOTELS_DATA_JSON = "HotelsDataArray.json"; | ||
|
||
@Override | ||
protected void beforeTest() { | ||
super.beforeTest(); | ||
searchIndexAsyncClient = builderSetup().buildAsyncClient(); | ||
} | ||
|
||
@Test | ||
public void indexResultSucceeds() throws Exception { | ||
|
||
List<Map> hotels = loadHotels(); | ||
|
||
Map<String, Object> hotel = new HashMap<String, Object>(hotels.get(1)); | ||
List<IndexAction> indexActions = new ArrayList<>(); | ||
indexActions.add(new IndexAction() | ||
.actionType(IndexActionType.UPLOAD) | ||
.additionalProperties(hotel) | ||
); | ||
|
||
DocumentIndexResult result = searchIndexAsyncClient.index(new IndexBatch().actions(indexActions)).block(); | ||
|
||
assert result.results().get(0).statusCode() == 200; | ||
|
||
} | ||
|
||
private List<Map> loadHotels() throws IOException { | ||
Reader docsData = new InputStreamReader( | ||
getClass().getClassLoader().getResourceAsStream(HOTELS_DATA_JSON)); | ||
List<Map> hotels = new ObjectMapper().readValue(docsData, List.class); | ||
assert hotels != null; | ||
|
||
return hotels; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.