Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4Bmcyc2U] Un-ignore and clean up working test. #3342

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 15 additions & 33 deletions core/src/test/java/apoc/meta/MetaEnterpriseFeaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import apoc.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.driver.Session;

Expand All @@ -18,6 +17,7 @@
import static apoc.util.TestContainerUtil.testResult;
import static apoc.util.TestUtil.isRunningInCI;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
Expand All @@ -34,12 +34,9 @@ public class MetaEnterpriseFeaturesTest {
@BeforeClass
public static void beforeAll() {
assumeFalse(isRunningInCI());
// executeGradleTasks("clean", "shadow");
TestUtil.ignoreException(() -> {
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(!TestUtil.isRunningInCI());
neo4jContainer.start();
}, Exception.class);
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(!TestUtil.isRunningInCI());
neo4jContainer.start();
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
session = neo4jContainer.getSession();
Expand All @@ -53,21 +50,6 @@ public static void afterAll() {
}
}

public static boolean hasRecordMatching(List<Map<String,Object>> records, Map<String,Object> record) {
return hasRecordMatching(records, row -> {
boolean okSoFar = true;

for(String k : record.keySet()) {
okSoFar = okSoFar && row.containsKey(k) &&
(row.get(k) == null ?
(record.get(k) == null) :
row.get(k).equals(record.get(k)));
}

return okSoFar;
});
}

public static boolean hasRecordMatching(List<Map<String,Object>> records, Predicate<Map<String,Object>> predicate) {
return records.stream().filter(predicate).count() > 0;
}
Expand All @@ -81,7 +63,6 @@ public static List<Map<String,Object>> gatherRecords(Iterator<Map<String,Object>
return rows;
}

@Ignore("test fails, ignoring until fixed by upstream author")
@Test
public void testNodeTypePropertiesBasic() {
session.writeTransaction(tx -> {
Expand All @@ -96,22 +77,23 @@ public void testNodeTypePropertiesBasic() {
});
testResult(session, "CALL apoc.meta.nodeTypeProperties();", (r) -> {
List<Map<String,Object>> records = gatherRecords(r);
assertEquals(true, hasRecordMatching(records, m ->
assertTrue(hasRecordMatching(records, m ->
m.get("nodeType").equals(":`Foo`") &&
((List)m.get("nodeLabels")).get(0).equals("Foo") &&
m.get("propertyName").equals("s") &&
m.get("mandatory").equals(true)));

assertEquals(true, hasRecordMatching(records, m ->
m.get("propertyName").equals("s") &&
((List)m.get("propertyTypes")).get(0).equals("String")));
assertTrue(hasRecordMatching(records, m ->
m.get("propertyName").equals("s") &&
((List)m.get("propertyTypes")).get(0).equals("String")));

assertEquals(true, hasRecordMatching(records, m ->
m.get("nodeType").equals(":`Foo`") &&
((List)m.get("nodeLabels")).get(0).equals("Foo") &&
m.get("propertyName").equals("dl") &&
m.get("mandatory").equals(false)));
assertEquals(5, records.size());
assertTrue(hasRecordMatching(records, m ->
m.get("nodeType").equals(":`Foo`") &&
((List)m.get("nodeLabels")).get(0).equals("Foo") &&
m.get("propertyName").equals("dl") &&
m.get("mandatory").equals(false)));

assertEquals(5, records.size());
});
}
}