Commit 7fb09b0f by Madhan Neethiraj

ATLAS-1981: fix for unit test failures

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