lordgamez commented on a change in pull request #979:
URL: https://github.com/apache/nifi-minifi-cpp/pull/979#discussion_r584878208



##########
File path: libminifi/test/azure-tests/PutAzureBlobStorageTests.cpp
##########
@@ -0,0 +1,288 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../TestBase.h"
+#include "core/Processor.h"
+#include "processors/PutAzureBlobStorage.h"
+#include "processors/GetFile.h"
+#include "processors/LogAttribute.h"
+#include "processors/UpdateAttribute.h"
+#include "storage/BlobStorage.h"
+#include "utils/file/FileUtils.h"
+
+const std::string CONTAINER_NAME = "test-container";
+const std::string STORAGE_ACCOUNT_NAME = "test-account";
+const std::string STORAGE_ACCOUNT_KEY = "test-key";
+const std::string SAS_TOKEN = "test-sas-token";
+const std::string ENDPOINT_SUFFIX = "test.suffix.com";
+const std::string CONNECTION_STRING = "test-connectionstring";
+const std::string BLOB_NAME = "test-blob.txt";
+const std::string TEST_DATA = "data";
+
+class MockBlobStorage : public minifi::azure::storage::BlobStorage {
+ public:
+  const std::string ETAG = "test-etag";
+  const std::string PRIMARY_URI = "test-uri";
+  const std::string TEST_TIMESTAMP = "test-timestamp";
+
+  MockBlobStorage()
+    : BlobStorage("", "") {
+  }
+
+  void createContainer() override {
+    container_created_ = true;
+  }
+
+  void resetClientIfNeeded(const std::string &connection_string, const 
std::string &container_name) override {
+    connection_string_ = connection_string;
+    container_name_ = container_name;
+  }
+
+  utils::optional<minifi::azure::storage::UploadBlobResult> uploadBlob(const 
std::string &blob_name, const uint8_t* buffer, std::size_t buffer_size) 
override {
+    input_data = std::string(buffer, buffer + buffer_size);
+    minifi::azure::storage::UploadBlobResult result;
+    result.etag = ETAG;
+    result.length = buffer_size;
+    result.primary_uri = PRIMARY_URI;
+    result.timestamp = TEST_TIMESTAMP;
+    return result;
+  }
+
+  std::string getConnectionString() const {
+    return connection_string_;
+  }
+
+  std::string getContainerName() const {
+    return container_name_;
+  }
+
+  bool getContainerCreated() const {
+    return container_created_;
+  }
+
+  std::string input_data;
+
+ private:
+  bool container_created_ = false;
+};
+
+class PutAzureBlobStorageTestsFixture {
+ public:
+  PutAzureBlobStorageTestsFixture() {
+    LogTestController::getInstance().setDebug<TestPlan>();
+    LogTestController::getInstance().setDebug<minifi::core::Processor>();
+    LogTestController::getInstance().setTrace<minifi::core::ProcessSession>();
+    LogTestController::getInstance().setTrace<processors::GetFile>();
+    LogTestController::getInstance().setDebug<processors::UpdateAttribute>();
+    LogTestController::getInstance().setDebug<processors::LogAttribute>();
+    
LogTestController::getInstance().setTrace<minifi::azure::processors::PutAzureBlobStorage>();
+
+    // Build MiNiFi processing graph
+    plan = test_controller.createPlan();
+    mock_blob_storage_ptr = new MockBlobStorage();
+    std::unique_ptr<minifi::azure::storage::BlobStorage> 
mock_blob_storage(mock_blob_storage_ptr);

Review comment:
       Unfortunately make_unique only works with constructor parameters, but 
does not work with an existing object.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to