diff --git a/search/data-plane/data/client.yml b/search/data-plane/data/azure-pipelines.yml similarity index 85% rename from search/data-plane/data/client.yml rename to search/data-plane/data/azure-pipelines.yml index 924c6bc9c854..10aa7a682122 100644 --- a/search/data-plane/data/client.yml +++ b/search/data-plane/data/azure-pipelines.yml @@ -1,11 +1,8 @@ -# External variables Settable at queue time: -# "pomFile" : "pom.client.xml". This is the project object model file for Maven. - variables: LoggingOptions: '-Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' jobs: -- job: 'Compile' +- job: 'Package' pool: vmImage: 'ubuntu-16.04' @@ -31,7 +28,7 @@ jobs: - task: Maven@3 displayName: 'Install Azure Core' inputs: - mavenPomFile: './sdk/core/azure-core/pom.xml' + mavenPomFile: './sdk/core/pom.xml' goals: 'install' options: '-Dmaven.test.skip=true -Dgpg.skip' publishJUnitResults: false @@ -41,7 +38,7 @@ jobs: mavenVersionOption: 'Default' - task: Maven@3 - displayName: 'Compile' + displayName: 'Package' inputs: mavenPomFile: ./search/data-plane/data/pom.xml goals: 'package' diff --git a/search/data-plane/data/pom.xml b/search/data-plane/data/pom.xml index 72163ebb1688..d65d59a357aa 100644 --- a/search/data-plane/data/pom.xml +++ b/search/data-plane/data/pom.xml @@ -7,7 +7,7 @@ com.azure azure-client-sdk-parent - 1.0.0 + 1.1.0 ../../../pom.client.xml @@ -16,6 +16,59 @@ 1.0-SNAPSHOT jar + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.azure + sdk-build-tools + ${sdk-build-tools.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + checkstyle/checkstyle.xml + checkstyle/checkstyle-suppressions.xml + checkstyle/java.header + samedir= + UTF-8 + true + true + true + true + true + **/generated/**/* + + + + package + + check + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + true + + + + + com.microsoft.azure diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/env/AzureSearchResources.java b/search/data-plane/data/src/test/java/com/azure/search/data/env/AzureSearchResources.java index 18e7555fff85..7dca6a81dcfa 100644 --- a/search/data-plane/data/src/test/java/com/azure/search/data/env/AzureSearchResources.java +++ b/search/data-plane/data/src/test/java/com/azure/search/data/env/AzureSearchResources.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.search.data.env; import com.microsoft.azure.credentials.AzureTokenCredentials; @@ -26,14 +29,26 @@ public class AzureSearchResources { private ResourceGroup resourceGroup = null; private SearchService searchService = null; + /** + * + * @return The created Resource Group name + */ public String getResourceGroupName() { return resourceGroupName; } + /** + * + * @return The created Search service name + */ public String getSearchServiceName() { return searchServiceName; } + /** + * + * @return The Search service admin key + */ public String getSearchAdminKey() { return searchAdminKey; } @@ -41,9 +56,10 @@ public String getSearchAdminKey() { /** * Creates an instance of AzureTokenCredentials to be used in creating a Resource Group and Search service * in Azure to be used for tests. + * * @param azureTokenCredentials includes credentials to connect to Azure. - * @param subscriptionId Azure subscription id. - * @param location location of the resources to be created in. + * @param subscriptionId Azure subscription id. + * @param location location of the resources to be created in. */ public AzureSearchResources( AzureTokenCredentials azureTokenCredentials, String subscriptionId, @@ -91,7 +107,7 @@ public void initialize() { private void validate() { Objects.requireNonNull(this.azureTokenCredentials, "azureTokenCredentials cannot be null"); Objects.requireNonNull(this.location, "location cannot be null"); - if(StringUtils.isBlank(this.subscriptionId)){ + if (StringUtils.isBlank(this.subscriptionId)) { throw new IllegalArgumentException("subscriptionId cannot be blank"); } } diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexDocs.java b/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexDocs.java new file mode 100644 index 000000000000..ad5fe474517a --- /dev/null +++ b/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexDocs.java @@ -0,0 +1,100 @@ +package com.azure.search.data.env; + +import com.azure.search.data.SearchIndexASyncClient; +import com.azure.search.data.common.SearchPipelinePolicy; +import com.azure.search.data.customization.SearchIndexClientBuilderImpl; +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 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 SearchIndexDocs { + + private static final String HOTELS_DATA_JSON = "HotelsDataArray.json"; + + private String searchServiceName; + private String apiAdminKey; + private String indexName; + private String dnsSuffix; + private String apiVersion; + + private SearchIndexASyncClient searchIndexASyncClient; + + /** + * Creates an instance of SearchIndexASyncClient to be used in uploading documents to a certain index, + * to be used in tests. + * + * @param searchServiceName The name of the Search service + * @param apiAdminKey The Admin key of the Search service + * @param indexName The name of the index + * @param dnsSuffix DNS suffix of the Search service + * @param apiVersion used API version + */ + public SearchIndexDocs( + String searchServiceName, String apiAdminKey, String indexName, + String dnsSuffix, String apiVersion) { + this.searchServiceName = searchServiceName; + this.apiAdminKey = apiAdminKey; + this.indexName = indexName; + this.dnsSuffix = dnsSuffix; + this.apiVersion = apiVersion; + } + + /** + * Created new documents in the index. The new documents are retrieved from HotelsDataArray.json + * @throws IOException If the file in HOTELS_DATA_JSON is not existing or invalid. + */ + public void initialize() throws IOException { + if (searchIndexASyncClient == null) { + searchIndexASyncClient = new SearchIndexClientBuilderImpl() + .serviceName(searchServiceName) + .searchDnsSuffix(dnsSuffix) + .indexName(indexName) + .apiVersion(apiVersion) + .policy(new SearchPipelinePolicy(apiAdminKey)) + .buildAsyncClient(); + } + addDocsData(); + } + + private void addDocsData() throws IOException { + Reader docsData = new InputStreamReader( + getClass().getClassLoader().getResourceAsStream(HOTELS_DATA_JSON)); + List hotels = new ObjectMapper().readValue(docsData, List.class); + + List indexActions = createIndexActions(hotels); + + System.out.println("Indexing " + indexActions.size() + " docs"); + DocumentIndexResult documentIndexResult = searchIndexASyncClient.index(new IndexBatch().actions(indexActions)) + .block(); + + System.out.println("Indexing Results:"); + assert documentIndexResult != null; + documentIndexResult.results().forEach(result -> + System.out.println( + "key:" + result.key() + (result.succeeded() ? " Succeeded" : " Error: " + result.errorMessage())) + ); + } + + private List createIndexActions(List hotels) { + List indexActions = new ArrayList<>(); + assert hotels != null; + hotels.forEach(h -> { + Map hotel = new HashMap(h); + indexActions.add(new IndexAction() + .actionType(IndexActionType.UPLOAD) + .additionalProperties(hotel) + ); + }); + return indexActions; + } +} diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexService.java b/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexService.java index 3208abd4ce97..757d8da7ceb4 100644 --- a/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexService.java +++ b/search/data-plane/data/src/test/java/com/azure/search/data/env/SearchIndexService.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.search.data.env; import com.azure.search.service.SearchServiceClient; @@ -17,6 +20,7 @@ public class SearchIndexService { private String searchServiceName; private String apiAdminKey; + private String indexName; private SearchServiceClient searchServiceClient; @@ -25,7 +29,7 @@ public class SearchIndexService { * to be used in tests. * * @param searchServiceName the name of Search Service in Azure. - * @param apiAdminKey the Admin Key of Search Service + * @param apiAdminKey the Admin Key of Search Service */ public SearchIndexService(String searchServiceName, String apiAdminKey) { this.searchServiceName = searchServiceName; @@ -35,7 +39,7 @@ public SearchIndexService(String searchServiceName, String apiAdminKey) { /** * Creates a new sample Index in Azure Search with configuration retrieved from INDEX_DATA_JSON * - * @throws IOException If the file in INDEX_DATA_JSON cannot be read. + * @throws IOException If the file in INDEX_DATA_JSON is not existing or invalid. */ public void initialize() throws IOException { validate(); @@ -49,10 +53,10 @@ public void initialize() throws IOException { } private void validate() { - if(StringUtils.isBlank(this.searchServiceName)){ + if (StringUtils.isBlank(this.searchServiceName)) { throw new IllegalArgumentException("searchServiceName cannot be blank"); } - if(StringUtils.isBlank(this.apiAdminKey)){ + if (StringUtils.isBlank(this.apiAdminKey)) { throw new IllegalArgumentException("apiAdminKey cannot be blank"); } } @@ -60,7 +64,15 @@ private void validate() { private void addIndexes() throws IOException { Reader indexData = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(INDEX_DATA_JSON)); Index index = new ObjectMapper().readValue(indexData, Index.class); + this.indexName = index.name(); searchServiceClient.indexes().create(index); } + /** + * + * @return the sample index name + */ + public String indexName(){ + return this.indexName; + } } diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/env/samples/CreateTestResources.java b/search/data-plane/data/src/test/java/com/azure/search/data/env/samples/CreateTestResources.java index e36f05f0bab5..be799c53779c 100644 --- a/search/data-plane/data/src/test/java/com/azure/search/data/env/samples/CreateTestResources.java +++ b/search/data-plane/data/src/test/java/com/azure/search/data/env/samples/CreateTestResources.java @@ -1,19 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package com.azure.search.data.env.samples; import com.azure.search.data.env.AzureSearchResources; +import com.azure.search.data.env.SearchIndexDocs; import com.azure.search.data.env.SearchIndexService; import com.microsoft.azure.AzureEnvironment; import com.microsoft.azure.credentials.ApplicationTokenCredentials; import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import java.io.IOException; + public class CreateTestResources { /** * This is an example of using {@link AzureSearchResources} to create Search resource in Azure, * and {@link SearchIndexService} to create Index in Search Azure. + * * @param args */ - public static void main(String[] args) { + public static void main(String[] args) throws IOException { // Creating Azure Search Resource: ApplicationTokenCredentials applicationTokenCredentials = new ApplicationTokenCredentials( "app-id", @@ -21,31 +28,37 @@ public static void main(String[] args) { "secret", AzureEnvironment.AZURE); - String subscriptionId="subscription-id"; + String subscriptionId = "subscription-id"; Region location = Region.US_EAST; - AzureSearchResources azureSearchResources = new AzureSearchResources(applicationTokenCredentials, subscriptionId, location); + AzureSearchResources azureSearchResources = new AzureSearchResources( + applicationTokenCredentials, subscriptionId, location); azureSearchResources.initialize(); String serviceName = azureSearchResources.getSearchServiceName(); String apiAdminKey = azureSearchResources.getSearchAdminKey(); //Creating Index: + SearchIndexService searchIndexService; try { - SearchIndexService searchIndexService = new SearchIndexService(serviceName, apiAdminKey); + searchIndexService = new SearchIndexService(serviceName, apiAdminKey); searchIndexService.initialize(); } catch (Exception e) { e.printStackTrace(); + throw e; } // Uploading Documents: -// try{ -// SearchIndexDocs searchIndexDocs = new SearchIndexDocs(serviceName, apiAdminKey); -// searchIndexDocs.initialize(); -// -// }catch (Exception e) { -// e.printStackTrace(); -// } + try{ + SearchIndexDocs searchIndexDocs = new SearchIndexDocs(serviceName, apiAdminKey, + searchIndexService.indexName(), + "search.windows.net", + "2019-05-06"); + searchIndexDocs.initialize(); + + }catch (Exception e) { + e.printStackTrace(); + } try { System.out.println("Waiting 100 secs before cleaning the created Azure Search resource"); diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientBuildersTest.java b/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientBuildersTest.java index fcbf9f831d29..e1b35738dd06 100644 --- a/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientBuildersTest.java +++ b/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientBuildersTest.java @@ -72,7 +72,7 @@ private void buildClientAndVerifyInternal(boolean isASync) { /** * Verify that if the property is invalid the client builder throws exception */ - private void BuildClientAndExpectException(boolean isASync, + private void buildClientAndExpectException(boolean isASync, String expectedMsg, String searchServiceName, String indexName, @@ -91,9 +91,9 @@ private void BuildClientAndExpectException(boolean isASync, @Before public void initialize() { - searchServiceName = ""; - apiKey = ""; - indexName = "hotels"; + searchServiceName = "servicename"; + apiKey = "0123"; + indexName = "myindex"; apiVersion = "2019-05-06"; dnsSuffix = "search.windows.net"; } @@ -132,8 +132,8 @@ public void buildClientAndVerifyPropertiesTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullSearchServiceNameIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid searchServiceName", null, + public void verifyNullSearchServiceNameIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid searchServiceName", null, indexName, apiKey, apiVersion, dnsSuffix); } @@ -141,8 +141,8 @@ public void VerifyNullSearchServiceNameIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullSearchServiceNameIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid searchServiceName", null, + public void verifyNullSearchServiceNameIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid searchServiceName", null, indexName, apiKey, apiVersion, dnsSuffix); } @@ -150,8 +150,8 @@ public void VerifyNullSearchServiceNameIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptySearchServiceNameIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(false, "Invalid searchServiceName", "", + public void verifyEmptySearchServiceNameIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(false, "Invalid searchServiceName", "", indexName, apiKey, apiVersion, dnsSuffix); } @@ -159,8 +159,8 @@ public void VerifyEmptySearchServiceNameIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptySearchServiceNameIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid searchServiceName", "", + public void verifyEmptySearchServiceNameIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid searchServiceName", "", indexName, apiKey, apiVersion, dnsSuffix); } @@ -168,8 +168,8 @@ public void VerifyEmptySearchServiceNameIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullIndexNameIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid indexName", searchServiceName, + public void verifyNullIndexNameIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid indexName", searchServiceName, null, apiKey, apiVersion, dnsSuffix); } @@ -177,8 +177,8 @@ public void VerifyNullIndexNameIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullIndexNameIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid indexName", searchServiceName, + public void verifyNullIndexNameIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid indexName", searchServiceName, null, apiKey, apiVersion, dnsSuffix); } @@ -186,8 +186,8 @@ public void VerifyNullIndexNameIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyIndexNameIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid indexName", searchServiceName, + public void verifyEmptyIndexNameIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid indexName", searchServiceName, "", apiKey, apiVersion, dnsSuffix); } @@ -195,8 +195,8 @@ public void VerifyEmptyIndexNameIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyIndexNameIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid indexName", searchServiceName, + public void verifyEmptyIndexNameIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid indexName", searchServiceName, "", apiKey, apiVersion, dnsSuffix); } @@ -204,8 +204,8 @@ public void VerifyEmptyIndexNameIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullApiKeyIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid apiKey", searchServiceName, + public void verifyNullApiKeyIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid apiKey", searchServiceName, indexName, null, apiVersion, dnsSuffix); } @@ -213,8 +213,8 @@ public void VerifyNullApiKeyIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullApiKeyIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid apiKey", searchServiceName, + public void verifyNullApiKeyIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid apiKey", searchServiceName, indexName, null, apiVersion, dnsSuffix); } @@ -222,8 +222,8 @@ public void VerifyNullApiKeyIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyApiKeyIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid apiKey", searchServiceName, + public void verifyEmptyApiKeyIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid apiKey", searchServiceName, indexName, "", apiVersion, dnsSuffix); } @@ -231,8 +231,8 @@ public void VerifyEmptyApiKeyIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyApiKeyIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid apiKey", searchServiceName, + public void verifyEmptyApiKeyIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid apiKey", searchServiceName, indexName, "", apiVersion, dnsSuffix); } @@ -240,8 +240,8 @@ public void VerifyEmptyApiKeyIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullApiVersionIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid apiVersion", searchServiceName, + public void verifyNullApiVersionIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid apiVersion", searchServiceName, indexName, apiKey, null, dnsSuffix); } @@ -249,8 +249,8 @@ public void VerifyNullApiVersionIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullApiVersionIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid apiVersion", searchServiceName, + public void verifyNullApiVersionIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid apiVersion", searchServiceName, indexName, apiKey, null, dnsSuffix); } @@ -258,8 +258,8 @@ public void VerifyNullApiVersionIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyApiVersionIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid apiVersion", searchServiceName, + public void verifyEmptyApiVersionIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid apiVersion", searchServiceName, indexName, apiKey, "", dnsSuffix); } @@ -267,8 +267,8 @@ public void VerifyEmptyApiVersionIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyApiVersionIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid apiVersion", searchServiceName, + public void verifyEmptyApiVersionIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid apiVersion", searchServiceName, indexName, apiKey, "", dnsSuffix); } @@ -276,8 +276,8 @@ public void VerifyEmptyApiVersionIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullDnsSuffixIsInvalidASyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid searchDnsSuffix", searchServiceName, + public void verifyNullDnsSuffixIsInvalidASyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid searchDnsSuffix", searchServiceName, indexName, apiKey, apiVersion, null); } @@ -285,8 +285,8 @@ public void VerifyNullDnsSuffixIsInvalidASyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyNullDnsSuffixIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid searchDnsSuffix", searchServiceName, + public void verifyNullDnsSuffixIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid searchDnsSuffix", searchServiceName, indexName, apiKey, apiVersion, null); } @@ -294,8 +294,8 @@ public void VerifyNullDnsSuffixIsInvalidTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyDnsSuffixIsInvalidAsyncTest() throws Exception { - BuildClientAndExpectException(true, "Invalid searchDnsSuffix", searchServiceName, + public void verifyEmptyDnsSuffixIsInvalidAsyncTest() throws Exception { + buildClientAndExpectException(true, "Invalid searchDnsSuffix", searchServiceName, indexName, apiKey, apiVersion, ""); } @@ -303,8 +303,8 @@ public void VerifyEmptyDnsSuffixIsInvalidAsyncTest() throws Exception { * Verify that if the property is invalid the client builder throws exception */ @Test - public void VerifyEmptyDnsSuffixIsInvalidTest() throws Exception { - BuildClientAndExpectException(false, "Invalid searchDnsSuffix", searchServiceName, + public void verifyEmptyDnsSuffixIsInvalidTest() throws Exception { + buildClientAndExpectException(false, "Invalid searchDnsSuffix", searchServiceName, indexName, apiKey, apiVersion, ""); } @@ -312,7 +312,7 @@ public void VerifyEmptyDnsSuffixIsInvalidTest() throws Exception { * Verify that there is a default for the dns suffix */ @Test - public void VerifyDefaultDnsSuffixIsCorrectTest() throws Exception { + public void verifyDefaultDnsSuffixIsCorrectTest() throws Exception { SearchPipelinePolicy policy = new SearchPipelinePolicy(apiKey); @@ -328,7 +328,7 @@ public void VerifyDefaultDnsSuffixIsCorrectTest() throws Exception { * Verify that the index name can be changed after the client was already created */ @Test - public void VerifyIndexNameIsChangeableTest() throws Exception { + public void verifyIndexNameIsChangeableTest() throws Exception { String originalIndexName = "firstOne"; SearchIndexASyncClient client = buildASyncClient(searchServiceName, originalIndexName, apiKey, apiVersion, dnsSuffix); diff --git a/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientTest.java b/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientTest.java index 1035a8ce26d6..7b040968a190 100644 --- a/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientTest.java +++ b/search/data-plane/data/src/test/java/com/azure/search/data/test/customization/SearchIndexClientTest.java @@ -3,12 +3,7 @@ package com.azure.search.data.test.customization; -import com.azure.search.data.common.SearchPipelinePolicy; -import com.azure.search.data.SearchIndexASyncClient; -import com.azure.search.data.SearchIndexClient; -import com.azure.search.data.customization.SearchIndexClientBuilderImpl; import org.junit.Before; -import org.junit.Test; public class SearchIndexClientTest { diff --git a/search/data-plane/data/src/test/resources/HotelsDataArray.json b/search/data-plane/data/src/test/resources/HotelsDataArray.json new file mode 100644 index 000000000000..f0f4bacda865 --- /dev/null +++ b/search/data-plane/data/src/test/resources/HotelsDataArray.json @@ -0,0 +1,242 @@ +[ + { + "HotelId": "1", + "HotelName": "Fancy Stay", + "Description": "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa, and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist attractions. We highly recommend this hotel.", + "Description_fr": "Meilleur hôtel en ville si vous aimez les hôtels de luxe. Ils ont une magnifique piscine à débordement, un spa et un concierge très utile. L'emplacement est parfait – en plein centre, à proximité de toutes les attractions touristiques. Nous recommandons fortement cet hôtel.", + "Category": "Luxury", + "Tags": [ + "pool", + "view", + "wifi", + "concierge" + ], + "ParkingIncluded": false, + "SmokingAllowed": false, + "LastRenovationDate": "2010-06-27T00:00:00Z", + "Rating": 5, + "Location": { + "type": "Point", + "coordinates": [ + -122.131577, + 47.678581 + ] + } + }, + { + "HotelId": "2", + "HotelName": "Roach Motel", + "Description": "Cheapest hotel in town. Infact, a motel.", + "Description_fr": "Hôtel le moins cher en ville. Infact, un motel.", + "Category": "Budget", + "Tags": [ + "motel", + "budget" + ], + "ParkingIncluded": true, + "SmokingAllowed": true, + "LastRenovationDate": "1982-04-28T00:00:00Z", + "Rating": 1, + "Location": { + "type": "Point", + "coordinates": [ + -122.131577, + 49.678581 + ] + } + }, + { + "HotelId": "3", + "HotelName": "EconoStay", + "Description": "Very popular hotel in town", + "Description_fr": "Hôtel le plus populaire en ville", + "Category": "Budget", + "Tags": [ + "wifi", + "budget" + ], + "ParkingIncluded": true, + "SmokingAllowed": false, + "LastRenovationDate": "1995-07-01T00:00:00Z", + "Rating": 4, + "Location": { + "type": "Point", + "coordinates": [ + -122.131577, + 49.678581 + ] + } + }, + { + "HotelId": "4", + "HotelName": "Express Rooms", + "Description": "Pretty good hotel", + "Description_fr": "Assez bon hôtel", + "Category": "Budget", + "Tags": [ + "wifi", + "budget" + ], + "ParkingIncluded": true, + "SmokingAllowed": false, + "LastRenovationDate": "1995-07-01T00:00:00Z", + "Rating": 4, + "Location": { + "type": "Point", + "coordinates": [ + -122.131577, + 48.678581 + ] + } + }, + { + "HotelId": "5", + "HotelName": "Comfy Place", + "Description": "Another good hotel", + "Description_fr": "Un autre bon hôtel", + "Category": "Budget", + "Tags": [ + "wifi", + "budget" + ], + "ParkingIncluded": true, + "SmokingAllowed": false, + "LastRenovationDate": "2012-08-12T00:00:00Z", + "Rating": 4, + "Location": { + "type": "Point", + "coordinates": [ + -122.131577, + 48.678581 + ] + } + }, + { + "HotelId": "6", + "Description": "Surprisingly expensive. Model suites have an ocean-view.", + "LastRenovationDate": null + }, + { + "HotelId": "7", + "HotelName": "Modern Stay", + "Description": "Modern architecture, very polite staff and very clean. Also very affordable.", + "Description_fr": "Architecture moderne, personnel poli et très propre. Aussi très abordable." + }, + { + "HotelId": "8", + "Description": "Has some road noise and is next to the very police station. Bathrooms had morel coverings.", + "Description_fr": "Il y a du bruit de la route et se trouve à côté de la station de police. Les salles de bain avaient des revêtements de morilles." + }, + { + "HotelId": "9", + "HotelName": "Secret Point Motel", + "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Time's Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.", + "Description_fr": "L'hôtel est idéalement situé sur la principale artère commerciale de la ville en plein cœur de New York. A quelques minutes se trouve la place du temps et le centre historique de la ville, ainsi que d'autres lieux d'intérêt qui font de New York l'une des villes les plus attractives et cosmopolites de l'Amérique.", + "Category": "Boutique", + "Tags": [ + "pool", + "air conditioning", + "concierge" + ], + "ParkingIncluded": false, + "LastRenovationDate": "1970-01-18T00:00:00Z", + "Rating": 3, + "Address": { + "StreetAddress": "677 5th Ave", + "City": "New York", + "StateProvince": "NY", + "PostalCode": "10022", + "Country": "USA" + }, + "Location": { + "type": "Point", + "coordinates": [ + -73.975403, + 40.760586 + ] + }, + "Rooms": [ + { + "Description": "Budget Room, 1 Queen Bed (Cityside)", + "Description_fr": "Chambre Économique, 1 grand lit (côté ville)", + "Type": "Budget Room", + "BaseRate": 9.69, + "BedOptions": "1 Queen Bed", + "SleepsCount": 2, + "SmokingAllowed": true, + "Tags": [ + "vcr/dvd" + ] + }, + { + "Description": "Budget Room, 1 King Bed (Mountain View)", + "Description_fr": "Chambre Économique, 1 très grand lit (Mountain View)", + "Type": "Budget Room", + "BaseRate": 8.09, + "BedOptions": "1 King Bed", + "SleepsCount": 2, + "SmokingAllowed": true, + "Tags": [ + "vcr/dvd", + "jacuzzi tub" + ] + } + ] + }, + { + "HotelId": "10", + "HotelName": "Countryside Hotel", + "Description": "Save up to 50% off traditional hotels. Free WiFi, great location near downtown, full kitchen, washer & dryer, 24\/7 support, bowling alley, fitness center and more.", + "Description_fr": "Économisez jusqu'à 50% sur les hôtels traditionnels. WiFi gratuit, très bien situé près du centre-ville, cuisine complète, laveuse & sécheuse, support 24\/7, bowling, centre de fitness et plus encore.", + "Category": "Budget", + "Tags": [ + "24-hour front desk service", + "coffee in lobby", + "restaurant" + ], + "ParkingIncluded": false, + "SmokingAllowed": true, + "LastRenovationDate": "1999-09-06T00:00:00Z", + "Rating": 3, + "Address": { + "StreetAddress": "6910 Fayetteville Rd", + "City": "Durham", + "StateProvince": "NC", + "PostalCode": "27713", + "Country": "USA" + }, + "Location": { + "type": "Point", + "coordinates": [ + -78.940483, + 35.904160 + ] + }, + "Rooms": [ + { + "Description": "Suite, 1 King Bed (Amenities)", + "Description_fr": "Suite, 1 très grand lit (Services)", + "Type": "Suite", + "BaseRate": 2.44, + "BedOptions": "1 King Bed", + "SleepsCount": 2, + "SmokingAllowed": true, + "Tags": [ + "coffee maker" + ] + }, + { + "Description": "Budget Room, 1 Queen Bed (Amenities)", + "Description_fr": "Chambre Économique, 1 grand lit (Services)", + "Type": "Budget Room", + "BaseRate": 7.69, + "BedOptions": "1 Queen Bed", + "SleepsCount": 2, + "SmokingAllowed": false, + "Tags": [ + "coffee maker" + ] + } + ] + } +]