Skip to content

Commit

Permalink
Fix method name capitalization and other non-functional changes (#328)
Browse files Browse the repository at this point in the history
* Fix capitalization of method names, and other non-functional improvements

* Fix capitalization of method names, and other non-functional improvements

* Fix black

* Revert breaking change

* Additional change required after merge
  • Loading branch information
yihezkel authored Oct 29, 2023
1 parent 1398520 commit 061818f
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public class KustoOperationResult implements Iterator<KustoResultSetTable> {

public KustoOperationResult(String response, String version) throws KustoServiceQueryError {
MonitoredActivity.invoke((SupplierOneException<Void, KustoServiceQueryError>) () -> {
KustoOperationResultImpl(response, version);
kustoOperationResultImpl(response, version);
return null;
}, "KustoOperationResult.createFromResponse");
it = resultTables.iterator();
}

private void KustoOperationResultImpl(String response, String version) throws KustoServiceQueryError {
private void kustoOperationResultImpl(String response, String version) throws KustoServiceQueryError {
if (version.contains("v2")) {
createFromV2Response(response);
} else {
Expand Down Expand Up @@ -89,7 +89,7 @@ private void createFromV1Response(String response) throws KustoServiceQueryError
throw new JsonPropertyMissingException("Tables Property missing from V1 response json");
}
} catch (JsonProcessingException | JsonPropertyMissingException e) {
log.error("Json processing error occured while parsing string to json with exception", e);
log.error("Json processing error occurred while parsing string to json with exception", e);
throw new KustoServiceQueryError("Json processing error occurred while parsing string to json with exception " + e.getMessage());
}

Expand Down Expand Up @@ -129,7 +129,7 @@ private void createFromV2Response(String response) throws KustoServiceQueryError
throw new JsonPropertyMissingException("There is no array in the response which can be parsed");
}
} catch (JsonProcessingException | JsonPropertyMissingException jsonException) {
log.error("Json processing error occured while parsing string to json with exception", jsonException);
log.error("Json processing error occurred while parsing string to json with exception", jsonException);
throw new KustoServiceQueryError(
"Json processing error occurred while parsing string to json with exception " + jsonException.getMessage());
} catch (NullPointerException nullPointerException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;

public class KustoDateTimeTest {

class KustoDateTimeTest {
@Test
void KustoResultSet() throws Exception {
void kustoResultSet() throws Exception {
ObjectMapper mapper = Utils.getObjectMapper();
DateTimeFormatter kustoDateTimeFormatter = new DateTimeFormatterBuilder().parseCaseInsensitive()
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME).appendLiteral('Z').toFormatter();
Expand Down Expand Up @@ -54,7 +53,7 @@ void KustoResultSet() throws Exception {
"\"Columns\":" + columns + ",\"Rows\":" +
rows + "}"));

Integer rowNum = 0;
int rowNum = 0;
while (res.next()) {
Assertions.assertEquals(
LocalDateTime.parse(rows.get(rowNum).get(0).toString(), kustoDateTimeFormatter),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ void setUp() throws IOException {
}

@Test
void WhenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenClose_ThenInnerStreamIsNotClosed() throws IOException {
stream.close();
verify(stream.getInnerStream(), never()).close();
}

@Test
void WhenReadThenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenReadThenClose_ThenInnerStreamIsNotClosed() throws IOException {
int amount = 3;
byte[] buffer = new byte[amount];
int read = stream.read(buffer);
Expand All @@ -52,7 +52,7 @@ void WhenReadThenClose_ThenInnerStreamIsNotClosed() throws IOException {
}

@Test
void WhenSkipThenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenSkipThenClose_ThenInnerStreamIsNotClosed() throws IOException {
int amount = 3;

int skipped = (int) stream.skip(amount);
Expand All @@ -73,7 +73,7 @@ void WhenSkipThenClose_ThenInnerStreamIsNotClosed() throws IOException {
}

@Test
void WhenAvailableThenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenAvailableThenClose_ThenInnerStreamIsNotClosed() throws IOException {
int total = bytes.length;

assertEquals(total, stream.available());
Expand All @@ -98,7 +98,7 @@ void WhenAvailableThenClose_ThenInnerStreamIsNotClosed() throws IOException {
}

@Test
void WhenResetThenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenResetThenClose_ThenInnerStreamIsNotClosed() throws IOException {
int amount = 3;
byte[] buffer = new byte[amount];
int read = stream.read(buffer);
Expand All @@ -122,7 +122,7 @@ void WhenResetThenClose_ThenInnerStreamIsNotClosed() throws IOException {
}

@Test
void WheMarkThenClose_ThenInnerStreamIsNotClosed() throws IOException {
void whenMarkThenClose_ThenInnerStreamIsNotClosed() throws IOException {
int amount = 3;
byte[] buffer = new byte[amount];
int read = stream.read(buffer);
Expand All @@ -148,7 +148,7 @@ void WheMarkThenClose_ThenInnerStreamIsNotClosed() throws IOException {
}

@Test
void TestMarkSupported_MatchesInnerMarkSupported() throws IOException {
void testMarkSupported_MatchesInnerMarkSupported() throws IOException {
assertEquals(stream.markSupported(), stream.getInnerStream().markSupported());
stream.close();
assertEquals(stream.markSupported(), stream.getInnerStream().markSupported());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.azure.data.tables.TableClient;
import com.azure.data.tables.models.TableEntity;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import com.azure.storage.queue.QueueClient;
import com.microsoft.azure.kusto.data.Ensure;
import com.microsoft.azure.kusto.ingest.source.CompressionType;
import com.microsoft.azure.kusto.ingest.utils.IngestionUtils;
Expand All @@ -15,10 +17,10 @@
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;

import static com.microsoft.azure.kusto.ingest.IngestClientBase.shouldCompress;
Expand Down Expand Up @@ -57,36 +59,37 @@ void uploadLocalFileToBlob(File file, String blobName, String storageUri, Ingest
}

@Test
void PostMessageToQueue_NullQueuePath_IllegalArgumentException() {
void postMessageToQueue_NullQueuePath_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.postMessageToQueue(null, "content"));
}

@Test
void PostMessageToQueue_NullContent_IllegalArgumentException() {
void postMessageToQueue_NullContent_IllegalArgumentException() {
QueueClient queue = TestUtils.queueWithSasFromQueueName("queue1").getQueue();
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.postMessageToQueue(TestUtils.queueWithSasFromQueueName("queue1").getQueue(), null));
() -> azureStorageClient.postMessageToQueue(queue, null));
}

@Test
void PostMessageToQueue_NullEntity_IllegalArgumentException() {
void postMessageToQueue_NullEntity_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.azureTableInsertEntity(mock(TableClient.class), null));
}

@Test
void PostMessageToQueue_NullTableUri_IllegalArgumentException() {
void postMessageToQueue_NullTableUri_IllegalArgumentException() {
TableEntity serviceEntity = mock(TableEntity.class);
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.azureTableInsertEntity(null, serviceEntity));
}

@Test
void UploadLocalFileToBlob_UncompressedFile_CompressAndUploadFileToBlobIsCalled()
void uploadLocalFileToBlob_UncompressedFile_CompressAndUploadFileToBlobIsCalled()
throws IOException {
doNothing().when(azureStorageClientSpy).compressAndUploadFileToBlob(any(File.class), any(BlobClient.class));

Expand All @@ -96,7 +99,7 @@ void UploadLocalFileToBlob_UncompressedFile_CompressAndUploadFileToBlobIsCalled(
}

@Test
void UploadLocalFileToBlob_CompressedFile_UploadFileToBlobIsCalled()
void uploadLocalFileToBlob_CompressedFile_UploadFileToBlobIsCalled()
throws IOException {
doNothing().when(azureStorageClientSpy).uploadFileToBlob(any(File.class), any(BlobClient.class));

Expand All @@ -106,38 +109,38 @@ void UploadLocalFileToBlob_CompressedFile_UploadFileToBlobIsCalled()
}

@Test
void UploadLocalFileToBlob_NullFilePath_IllegalArgumentException() {
void uploadLocalFileToBlob_NullFilePath_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> uploadLocalFileToBlob(null, "blobName", "storageUri", IngestionProperties.DataFormat.CSV));
}

@Test
void UploadLocalFileToBlob_NullBlobName_IllegalArgumentException() {
void uploadLocalFileToBlob_NullBlobName_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> uploadLocalFileToBlob(testFile, null, "storageUri", IngestionProperties.DataFormat.CSV));
}

@Test
void UploadLocalFileToBlob_NullStorageUri_IllegalArgumentException() {
void uploadLocalFileToBlob_NullStorageUri_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> uploadLocalFileToBlob(testFile, "blobName", null, IngestionProperties.DataFormat.CSV));
}

@Test
void UploadLocalFileToBlob_FileDoesNotExist_IOException() {
void uploadLocalFileToBlob_FileDoesNotExist_IOException() {
File notExistingFile = new File("not.existing.file.path");
assertThrows(
IOException.class,
() -> uploadLocalFileToBlob(notExistingFile, "blobName", "storageUri", IngestionProperties.DataFormat.CSV));
}

@Test
void UploadStreamToBlob_NotCompressMode_UploadStreamIsCalled()
void uploadStreamToBlob_NotCompressMode_UploadStreamIsCalled()
throws IOException, URISyntaxException {
try (InputStream stream = new FileInputStream(testFilePath)) {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
doNothing().when(azureStorageClientSpy).uploadStream(any(InputStream.class), any(BlobClient.class));

azureStorageClientSpy.uploadStreamToBlob(stream, "blobName",
Expand All @@ -147,9 +150,9 @@ void UploadStreamToBlob_NotCompressMode_UploadStreamIsCalled()
}

@Test
void UploadStreamToBlob_CompressMode_CompressAndUploadStreamIsCalled()
void uploadStreamToBlob_CompressMode_CompressAndUploadStreamIsCalled()
throws IOException, URISyntaxException {
try (InputStream stream = new FileInputStream(testFilePath)) {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
doNothing().when(azureStorageClientSpy)
.compressAndUploadStream(any(InputStream.class), any(BlobClient.class));
azureStorageClientSpy.uploadStreamToBlob(stream, "blobName",
Expand All @@ -160,86 +163,87 @@ void UploadStreamToBlob_CompressMode_CompressAndUploadStreamIsCalled()

@Test
void UploadStreamToBlob_NullInputStream_IllegalArgumentException() {
BlobContainerClient container = new BlobContainerClientBuilder().endpoint("https://blobPath.blob.core.windows.net/container/blob").buildClient();
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadStreamToBlob(null, "blobName", new BlobContainerClientBuilder().endpoint("storageUrl").buildClient(), false));

() -> azureStorageClient.uploadStreamToBlob(null, "blobName", container, false));
}

@Test
void UploadStreamToBlob_NullBlobName_IllegalArgumentException() throws IOException {
try (InputStream stream = new FileInputStream(testFilePath)) {
void uploadStreamToBlob_NullBlobName_IllegalArgumentException() throws IOException {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
BlobContainerClient storageUrl = new BlobContainerClientBuilder().endpoint("https://blobPath.blob.core.windows.net/container/blob").buildClient();
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadStreamToBlob(stream, null, new BlobContainerClientBuilder().endpoint("storageUrl").buildClient(), false));
() -> azureStorageClient.uploadStreamToBlob(stream, null, storageUrl, false));
}
}

@Test
void UploadStreamToBlob_NullStorageUri_IllegalArgumentException() throws IOException {
try (InputStream stream = new FileInputStream(testFilePath)) {
void uploadStreamToBlob_NullStorageUri_IllegalArgumentException() throws IOException {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadStreamToBlob(stream, "blobName", null, false));
}
}

@Test
void CompressAndUploadFileToBlob_NullFilePath_IllegalArgumentException() {
void compressAndUploadFileToBlob_NullFilePath_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.compressAndUploadFileToBlob(null, blob));
}

@Test
void CompressAndUploadFileToBlob_NullBlob_IllegalArgumentException() {
void compressAndUploadFileToBlob_NullBlob_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.compressAndUploadFileToBlob(testFile, null));
}

@Test
void UploadFileToBlob_NullSourceFile_IllegalArgumentException() {
void uploadFileToBlob_NullSourceFile_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadFileToBlob(null, blob));
}

@Test
void UploadFileToBlob_NullBlob_IllegalArgumentException() {
void uploadFileToBlob_NullBlob_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadFileToBlob(testFile, null));
}

@Test
void UploadStream_NullInputStream_IllegalArgumentException() {
void uploadStream_NullInputStream_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadStream(null, blob));

}

@Test
void UploadStream_NullBlob_IllegalArgumentException() throws IOException {
try (InputStream stream = new FileInputStream(testFilePath)) {
void uploadStream_NullBlob_IllegalArgumentException() throws IOException {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.uploadStream(stream, null));
}
}

@Test
void CompressAndStream_NullStream_IllegalArgumentException() {
void compressAndStream_NullStream_IllegalArgumentException() {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.compressAndUploadStream(null, blob));

}

@Test
void CompressAndStream_NullBlob_IllegalArgumentException() throws IOException {
try (InputStream stream = new FileInputStream(testFilePath)) {
void compressAndStream_NullBlob_IllegalArgumentException() throws IOException {
try (InputStream stream = Files.newInputStream(Paths.get(testFilePath))) {
assertThrows(
IllegalArgumentException.class,
() -> azureStorageClient.compressAndUploadStream(stream, null));
Expand Down
Loading

0 comments on commit 061818f

Please sign in to comment.