From e0f399ac42104bf08c90c5d2418eb106ea2dd10f Mon Sep 17 00:00:00 2001
From: Dominik Gleich <dominik.gleich@memgraph.io>
Date: Tue, 21 Feb 2017 15:37:32 +0100
Subject: [PATCH] Fix manual query engine config and paths.

Test Plan: In progress.

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D55
---
 tests/data/queries/core/mg_basic_002.txt      |  1 +
 .../hardcoded_query/create_garment.cpp        | 24 +++++++++++++++++++
 tests/integration/query_engine_common.hpp     |  5 +---
 .../stream/print_record_stream.hpp            | 19 +--------------
 tests/manual/query_engine.cpp                 |  4 ++--
 5 files changed, 29 insertions(+), 24 deletions(-)
 create mode 100644 tests/data/queries/core/mg_basic_002.txt
 create mode 100644 tests/integration/hardcoded_query/create_garment.cpp

diff --git a/tests/data/queries/core/mg_basic_002.txt b/tests/data/queries/core/mg_basic_002.txt
new file mode 100644
index 000000000..cde3491d4
--- /dev/null
+++ b/tests/data/queries/core/mg_basic_002.txt
@@ -0,0 +1 @@
+CREATE (n {garment_id: 1234, garment_category_id: 1}) RETURN n;
diff --git a/tests/integration/hardcoded_query/create_garment.cpp b/tests/integration/hardcoded_query/create_garment.cpp
new file mode 100644
index 000000000..b8b2985f2
--- /dev/null
+++ b/tests/integration/hardcoded_query/create_garment.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+#include <string>
+
+#include "query/plan_interface.hpp"
+#include "using.hpp"
+
+using std::cout;
+using std::endl;
+
+// Query: CREATE (n {garment_id: 1234, garment_category_id: 1}) RETURN n;
+
+class CPUPlan : public PlanInterface<Stream> {
+ public:
+  bool run(GraphDbAccessor &db_accessor, const TypedValueStore<> &args,
+           Stream &stream) {
+    return true;
+  }
+
+  ~CPUPlan() {}
+};
+
+extern "C" PlanInterface<Stream> *produce() { return new CPUPlan(); }
+
+extern "C" void destruct(PlanInterface<Stream> *p) { delete p; }
diff --git a/tests/integration/query_engine_common.hpp b/tests/integration/query_engine_common.hpp
index d40760d56..1c882a8ae 100644
--- a/tests/integration/query_engine_common.hpp
+++ b/tests/integration/query_engine_common.hpp
@@ -105,9 +105,6 @@ auto LoadQueryPlans(Logger &log, QueryEngineT &engine,
       break;
     }
   }
-  permanent_assert(query_hashes.size() == engine.Size(),
-                   "Query engine doesn't contain appropriate number of query "
-                   "implementations");
 }
 
 /**
@@ -152,7 +149,7 @@ auto WarmUpEngine(Logger &log, QueryEngineT &engine,
                   GraphDbAccessor &db_accessor, StreamT &stream) {
   // path to a file with queries
   auto queries_file = fs::path(
-      GET_ARG("-q", "../data/queries/core/mg_basic_000.txt").get_string());
+      GET_ARG("-q", "../data/queries/core/mg_basic_002.txt").get_string());
   // forlder with query implementations
   auto implementations_folder =
       fs::path(GET_ARG("-i", "../integration/hardcoded_query").get_string());
diff --git a/tests/integration/stream/print_record_stream.hpp b/tests/integration/stream/print_record_stream.hpp
index e8aaf83ce..286ae385d 100644
--- a/tests/integration/stream/print_record_stream.hpp
+++ b/tests/integration/stream/print_record_stream.hpp
@@ -5,8 +5,6 @@
 #include <string>
 #include <vector>
 
-#include "utils/exceptions/not_yet_implemented.hpp"
-
 class PrintRecordStream {
  private:
   std::ostream &stream;
@@ -43,22 +41,7 @@ class PrintRecordStream {
   }
 
   void write_failure(const std::map<std::string, std::string> &data) {
-    throw NotYetImplemented();
   }
 
-  void write_count(const size_t count) { throw NotYetImplemented(); }
-
-  void write(const VertexAccessor &vertex) { throw NotYetImplemented(); }
-
-  void write_vertex_record(const VertexAccessor &va) {
-    throw NotYetImplemented();
-  }
-
-  void write(const EdgeAccessor &edge) { throw NotYetImplemented(); }
-
-  void write_edge_record(const EdgeAccessor &ea) { throw NotYetImplemented(); }
-
-  void send() { throw NotYetImplemented(); }
-
-  void chunk() { throw NotYetImplemented(); }
+  void write_count(const size_t count) { }
 };
diff --git a/tests/manual/query_engine.cpp b/tests/manual/query_engine.cpp
index 697c97f09..c0ef4f9e0 100644
--- a/tests/manual/query_engine.cpp
+++ b/tests/manual/query_engine.cpp
@@ -18,7 +18,7 @@ int main(int argc, char* argv[]) {
   auto log = init_logging("ManualQueryEngine");
   Dbms dbms;
   auto db_accessor = dbms.active();
-  StreamT stream(std::cout);
+  StreamT stream(std::cout);  // inject path to data queries
   QueryEngineT query_engine;
   // IMPORTANT: PrintRecordStream can be replaces with a smarter
   // object that can test the results
@@ -31,7 +31,7 @@ int main(int argc, char* argv[]) {
 
   int i = 0;
   watcher.watch(
-      WatchDescriptor(implementations_folder, FSEventType::CloseNowrite),
+      WatchDescriptor(implementations_folder, FSEventType::All),
       [&](FSEvent event) {
         i++;  // bacause only close_no_write could be detected and this
         // call will cause close no write again