Commit 4b2a4cae by Shwetha GS

fixed test failures - GraphBackedMetadataRepositoryTest#testFullTextSearch, DSLTest.test1

parent 8e73ed24
......@@ -85,7 +85,7 @@ public final class GraphHelper {
public static Edge addEdge(TitanGraph titanGraph, Vertex fromVertex, Vertex toVertex,
String edgeLabel) {
LOG.debug("Adding edge for {} -> struct label {} -> v{}",
LOG.debug("Adding edge for {} -> label {} -> {}",
fromVertex, edgeLabel, toVertex);
return titanGraph.addEdge(null, fromVertex, toVertex, edgeLabel);
......
......@@ -334,11 +334,6 @@ public class GraphBackedMetadataRepositoryTest {
String response = discoveryService.searchByFullText("john");
Assert.assertNotNull(response);
JSONArray results = new JSONArray(response);
System.out.println("Found the following results");
for (int i = 0 ; i < results.length(); i++) {
JSONObject myrow = results.getJSONObject(i);
System.out.println(myrow.toString());
}
Assert.assertEquals(results.length(), 1);
JSONObject row = (JSONObject) results.get(0);
Assert.assertEquals(row.get("typeName"), "Person");
......@@ -346,11 +341,10 @@ public class GraphBackedMetadataRepositoryTest {
//person in hr department who lives in santa clara
response = discoveryService.searchByFullText("Jane AND santa AND clara");
Assert.assertNotNull(response);
// todo: enable this - temporarily commented this as its failing
// results = new JSONArray(response);
// Assert.assertEquals(results.length(), 1);
// row = (JSONObject) results.get(0);
// Assert.assertEquals(row.get("typeName"), "Manager");
results = new JSONArray(response);
Assert.assertEquals(results.length(), 1);
row = (JSONObject) results.get(0);
Assert.assertEquals(row.get("typeName"), "Manager");
//search for person in hr department whose name starts is john/jahn
response = discoveryService.searchByFullText("hr AND (john OR jahn)");
......
......@@ -36,7 +36,7 @@ import scala.collection.JavaConversions._
package object dsl {
val defFormat = new DefaultFormats {
override protected def dateFormatter = new SimpleDateFormat("yyyy-MM-dd")
override protected def dateFormatter = TypeSystem.getInstance().getDateFormat;
override val typeHints = NoTypeHints
}
......
......@@ -120,7 +120,7 @@ class DSLTest {
Assert.assertEquals(s"${i.o.asInstanceOf[java.util.Map[_, _]].keySet}", "[b, a]")
// 5. Serialize mytype instance to Json
Assert.assertEquals(s"${pretty(render(i))}", "{\n \"$typeName$\":\"mytype\",\n \"e\":1," + "\n \"n\":[1,1.100000000000000088817841970012523233890533447265625],\n \"h\":1.0,\n \"b\":true,\n \"k\":1,\n \"j\":1,\n \"d\":2,\n \"m\":[1,1],\n \"g\":1,\n \"a\":1,\n \"i\":1.0,\n \"c\":1,\n \"l\":\"2014-12-02\",\n \"f\":1,\n \"o\":{\n \"b\":2.0,\n \"a\":1.0\n }\n}")
Assert.assertEquals(s"${pretty(render(i))}", "{\n \"$typeName$\":\"mytype\",\n \"e\":1," + "\n \"n\":[1,1.100000000000000088817841970012523233890533447265625],\n \"h\":1.0,\n \"b\":true,\n \"k\":1,\n \"j\":1,\n \"d\":2,\n \"m\":[1,1],\n \"g\":1,\n \"a\":1,\n \"i\":1.0,\n \"c\":1,\n \"l\":\"2014-12-03\",\n \"f\":1,\n \"o\":{\n \"b\":2.0,\n \"a\":1.0\n }\n}")
}
@Test def test2 {
......
......@@ -42,10 +42,10 @@ import java.util.concurrent.ConcurrentHashMap;
@InterfaceAudience.Private
public class TypeSystem {
private static final TypeSystem INSTANCE = new TypeSystem();
public static ThreadLocal<DateFormat> dateFormat = new ThreadLocal() {
private static ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal() {
@Override
public DateFormat initialValue() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
public SimpleDateFormat initialValue() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat;
}
......@@ -294,7 +294,7 @@ public class TypeSystem {
return eT;
}
public DateFormat getDateFormat() {
public SimpleDateFormat getDateFormat() {
return dateFormat.get();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment