[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015549
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015540
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015543
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015527
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
 
 Review comment:
   Remove whitespace



[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015530
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015559
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015507
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,50 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This is a helper class the starts an embedded elasticsearch server for each
 
 Review comment:
   Once you have addressed the comments here fully I will test the code locally 
and provide input as to why it is not working. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015557
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015560
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015483
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/EmbeddedElasticsearchServer.java
 ##
 @@ -0,0 +1,82 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.driver;
+
+import org.apache.commons.io.FileUtils;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeValidationException;
+import org.elasticsearch.transport.Netty3Plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * embedded elasticsearch server.
+ */
+public class EmbeddedElasticsearchServer {
+
+  private static final String DEFAULT_DATA_DIRECTORY = 
"target/elasticsearch-data";
+
+  private Node node;
+  private final String dataDirectory;
+
+  public EmbeddedElasticsearchServer() {
+this(DEFAULT_DATA_DIRECTORY);
+  }
+
+  public EmbeddedElasticsearchServer(String dataDirectory) {
+this.dataDirectory = dataDirectory;
+
+Settings.Builder settingsBuilder = Settings.builder();
+settingsBuilder.put("http.type", "netty3");
+settingsBuilder.put("transport.type", "netty3");
+settingsBuilder.put("cluster.name", "MurdorES").put("http.enabled", 
"false").put("path.data", dataDirectory).put("path.home", "/");
+
+Settings settings = settingsBuilder.build();
+Collection plugins = Arrays.asList(Netty3Plugin.class);
+node = null;
+try {
+  node = new PluginConfigurableNode(settings, plugins).start();
+  System.out.println(node.toString());
+} catch (NodeValidationException e) {
+  // TODO Auto-generated catch block
+  e.printStackTrace();
+}
+
+System.out.println(node.getNodeEnvironment().nodeId());
+  }
+
+  public Client getClient() {
+return node.client();
+  }
+
+  public void shutdown() {
 
 Review comment:
   Remove this method if it has no content and you are not overriding anything.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015520
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
 
 Review comment:
   Remove whitespace


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015534
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015405
 
 

 ##
 File path: core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
 ##
 @@ -391,12 +391,12 @@ public static void main(String[] args) {
   me.end();
 } catch (Exception e) {
   HelpFormatter formatter = new HelpFormatter();
-  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", true);
+  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", options, true);
 
 Review comment:
   OK what I am saying is that this code should be changed to the following
   ```
   } catch (Exception e) {
 throw new RuntimeException(e)
   }
   ```
   ...or something similar.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015553
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015519
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
 
 Review comment:
   Remove whitespace


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015545
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015449
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
 
 Review comment:
   This still needs to be addressed using the ClassLoader. Something like
   ```
   getClass().getClassLoader().getResource... or getResourceAsStream...
   ```
   You need to make this change rather than passing around File objects OK.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015576
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/log/GeoIpTest.java
 ##
 @@ -0,0 +1,18 @@
+package org.apache.sdap.mudrod.weblog.structure.log;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GeoIpTest {
+
+   @Test
+   public void testToLocation() {
+   GeoIp ip = new GeoIp();
+   String iptest = "185.10.104.194";
+   Coordinates result = ip.toLocation(iptest);
+   Assert.assertEquals("failed in geoip function!", 
"22.283001,114.150002", result.latlon);
+   }
+
+}
 
 Review comment:
   You have not addressed this issue. The files should not be in the compressed 
form... you need to decompress them. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-08 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r240015539
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,265 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+es.destroyBulkProcessor();
+es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+customlist.add("string_b");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239542280
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,312 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// es.destroyBulkProcessor();
+// es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239539235
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,139 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.discoveryengine;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
+// TODO compare clickStream data
 
 Review comment:
   Remove comments or else address TODO


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239540790
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/EmbeddedElasticsearchServer.java
 ##
 @@ -0,0 +1,82 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.driver;
+
+import org.apache.commons.io.FileUtils;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeValidationException;
+import org.elasticsearch.transport.Netty3Plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * embedded elasticsearch server.
+ */
+public class EmbeddedElasticsearchServer {
+
+  private static final String DEFAULT_DATA_DIRECTORY = 
"target/elasticsearch-data";
+
+  private Node node;
+  private final String dataDirectory;
+
+  public EmbeddedElasticsearchServer() {
+this(DEFAULT_DATA_DIRECTORY);
+  }
+
+  public EmbeddedElasticsearchServer(String dataDirectory) {
+this.dataDirectory = dataDirectory;
+
+Settings.Builder settingsBuilder = Settings.builder();
+settingsBuilder.put("http.type", "netty3");
+settingsBuilder.put("transport.type", "netty3");
+settingsBuilder.put("cluster.name", "MurdorES").put("http.enabled", 
"false").put("path.data", dataDirectory).put("path.home", "/");
+
+Settings settings = settingsBuilder.build();
+Collection plugins = Arrays.asList(Netty3Plugin.class);
+node = null;
+try {
+  node = new PluginConfigurableNode(settings, plugins).start();
+  System.out.println(node.toString());
+} catch (NodeValidationException e) {
+  // TODO Auto-generated catch block
+  e.printStackTrace();
+}
+
+System.out.println(node.getNodeEnvironment().nodeId());
+  }
+
+  public Client getClient() {
+return node.client();
+  }
+
+  public void shutdown() {
 
 Review comment:
   If you are not using the content of this method... remove it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239542736
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/TestMudrodEngine.java
 ##
 @@ -23,9 +23,9 @@
 import org.junit.Test;
 
 /**
- * Initial test case for {@link org.apache.sdap.mudrod.main.MudrodEngine}, 
currently no 
- * tests are implemented, this is merely in place to get the JaCoCo test 
reporting to
- * work.
+ * Initial test case for {@link org.apache.sdap.mudrod.main.MudrodEngine},
+ * currently no tests are implemented, this is merely in place to get the 
JaCoCo
 
 Review comment:
   If no tests are implemented then this is a TODO and a JIRA issue should be 
logged such that someone knows that a test needs to be written.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239538581
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
 
 Review comment:
   You need to address this. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239540539
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/EmbeddedElasticsearchServer.java
 ##
 @@ -0,0 +1,82 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.driver;
+
+import org.apache.commons.io.FileUtils;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeValidationException;
+import org.elasticsearch.transport.Netty3Plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * embedded elasticsearch server.
+ */
+public class EmbeddedElasticsearchServer {
+
+  private static final String DEFAULT_DATA_DIRECTORY = 
"target/elasticsearch-data";
+
+  private Node node;
+  private final String dataDirectory;
+
+  public EmbeddedElasticsearchServer() {
+this(DEFAULT_DATA_DIRECTORY);
+  }
+
+  public EmbeddedElasticsearchServer(String dataDirectory) {
+this.dataDirectory = dataDirectory;
+
+Settings.Builder settingsBuilder = Settings.builder();
+settingsBuilder.put("http.type", "netty3");
+settingsBuilder.put("transport.type", "netty3");
+settingsBuilder.put("cluster.name", "MurdorES").put("http.enabled", 
"false").put("path.data", dataDirectory).put("path.home", "/");
+
+Settings settings = settingsBuilder.build();
+Collection plugins = Arrays.asList(Netty3Plugin.class);
+node = null;
+try {
+  node = new PluginConfigurableNode(settings, plugins).start();
+  System.out.println(node.toString());
+} catch (NodeValidationException e) {
+  // TODO Auto-generated catch block
 
 Review comment:
   Remove TODO


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239541940
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,312 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// es.destroyBulkProcessor();
+// es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239541715
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,50 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This is a helper class the starts an embedded elasticsearch server for each
+ * test.
+ *
+ * @author Felix Müller
+ */
+public abstract class AbstractElasticsearchIntegrationTest {
+
+  private static EmbeddedElasticsearchServer embeddedElasticsearchServer;
+
+  @BeforeClass
+  public static void startEmbeddedElasticsearchServer() {
+embeddedElasticsearchServer = new EmbeddedElasticsearchServer();
+  }
+
+  @AfterClass
+  public static void shutdownEmbeddedElasticsearchServer() {
+// embeddedElasticsearchServer.shutdown();
 
 Review comment:
   Why are you not shutting the server down? If you are not doing so then you 
need to remove this method. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239542355
 
 

 ##
 File path: core/src/test/java/org/apache/sdap/mudrod/main/ESDriverTest.java
 ##
 @@ -0,0 +1,312 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.action.bulk.BulkProcessor;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+
+public class ESDriverTest extends AbstractElasticsearchIntegrationTest {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ESDriver.class);
+  protected static final String ES_SETTINGS = "elastic_settings.json";
+  protected static final String ES_MAPPINGS = "elastic_mappings.json";
+
+  static ESDriver es = null;
+  static MudrodEngine mudrodEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+mudrodEngine = new MudrodEngine();
+es = new ESDriver(mudrodEngine.loadConfig());
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// es.destroyBulkProcessor();
+// es.close();
+  }
+
+  @Test
+  public void testESDriverProperties() {
+
+Client client = es.getClient();
+assert client != null;
+  }
+
+  @Test
+  public void testCreateBulkProcessor() {
+es.createBulkProcessor();
+BulkProcessor processor = es.getBulkProcessor();
+assert processor != null;
+  }
+
+  @Test
+  public void testDestroyBulkProcessor() {
+es.createBulkProcessor();
+es.destroyBulkProcessor();
+
+BulkProcessor processor = es.getBulkProcessor();
+assert processor == null;
+  }
+
+  @Test
+  public void testPutMapping() {
+
+InputStream settingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_SETTINGS);
+InputStream mappingsStream = 
getClass().getClassLoader().getResourceAsStream(ES_MAPPINGS);
+
+JSONObject settingsJSON = null;
+JSONObject mappingJSON = null;
+
+Properties props = mudrodEngine.loadConfig();
+try {
+  settingsJSON = new JSONObject(IOUtils.toString(settingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch settings!", e1);
+}
+
+try {
+  mappingJSON = new JSONObject(IOUtils.toString(mappingsStream));
+} catch (JSONException | IOException e1) {
+  LOG.error("Error reading Elasticsearch mappings!", e1);
+}
+
+try {
+  if (settingsJSON != null && mappingJSON != null) {
+es.putMapping(props.getProperty(MudrodConstants.ES_INDEX_NAME), 
settingsJSON.toString(), mappingJSON.toString());
+  }
+} catch (IOException e) {
+  LOG.error("Error entering Elasticsearch Mappings!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringString() {
+
+String str = "temp";
+try {
+  String res = es.customAnalyzing("mudrod", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringStringString() {
+String str = "temp";
+
+try {
+  String res = es.customAnalyzing("mudrod", "cody", str);
+  assert res != "";
+  assert res != null;
+} catch (InterruptedException | ExecutionException e) {
+  LOG.error("Error!", e);
+}
+  }
+
+  @Test
+  public void testCustomAnalyzingStringListOfString() {
+
+List customlist = new ArrayList<>();
+customlist.add("string_a");
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239539469
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,139 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.discoveryengine;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
+// TODO compare clickStream data
+// String clickStreamcsvFile =
+// 
"C:/Users/admin/Documents/GitHub/incubator-sdap-mudrod/core/clickStreamMatrix.csv";
 
 Review comment:
   Never, ever, ever use path's to your local machine in code. This is a huge 
No-go. Remove this. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239539163
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
 
 Review comment:
   The issue is the same here. Change ```testPreprocess_clickStream``` to 
```testPreprocessClickStream```


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239538180
 
 

 ##
 File path: core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
 ##
 @@ -391,12 +391,12 @@ public static void main(String[] args) {
   me.end();
 } catch (Exception e) {
   HelpFormatter formatter = new HelpFormatter();
-  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", true);
+  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", options, true);
   LOG.error("Error whilst parsing command line.", e);
 }
   }
 
-  private static void loadPathConfig(MudrodEngine me, String dataDir) {
+  public static void loadPathConfig(MudrodEngine me, String dataDir) {
 
 Review comment:
   OK thanks.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239539629
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,139 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.discoveryengine;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
+// TODO compare clickStream data
+// String clickStreamcsvFile =
+// 
"C:/Users/admin/Documents/GitHub/incubator-sdap-mudrod/core/clickStreamMatrix.csv";
+String clickStreamcsvFile = getTestDataPath() + "/clickStreamMatrix.csv";
+System.out.println(clickStreamcsvFile);
+BufferedReader br = new BufferedReader(new FileReader(clickStreamcsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
 
 Review comment:
   If all of this code is duplicated, then factor it out and provide method 
parameters for the input data.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239538820
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
 
 Review comment:
   Additionally, ```testPreprocess_userHistory``` is not how to write Java 
methods. Please use camelCase as is shown elsewhere throughout the codebase. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239541079
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/PluginConfigurableNode.java
 ##
 @@ -0,0 +1,27 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.driver;
+
+import java.util.Collection;
+
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.internal.InternalSettingsPreparer;
+import org.elasticsearch.plugins.Plugin;
+
+public class PluginConfigurableNode extends Node {
+  public PluginConfigurableNode(Settings settings, Collection> classpathPlugins) {
+super(InternalSettingsPreparer.prepareEnvironment(settings, null), 
classpathPlugins);
 
 Review comment:
   What is this code doing?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239541560
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,50 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.main;
+
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This is a helper class the starts an embedded elasticsearch server for each
 
 Review comment:
   We do not need to start a new server for every test. We need to start one 
server which runs for the duration of the tests. Between tests, the data within 
the server should probably be deleted/truncated. This however depends on what 
tests you are running. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239538277
 
 

 ##
 File path: 
core/src/main/java/org/apache/sdap/mudrod/weblog/pre/SessionStatistic.java
 ##
 @@ -229,7 +229,7 @@ public int processSession(ESDriver es, String sessionId) 
throws IOException, Int
   String[] keywordList = keywords.split(",");
   for (String item : items) {
 if (!Arrays.asList(keywordList).contains(item)) {
-  keywords = keywords + item + ",";
+  keywords = keywords + "," + item + ",";
 
 Review comment:
   OK thanks is this included in a test?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239538351
 
 

 ##
 File path: 
core/src/main/java/org/apache/sdap/mudrod/weblog/structure/session/SessionTree.java
 ##
 @@ -205,7 +208,8 @@ public JsonObject treeToJson(SessionNode node) {
   RequestUrl requestURL = new RequestUrl();
   String viewquery = "";
   try {
-String infoStr = requestURL.getSearchInfo(viewnode.getRequest());
+//String infoStr = requestURL.getSearchInfo(viewnode.getRequest());
 
 Review comment:
   You need to resolve this.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239540151
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,139 @@
+/*
+ * Licensed 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.
+ */
+package org.apache.sdap.mudrod.discoveryengine;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
+// TODO compare clickStream data
+// String clickStreamcsvFile =
+// 
"C:/Users/admin/Documents/GitHub/incubator-sdap-mudrod/core/clickStreamMatrix.csv";
+String clickStreamcsvFile = getTestDataPath() + "/clickStreamMatrix.csv";
+System.out.println(clickStreamcsvFile);
+BufferedReader br = new BufferedReader(new FileReader(clickStreamcsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0.0")) { //
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+System.out.println(map);
+
+

[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239541170
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,37 @@
+package org.apache.sdap.mudrod.main;
+
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This is a helper class the starts an embedded elasticsearch server
+ * for each test.
+ *
+ * @author Felix Müller
 
 Review comment:
   ???


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239537668
 
 

 ##
 File path: core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
 ##
 @@ -391,12 +391,12 @@ public static void main(String[] args) {
   me.end();
 } catch (Exception e) {
   HelpFormatter formatter = new HelpFormatter();
-  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", true);
+  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", options, true);
 
 Review comment:
   @quintinali please address this. It should not throw help. It should through 
the ```Exception e```


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-12-06 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r239543206
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/log/GeoIpTest.java
 ##
 @@ -0,0 +1,18 @@
+package org.apache.sdap.mudrod.weblog.structure.log;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GeoIpTest {
+
+   @Test
+   public void testToLocation() {
+   GeoIp ip = new GeoIp();
+   String iptest = "185.10.104.194";
+   Coordinates result = ip.toLocation(iptest);
+   Assert.assertEquals("failed in geoip function!", 
"22.283001,114.150002", result.latlon);
+   }
+
+}
 
 Review comment:
   core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/FTP.201502.w1.gz and
   core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/WWW.201502.w1.gz


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033346
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
 
 Review comment:
   Also, you should always document your tests.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033834
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/PluginConfigurableNode.java
 ##
 @@ -0,0 +1,14 @@
+package org.apache.sdap.mudrod.driver;
 
 Review comment:
   License header


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033850
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/driver/PluginConfigurableNode.java
 ##
 @@ -0,0 +1,14 @@
+package org.apache.sdap.mudrod.driver;
 
 Review comment:
   What is this even doing?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033357
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
+// compare user history data
+String userHistorycsvFile = getTestDataPath() + "/userHistoryMatrix.csv";
+BufferedReader br = new BufferedReader(new FileReader(userHistorycsvFile));
+String line = null;
+HashMap> map = new HashMap<>();
+int i = 0;
+List header = new LinkedList<>();
+while ((line = br.readLine()) != null) {
+  if (i == 0) {
+String str[] = line.split(",");
+for (String s : str) {
+  header.add(s);
+}
+  } else {
+String str[] = line.split(",");
+for (int j = 1; j < str.length; j++) {
+  if (!str[j].equals("0")) {
+if (!map.containsKey(str[0])) {
+  map.put(str[0], new ArrayList<>());
+}
+map.get(str[0]).add(header.get(j));
+  }
+}
+  }
+  i += 1;
+}
+
+Assert.assertEquals("failed in history data result!", "195.219.98.7", 
String.join(",", map.get("sea surface topography")));
+  }
+
+  private void testPreprocess_clickStream() throws IOException {
 
 Review comment:
   Document test.


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238034514
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/log/GeoIpTest.java
 ##
 @@ -0,0 +1,18 @@
+package org.apache.sdap.mudrod.weblog.structure.log;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GeoIpTest {
+
+   @Test
+   public void testToLocation() {
+   GeoIp ip = new GeoIp();
+   String iptest = "185.10.104.194";
+   Coordinates result = ip.toLocation(iptest);
+   Assert.assertEquals("failed in geoip function!", 
"22.283001,114.150002", result.latlon);
+   }
+
+}
 
 Review comment:
   We cannot ship binary code inside of source code management... the resources 
below should be decompressed.  


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033924
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,37 @@
+package org.apache.sdap.mudrod.main;
+
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.apache.sdap.mudrod.driver.EmbeddedElasticsearchServer;
+import org.elasticsearch.client.Client;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * This is a helper class the starts an embedded elasticsearch server
+ * for each test.
+ *
+ * @author Felix Müller
 
 Review comment:
   Who is Felix Muller?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238032419
 
 

 ##
 File path: 
core/src/main/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngine.java
 ##
 @@ -105,7 +105,7 @@ public void preprocess() {
   startTime = System.currentTimeMillis();
   LOG.info("Processing logs dated {}", anInputList);
 
-  DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, 
this.spark);
+ /* DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, 
this.spark);
 
 Review comment:
   OK, the issue SDAP-161 is described as being **MUDROD embedded unit test** 
there should therefore be no code other than en embedded Unit test...


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033243
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
+String resourcedir = "/Testing_Data_1_3dayLog+Meta+Onto/";
+String dataDir = resourcesDirectory.getAbsolutePath() + resourcedir;
+return dataDir;
+  }
+
+  @Test
+  public void testPreprocess() throws IOException {
+
+weblogEngine.preprocess();
+testPreprocess_userHistory();
+testPreprocess_clickStream();
+  }
+
+  private void testPreprocess_userHistory() throws IOException {
 
 Review comment:
   Tests in JUnit are annotated with @Test. See 
https://junit.org/junit4/javadoc/latest/index.html?org/junit/Test.html


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238034551
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/log/GeoIpTest.java
 ##
 @@ -0,0 +1,18 @@
+package org.apache.sdap.mudrod.weblog.structure.log;
+
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GeoIpTest {
+
+   @Test
+   public void testToLocation() {
+   GeoIp ip = new GeoIp();
+   String iptest = "185.10.104.194";
+   Coordinates result = ip.toLocation(iptest);
+   Assert.assertEquals("failed in geoip function!", 
"22.283001,114.150002", result.latlon);
+   }
+
+}
 
 Review comment:
   Also, is there any reason we are using logs from 2015? Why not 2018?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238032665
 
 

 ##
 File path: core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java
 ##
 @@ -391,12 +391,12 @@ public static void main(String[] args) {
   me.end();
 } catch (Exception e) {
   HelpFormatter formatter = new HelpFormatter();
-  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", true);
+  formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + 
"User must also provide an ingest method.", options, true);
   LOG.error("Error whilst parsing command line.", e);
 }
   }
 
-  private static void loadPathConfig(MudrodEngine me, String dataDir) {
+  public static void loadPathConfig(MudrodEngine me, String dataDir) {
 
 Review comment:
   Why does this need to be public?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238034020
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/RequestUrlTest.java
 ##
 @@ -0,0 +1,75 @@
+package org.apache.sdap.mudrod.weblog.structure;
+
+import static org.junit.Assert.*;
 
 Review comment:
   Never use wildcard imports. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238034053
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/RequestUrlTest.java
 ##
 @@ -0,0 +1,75 @@
+package org.apache.sdap.mudrod.weblog.structure;
+
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import org.apache.sdap.mudrod.weblog.structure.log.RequestUrl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RequestUrlTest {
+   
+// @BeforeClass
 
 Review comment:
   Never leave code commented out like this it is extremely untidy. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238032746
 
 

 ##
 File path: 
core/src/main/java/org/apache/sdap/mudrod/weblog/pre/SessionStatistic.java
 ##
 @@ -229,7 +229,7 @@ public int processSession(ESDriver es, String sessionId) 
throws IOException, Int
   String[] keywordList = keywords.split(",");
   for (String item : items) {
 if (!Arrays.asList(keywordList).contains(item)) {
-  keywords = keywords + item + ",";
+  keywords = keywords + "," + item + ",";
 
 Review comment:
   Can you explain this addition? What was wrong with it previously? Do you 
have a unit test for it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238034104
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/RequestUrlTest.java
 ##
 @@ -0,0 +1,75 @@
+package org.apache.sdap.mudrod.weblog.structure;
+
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import org.apache.sdap.mudrod.weblog.structure.log.RequestUrl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RequestUrlTest {
+   
+// @BeforeClass
+//public void setUp(){
+// RequestUrl url = new RequestUrl();
+// 
+//}
+// @Test
+// public void testRequestUrl() {
+// fail("Not yet implemented");
+// }
+
+   @Test
+   public void testUrlPage() {
+   RequestUrl url = new RequestUrl();
+   String strURL = 
"https://podaac.jpl.nasa.gov/datasetlist?ids=Collections:Measurement:SpatialCoverage:Platform:Sensor=SCAT_BYU_L3_OW_SIGMA0_ENHANCED:Sea%20Ice:Bering%20Sea:ERS-2:AMI=list;;
+   String result = url.urlPage(strURL);
+   //System.out.println(urlPage);
+   ///fail("Not yet implemented");
+   Assert.assertEquals("You did not pass urlPage function ", 
"https://podaac.jpl.nasa.gov/datasetlist;, result);
+   }
+
+   @Test
+   public void testuRLRequest() {
+   RequestUrl url = new RequestUrl();
+   String strURL = 
"https://podaac.jpl.nasa.gov/datasetlist?ids=Collections:Measurement:SpatialCoverage:Platform:Sensor=SCAT_BYU_L3_OW_SIGMA0_ENHANCED:Sea%20Ice:Bering%20Sea:ERS-2:AMI=list;;
 
 Review comment:
   Why is this not a constant?


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033014
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/discoveryengine/WeblogDiscoveryEngineTest.java
 ##
 @@ -0,0 +1,127 @@
+package org.apache.sdap.mudrod.discoveryengine;
+
+import static org.junit.Assert.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.sdap.mudrod.driver.ESDriver;
+import org.apache.sdap.mudrod.driver.SparkDriver;
+import org.apache.sdap.mudrod.main.AbstractElasticsearchIntegrationTest;
+import org.apache.sdap.mudrod.main.MudrodConstants;
+import org.apache.sdap.mudrod.main.MudrodEngine;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WeblogDiscoveryEngineTest extends 
AbstractElasticsearchIntegrationTest {
+
+  private static WeblogDiscoveryEngine weblogEngine = null;
+
+  @BeforeClass
+  public static void setUp() {
+MudrodEngine mudrodEngine = new MudrodEngine();
+Properties props = mudrodEngine.loadConfig();
+ESDriver es = new ESDriver(props);
+SparkDriver spark = new SparkDriver(props);
+String dataDir = getTestDataPath();
+System.out.println(dataDir);
+props.setProperty(MudrodConstants.DATA_DIR, dataDir);
+MudrodEngine.loadPathConfig(mudrodEngine, dataDir);
+weblogEngine = new WeblogDiscoveryEngine(props, es, spark);
+  }
+
+  @AfterClass
+  public static void tearDown() {
+// TODO
+  }
+
+  private static String getTestDataPath() {
+File resourcesDirectory = new File("src/test/resources/");
 
 Review comment:
   Use the Java ClassLoader...
   ```
   getClass().getCLassLoader().getResource


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services


[GitHub] lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded unit test

2018-11-30 Thread GitBox
lewismc commented on a change in pull request #35: SDAP-161 MUDROD embedded 
unit test
URL: 
https://github.com/apache/incubator-sdap-mudrod/pull/35#discussion_r238033873
 
 

 ##
 File path: 
core/src/test/java/org/apache/sdap/mudrod/main/AbstractElasticsearchIntegrationTest.java
 ##
 @@ -0,0 +1,37 @@
+package org.apache.sdap.mudrod.main;
 
 Review comment:
   License header. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services