Commit 7fb09b0f by Madhan Neethiraj

ATLAS-1981: fix for unit test failures

parent de251913
...@@ -34,11 +34,12 @@ import org.apache.commons.lang.StringUtils; ...@@ -34,11 +34,12 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* class that implements behaviour of a struct-type. * class that implements behaviour of a struct-type.
...@@ -714,13 +715,21 @@ public class AtlasStructType extends AtlasType { ...@@ -714,13 +715,21 @@ public class AtlasStructType extends AtlasType {
return key; return key;
} }
public static String escapeIndexQueryValue(Set<String> values) { public static String escapeIndexQueryValue(Collection<String> values) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(BRACE_OPEN_CHAR); sb.append(BRACE_OPEN_CHAR);
for (String value : values) {
sb.append(escapeIndexQueryValue(value)).append(SPACE_CHAR); if (CollectionUtils.isNotEmpty(values)) {
Iterator<String> iter = values.iterator();
sb.append(escapeIndexQueryValue(iter.next()));
while (iter.hasNext()) {
sb.append(SPACE_CHAR).append(escapeIndexQueryValue(iter.next()));
} }
}
sb.append(BRACE_CLOSE_CHAR); sb.append(BRACE_CLOSE_CHAR);
return sb.toString(); return sb.toString();
......
...@@ -50,7 +50,7 @@ public class EntityDiscoveryServiceTest { ...@@ -50,7 +50,7 @@ public class EntityDiscoveryServiceTest {
AtlasEntityDef typeTest3 = null; AtlasEntityDef typeTest3 = null;
AtlasEntityDef typeWithSubTypes = null; AtlasEntityDef typeWithSubTypes = null;
private final int maxTypesCountInIdxQuery = 10; private final int maxTypesStrLengthInIdxQuery = 55;
@Inject @Inject
EntityDiscoveryService discoveryService; EntityDiscoveryService discoveryService;
...@@ -81,17 +81,17 @@ public class EntityDiscoveryServiceTest { ...@@ -81,17 +81,17 @@ public class EntityDiscoveryServiceTest {
@Test @Test
public void getSubTypesForType_NullStringReturnsEmptyString() throws Exception { public void getSubTypesForType_NullStringReturnsEmptyString() throws Exception {
invokeGetSubTypesForType(null, maxTypesCountInIdxQuery); invokeGetSubTypesForType(null, maxTypesStrLengthInIdxQuery);
} }
@Test @Test
public void getSubTypesForType_BlankStringReturnsEmptyString() throws Exception { public void getSubTypesForType_BlankStringReturnsEmptyString() throws Exception {
invokeGetSubTypesForType(" ", maxTypesCountInIdxQuery); invokeGetSubTypesForType(" ", maxTypesStrLengthInIdxQuery);
} }
@Test @Test
public void getSubTypesForType_EmptyStringReturnsEmptyString() throws Exception { public void getSubTypesForType_EmptyStringReturnsEmptyString() throws Exception {
invokeGetSubTypesForType("", maxTypesCountInIdxQuery); invokeGetSubTypesForType("", maxTypesStrLengthInIdxQuery);
} }
@Test @Test
...@@ -103,7 +103,7 @@ public class EntityDiscoveryServiceTest { ...@@ -103,7 +103,7 @@ public class EntityDiscoveryServiceTest {
@Test @Test
public void getSubTypeForTypeWithSubTypes_ReturnsOrClause() throws Exception { public void getSubTypeForTypeWithSubTypes_ReturnsOrClause() throws Exception {
String s = invokeGetSubTypesForType(TEST_TYPE_WITH_SUB_TYPES, maxTypesCountInIdxQuery); String s = invokeGetSubTypesForType(TEST_TYPE_WITH_SUB_TYPES, maxTypesStrLengthInIdxQuery);
assertTrue(s.startsWith("(")); assertTrue(s.startsWith("("));
assertTrue(s.contains(TEST_TYPE_WITH_SUB_TYPES)); assertTrue(s.contains(TEST_TYPE_WITH_SUB_TYPES));
...@@ -115,7 +115,7 @@ public class EntityDiscoveryServiceTest { ...@@ -115,7 +115,7 @@ public class EntityDiscoveryServiceTest {
@Test @Test
public void getSubTypeForTypeWithSubTypes_ReturnsEmptyString() throws Exception { public void getSubTypeForTypeWithSubTypes_ReturnsEmptyString() throws Exception {
String s = invokeGetSubTypesForType(TEST_TYPE_WITH_SUB_TYPES, 2); String s = invokeGetSubTypesForType(TEST_TYPE_WITH_SUB_TYPES, 20);
assertTrue(StringUtils.isBlank(s)); assertTrue(StringUtils.isBlank(s));
} }
......
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