[GitHub] nifi-minifi-cpp pull request #157: MINIFI-269 Implement ApplyTemplate proces...

2017-10-28 Thread achristianson
Github user achristianson commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/157#discussion_r147565661
  
--- Diff: libminifi/test/bustache-tests/ApplyTemplateTests.cpp ---
@@ -0,0 +1,131 @@
+/**
+ *
+ * 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.
+ */
+#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only 
do this in one cpp file
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../TestBase.h"
+#include "core/Core.h"
+
+#include "core/FlowFile.h"
+#include "core/Processor.h"
+#include "core/ProcessContext.h"
+#include "core/ProcessSession.h"
+#include "core/ProcessorNode.h"
+
+#include "ApplyTemplate.h"
+#include "processors/GetFile.h"
+#include "processors/ExtractText.h"
+
+const char* TEMPLATE = "TemplateBegins\n{{ ExampleAttribute 
}}\nTemplateEnds";
+const char* TEMPLATE_FILE = "test_template.txt";
+const char* TEST_ATTR = "ExampleAttribute";
+const char* TEST_VALUE = "ExampleValue";
+const char* TEST_FILE = "test_file.txt";
+const char* EXPECT_OUTPUT = "TemplateBegins\nExampleValue\nTemplateEnds";
+
+TEST_CASE("Test Creation of ApplyTemplate", "[ApplyTemplateCreate]") {
+TestController testController;
+std::shared_ptr processor = 
std::make_shared("processorname");
+REQUIRE(processor->getName() == "processorname");
+uuid_t processoruuid;
+REQUIRE(true == processor->getUUID(processoruuid));
+}
+
+TEST_CASE("Test usage of ApplyTemplate", "[ApplyTemplateTest]") {
+TestController testController;
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
LogTestController::getInstance().setTrace();
+
+std::shared_ptr plan = testController.createPlan();
+std::shared_ptr repo = 
std::make_shared();
+
+char dir1[] = "/tmp/gt.XX";  // GetFile source
+char dir2[] = "/tmp/gt.XX";  // Template source
+char dir3[] = "/tmp/gt.XX";  // PutFile destionation
+
+REQUIRE(testController.createTempDirectory(dir1) != nullptr);
+REQUIRE(testController.createTempDirectory(dir2) != nullptr);
+REQUIRE(testController.createTempDirectory(dir3) != nullptr);
+
+std::shared_ptr getfile = 
plan->addProcessor("GetFile", "getFile");
+plan->setProperty(getfile, 
org::apache::nifi::minifi::processors::GetFile::Directory.getName(), dir1);
+plan->setProperty(getfile, 
org::apache::nifi::minifi::processors::GetFile::KeepSourceFile.getName(), 
"true");
+
+std::shared_ptr maprocessor = 
plan->addProcessor("ExtractText", "testExtractText", 
core::Relationship("success", "description"), true);
+plan->setProperty(maprocessor, 
org::apache::nifi::minifi::processors::ExtractText::Attribute.getName(), 
TEST_ATTR);
+
+std::shared_ptr atprocessor = 
plan->addProcessor("ApplyTemplate", "testApplyTemplate", 
core::Relationship("success", "description"), true);
+
+std::shared_ptr putfile = 
plan->addProcessor("PutFile", "putfile", core::Relationship("success", 
"description"), true);
+plan->setProperty(putfile, 
org::apache::nifi::minifi::processors::PutFile::Directory.getName(), dir3);
+plan->setProperty(putfile, 
org::apache::nifi::minifi::processors::PutFile::ConflictResolution.getName(),
+  
org::apache::nifi::minifi::processors::PutFile::CONFLICT_RESOLUTION_STRATEGY_REPLACE);
+
+// Write attribute value to file for GetFile->ExtractText
+std::stringstream ss1;
+ss1 << dir1 << "/" << TEST_FILE;
+std::string test_path = 

[GitHub] nifi-minifi-cpp pull request #157: MINIFI-269 Implement ApplyTemplate proces...

2017-10-28 Thread achristianson
Github user achristianson commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/157#discussion_r147565654
  
--- Diff: libminifi/test/bustache-tests/ApplyTemplateTests.cpp ---
@@ -0,0 +1,131 @@
+/**
+ *
+ * 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.
+ */
+#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only 
do this in one cpp file
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../TestBase.h"
+#include "core/Core.h"
+
+#include "core/FlowFile.h"
+#include "core/Processor.h"
+#include "core/ProcessContext.h"
+#include "core/ProcessSession.h"
+#include "core/ProcessorNode.h"
+
+#include "ApplyTemplate.h"
+#include "processors/GetFile.h"
+#include "processors/ExtractText.h"
+
+const char* TEMPLATE = "TemplateBegins\n{{ ExampleAttribute 
}}\nTemplateEnds";
+const char* TEMPLATE_FILE = "test_template.txt";
+const char* TEST_ATTR = "ExampleAttribute";
+const char* TEST_VALUE = "ExampleValue";
+const char* TEST_FILE = "test_file.txt";
+const char* EXPECT_OUTPUT = "TemplateBegins\nExampleValue\nTemplateEnds";
+
+TEST_CASE("Test Creation of ApplyTemplate", "[ApplyTemplateCreate]") {
+TestController testController;
+std::shared_ptr processor = 
std::make_shared("processorname");
+REQUIRE(processor->getName() == "processorname");
+uuid_t processoruuid;
+REQUIRE(true == processor->getUUID(processoruuid));
--- End diff --

Minor nit: simplify to `REQUIRE(processor->getUUID(processoruuid));`


---


[GitHub] nifi-minifi-cpp pull request #157: MINIFI-269 Implement ApplyTemplate proces...

2017-10-27 Thread calebj
GitHub user calebj opened a pull request:

https://github.com/apache/nifi-minifi-cpp/pull/157

MINIFI-269 Implement ApplyTemplate processor

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced
 in the commit message?

- [x] Does your PR title start with MINIFI- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.

- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [x] Is your initial contribution a single, squashed commit?

### For code changes:
- [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [x] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/NiFiLocal/nifi-minifi-cpp ApplyTemplate

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi-minifi-cpp/pull/157.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #157


commit 2913bc1d456adfeb1c6ac58ea91c061b4451e02d
Author: Caleb Johnson 
Date:   2017-10-17T19:13:32Z

MINIFI-269 Implement ApplyTemplate processor




---