Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed and added Tables unit tests. #22196

Merged
merged 7 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions sdk/tables/azure-data-tables/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ Licensed under the MIT License.
<tag>HEAD</tag>
</scm>

<properties>
<jacoco.skip.coverage.check>true</jacoco.skip.coverage.check>
vcolin7 marked this conversation as resolved.
Show resolved Hide resolved
</properties>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
@ServiceClient(builder = TableServiceClientBuilder.class, isAsync = true)
public final class TableServiceAsyncClient {
private final ClientLogger logger = new ClientLogger(TableServiceAsyncClient.class);
private final SerializerAdapter serializerAdapter;
private final AzureTableImpl implementation;
private final String accountName;
private final HttpPipeline pipeline;
Expand All @@ -88,6 +89,7 @@ public final class TableServiceAsyncClient {
throw logger.logExceptionAsError(ex);
}

this.serializerAdapter = serializerAdapter;
this.implementation = new AzureTableImplBuilder()
.serializerAdapter(serializerAdapter)
.url(url)
Expand Down Expand Up @@ -142,6 +144,15 @@ ClientLogger getLogger() {
return this.logger;
}

/**
* Gets this client's {@link SerializerAdapter}.
*
* @return This client's {@link SerializerAdapter}.
*/
SerializerAdapter getSerializerAdapter() {
vcolin7 marked this conversation as resolved.
Show resolved Hide resolved
return this.serializerAdapter;
}

/**
* Gets the REST API version used by this client.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.credential.AzureNamedKeyCredential;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.data.tables.implementation.AzureTableImpl;
import com.azure.data.tables.implementation.TableUtils;
import com.azure.data.tables.implementation.models.ResponseFormat;
import com.azure.data.tables.implementation.models.TableProperties;
Expand Down Expand Up @@ -73,6 +77,24 @@ public TableServiceVersion getServiceVersion() {
return client.getServiceVersion();
}

/**
* Gets the {@link HttpPipeline} powering this client.
*
* @return This client's {@link HttpPipeline}.
*/
HttpPipeline getHttpPipeline() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is not required.

return client.getHttpPipeline();
}

/**
* Gets this client's {@link SerializerAdapter}.
*
* @return This client's {@link SerializerAdapter}.
*/
SerializerAdapter getSerializerAdapter() {
return client.getSerializerAdapter();
}

/**
* Generates an account SAS for the Azure Storage account using the specified
* {@link TableAccountSasSignatureValues}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
package com.azure.data.tables.implementation.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

import java.util.ArrayList;
import java.util.List;

/** Table Service Properties. */
@JacksonXmlRootElement(localName = "StorageServiceProperties")
@Fluent
public final class TableServiceProperties {
/*
Expand All @@ -31,11 +37,20 @@ public final class TableServiceProperties {
@JsonProperty(value = "MinuteMetrics")
private Metrics minuteMetrics;

private static final class CorsWrapper {
@JacksonXmlProperty(localName = "CorsRule")
private final List<CorsRule> items;

@JsonCreator
private CorsWrapper(@JacksonXmlProperty(localName = "CorsRule") List<CorsRule> items) {
this.items = items;
}
}
/*
* The set of CORS rules.
*/
@JsonProperty(value = "Cors")
private List<CorsRule> cors;
private CorsWrapper cors;

/**
* Get the logging property: Azure Analytics Logging settings.
Expand Down Expand Up @@ -103,7 +118,11 @@ public TableServiceProperties setMinuteMetrics(Metrics minuteMetrics) {
* @return the cors value.
*/
public List<CorsRule> getCors() {
return this.cors;
if (this.cors == null) {
this.cors = new CorsWrapper(new ArrayList<CorsRule>());
}

return this.cors.items;
}

/**
Expand All @@ -113,7 +132,8 @@ public List<CorsRule> getCors() {
* @return the TableServiceProperties object itself.
*/
public TableServiceProperties setCors(List<CorsRule> cors) {
this.cors = cors;
this.cors = new CorsWrapper(cors);

return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

/** Stats for the service. */
@JacksonXmlRootElement(localName = "StorageServiceStats")
@Fluent
public final class TableServiceStats {
vcolin7 marked this conversation as resolved.
Show resolved Hide resolved
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void createEntityWithAllSupportedDataTypesAsync() {
StepVerifier.create(tableClient.getEntityWithResponse(partitionKeyValue, rowKeyValue, null))
.assertNext(response -> {
final TableEntity entity = response.getValue();
Map<String, Object> properties = entity.getProperties();
final Map<String, Object> properties = entity.getProperties();
assertTrue(properties.get("BinaryTypeProperty") instanceof byte[]);
assertTrue(properties.get("BooleanTypeProperty") instanceof Boolean);
assertTrue(properties.get("DateTypeProperty") instanceof OffsetDateTime);
Expand Down Expand Up @@ -493,7 +493,7 @@ void getEntityWithResponseSubclassAsync() {
String s = "Test";
SampleEntity.Color color = SampleEntity.Color.GREEN;

Map<String, Object> props = new HashMap<>();
final Map<String, Object> props = new HashMap<>();
props.put("ByteField", bytes);
props.put("BooleanField", b);
props.put("DateTimeField", dateTime);
Expand Down Expand Up @@ -607,7 +607,7 @@ void updateEntityWithResponseSubclassAsync() {

StepVerifier.create(tableClient.getEntity(partitionKeyValue, rowKeyValue))
.assertNext(entity -> {
Map<String, Object> properties = entity.getProperties();
final Map<String, Object> properties = entity.getProperties();
assertTrue(properties.containsKey("SubclassProperty"));
assertEquals("UpdatedValue", properties.get("SubclassProperty"));
})
Expand Down
Loading