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

Cypher Quality Assurance #513

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
af9d261
add new tests for aggregate , order by , UnWind , With
alyaa999 Jun 13, 2024
df7321a
add new tests for merge test file ,
alyaa999 Jun 13, 2024
7f8ee4f
add tests for merge , delete and remove
alyaa999 Jun 13, 2024
a767348
add tests for Case,Skip ,Union files
alyaa999 Jun 14, 2024
8da8e4a
update test cases
alyaa999 Jun 15, 2024
b819164
update test cases
alyaa999 Jun 15, 2024
14f1b9a
update test cases
alyaa999 Jun 16, 2024
976462f
update test cases
alyaa999 Jun 16, 2024
b0916f5
add new tests cases for :
alyaa999 Jun 26, 2024
5acaeff
add list , numeric , temporal functions to new folder "functions"
alyaa999 Jun 26, 2024
0f1a2a5
add new tests cases for string functions and other functions
alyaa999 Jun 26, 2024
affd23a
move the files to folders
alyaa999 Jun 27, 2024
34e10c6
add new test cases to string func file
alyaa999 Jun 29, 2024
395c269
add new test cases for numeric fun file
alyaa999 Jun 29, 2024
b9caf5b
add changes
alyaa999 Jun 29, 2024
7002785
add changes
alyaa999 Jun 29, 2024
c81c488
add changes
alyaa999 Jun 29, 2024
f7e364b
update testcases within delete test file
alyaa999 Jul 5, 2024
1bcf85f
add testcases for filter test file
alyaa999 Jul 5, 2024
7788b22
add testcases for Other test file
alyaa999 Jul 5, 2024
63c48f4
add testcases for call test
alyaa999 Jul 23, 2024
079e5f0
move aggregation test file to func folder
alyaa999 Jul 23, 2024
e162d87
remove comment from merge test file
alyaa999 Jul 23, 2024
990c862
add tests for insert test file
alyaa999 Jul 28, 2024
8242172
add new tests to Union Test file
alyaa999 Jul 28, 2024
33ab986
Add test coverage for Call SubQueries
alyaa999 Jul 28, 2024
4b3164f
Add test coverage for Collect SubQueries
alyaa999 Jul 29, 2024
64a8c0e
Add test coverage for Count SubQueries
alyaa999 Jul 30, 2024
c5f7670
Add changes for Count SubQueries
alyaa999 Jul 30, 2024
c3520a2
Add changes for Exists SubQueries
alyaa999 Jul 30, 2024
c96c358
Add test coverage for foreach clause
alyaa999 Jul 30, 2024
2d073db
Add test coverage for foreach clause
alyaa999 Jul 30, 2024
8e05178
Add test coverage for Operators
alyaa999 Aug 4, 2024
d3fabdc
Add more test coverage for TemporalFun
alyaa999 Aug 4, 2024
a23b57a
Add more test coverage for Mathematical Operators
alyaa999 Aug 4, 2024
612de00
Add more test coverage for more functions
alyaa999 Aug 5, 2024
01b0c89
Add more test coverage for limit clause
alyaa999 Aug 5, 2024
b4f9a13
Add more test coverage for list Operators
alyaa999 Aug 5, 2024
b261709
Add more test coverage for where clause
alyaa999 Aug 5, 2024
6b0c0b8
change function names to lower case
alyaa999 Aug 5, 2024
0cf738c
add coverage test for Point fun
alyaa999 Aug 5, 2024
a955b7b
add coverage test for Point fun
alyaa999 Aug 5, 2024
b1080ef
add coverage test for insert clause to
alyaa999 Aug 7, 2024
f0fb99a
add coverage test for insert clause to
alyaa999 Aug 8, 2024
a7a48e0
Reformat line indents
alyaa999 Aug 17, 2024
c7ed8c2
add more coverage test for update clause
alyaa999 Aug 17, 2024
f71f5d0
"Refactor: Replace Java assert statements with JUnit5 assertions for …
alyaa999 Aug 18, 2024
264a7ad
Refactor: "replace concatenation with text block
alyaa999 Aug 18, 2024
e7e74e7
Refactor: rename files
alyaa999 Aug 18, 2024
90467f2
update the output test
alyaa999 Aug 19, 2024
153df2d
Merge branch 'master'
vogti Aug 25, 2024
57a87b5
Minor formatting and style improvements and rename folders to lower case
vogti Aug 25, 2024
06a13f0
Minor improvements
vogti Aug 25, 2024
9070652
Improve cypher error messages
vogti Aug 25, 2024
61d6f1a
Improve method names
vogti Aug 25, 2024
dcd50e0
Small improvements
vogti Aug 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ private Expression translateCall( RexCall call, RexImpTable.NullAs nullAs ) {
final Operator operator = call.getOperator();
CallImplementor implementor = RexImpTable.INSTANCE.get( operator );
if ( implementor == null ) {
throw new GenericRuntimeException( "cannot translate call " + call );
throw new GenericRuntimeException( "Cannot translate call " + call );
}
return implementor.implement( this, call, nullAs );
}
Expand Down
160 changes: 0 additions & 160 deletions dbms/src/test/java/org/polypheny/db/cypher/AggregateTest.java

This file was deleted.

63 changes: 29 additions & 34 deletions dbms/src/test/java/org/polypheny/db/cypher/CypherTestTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.polypheny.db.cypher;

import static java.lang.String.format;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.ArrayList;
Expand Down Expand Up @@ -48,6 +50,7 @@
import org.polypheny.db.util.Pair;
import org.polypheny.db.webui.models.results.GraphResult;


@Slf4j
public class CypherTestTemplate {

Expand All @@ -58,6 +61,8 @@ public class CypherTestTemplate {
protected static final String SINGLE_NODE_PERSON_COMPLEX_1 = "CREATE (p:Person {name: 'Ann', age: 45, depno: 13})";
protected static final String SINGLE_NODE_PERSON_COMPLEX_2 = "CREATE (p:Person {name: 'Bob', age: 31, depno: 13})";

protected static final String SINGLE_NODE_PERSON_COMPLEX_3 = "CREATE (p:Person {name: 'Alex', age: 32, depno: 14})";

protected static final String SINGLE_NODE_ANIMAL = "CREATE (a:Animal {name:'Kira', age:3, type:'dog'})";
protected static final String SINGLE_NODE_GEOM = "CREATE (c:City {name:'Basel', location:'POINT (7.586052 47.559152)'})";
protected static final String SINGLE_EDGE_1 = "CREATE (p:Person {name: 'Max'})-[rel:OWNER_OF]->(a:Animal {name:'Kira', age:3, type:'dog'})";
Expand Down Expand Up @@ -172,7 +177,6 @@ public boolean containsIn( GraphResult actual, boolean exclusive, int index, @Nu
}

return contains;

}


Expand All @@ -186,13 +190,12 @@ public static boolean containsRows( GraphResult actual, boolean exclusive, boole
i++;
}

assert !exclusive || actual.getData().length >= rows.length;
// Use assert to validate exclusive condition
assertTrue( !exclusive || actual.getData().length >= rows.length, "Exclusive condition failed: actual data has fewer rows than expected." );

// Use the appropriate matching method based on the 'ordered' flag
return ordered ? matchesExactRows( parsed, rows ) : matchesUnorderedRows( parsed, rows );

if ( ordered ) {
return matchesExactRows( parsed, rows );
} else {
return matchesUnorderedRows( parsed, rows );
}
} catch ( Throwable t ) {
fail( "Error while evaluating result: " + t.getMessage() );
throw new RuntimeException();
Expand All @@ -201,40 +204,32 @@ public static boolean containsRows( GraphResult actual, boolean exclusive, boole


private static boolean matchesUnorderedRows( List<List<PolyValue>> parsed, Row[] rows ) {

List<Integer> used = new ArrayList<>();
for ( Row row : rows ) {

int i = 0;
for ( Row row : rows ) {
boolean matches = false;
for ( List<PolyValue> objects : parsed ) {

if ( !matches && !used.contains( i ) ) {
if ( row.matches( objects ) ) {
used.add( i );
matches = true;
}
for ( int i = 0; i < parsed.size(); i++ ) {
if ( !matches && !used.contains( i ) && row.matches( parsed.get( i ) ) ) {
used.add( i );
matches = true;
break;
}

i++;
}
if ( !matches ) {
return false;
}

// Use assert to validate that each row finds a match
assertTrue( matches, "Row " + row + " could not be matched in the parsed data." );
}
return true;

}


private static boolean matchesExactRows( List<List<PolyValue>> parsed, Row[] rows ) {
boolean matches = true;
int j = 0;
for ( Row row : rows ) {
matches &= row.matches( parsed.get( j ) );
j++;
for ( int j = 0; j < rows.length; j++ ) {
// Use assert to ensure each row matches
assertTrue( rows[j].matches( parsed.get( j ) ), "Row " + j + " does not match the expected value." );
}
return matches;
return true;
}


Expand All @@ -246,14 +241,15 @@ private <T extends GraphPropertyHolder> boolean contains( String[][] actual, boo
parsed.add( PolyValue.JSON_WRAPPER.readValue( entry[index], clazz ) );
}

assert !exclusive || parsed.size() == expected.length;
// Assert that if exclusive is true, the number of parsed items equals the number of expected items
assertEquals( exclusive ? expected.length : parsed.size(), parsed.size(), "Exclusive condition failed: parsed size does not match expected length." );

boolean contains = true;
for ( TestObject node : expected ) {
contains &= parsed.stream().anyMatch( n -> node.matches( n, exclusive ) );
// Assert that each expected node matches at least one parsed element
assertTrue( parsed.stream().anyMatch( n -> node.matches( n, exclusive ) ), "Expected node does not match any parsed element." );
}

return contains;
return true;
}


Expand All @@ -280,7 +276,7 @@ protected boolean is( GraphResult res, Type type, int index ) {


protected void assertEmpty( GraphResult res ) {
assert res.getData().length == 0;
assertEquals( 0, res.getData().length );
}


Expand Down Expand Up @@ -361,5 +357,4 @@ public boolean matches( List<PolyValue> objects ) {

}


}
13 changes: 2 additions & 11 deletions dbms/src/test/java/org/polypheny/db/cypher/DdlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.polypheny.db.cypher;


import static java.lang.String.format;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -34,8 +33,10 @@
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.entity.logical.LogicalGraph;
import org.polypheny.db.catalog.entity.logical.LogicalNamespace;
import org.polypheny.db.cypher.clause.write.DmlInsertTest;
import org.polypheny.db.webui.models.results.GraphResult;


@Tag("adapter")
@Slf4j
public class DdlTest extends CypherTestTemplate {
Expand All @@ -58,7 +59,6 @@ public void addGraphTest() {
assertTrue( Catalog.snapshot().getNamespace( graphName ).isPresent() );

execute( "DROP DATABASE " + graphName );

}


Expand All @@ -70,7 +70,6 @@ public void createNamespaceTest( String namespaceName ) {
execute( format( "CREATE %s %s", namespaceName, name ) );

execute( format( "DROP %s %s", namespaceName, name ) );

}


Expand All @@ -97,10 +96,8 @@ public void addPlacementTest() throws SQLException {
execute( "DROP DATABASE " + graphName );

} finally {

removeStore( "store1" );
}

}


Expand Down Expand Up @@ -128,7 +125,6 @@ public void initialPlacementTest() throws SQLException {
} finally {
removeStore( "store1" );
}

}


Expand Down Expand Up @@ -160,13 +156,11 @@ public void deletePlacementTest() throws SQLException {
} finally {
removeStore( "store1" );
}

}


@Test
public void deletePlacementDataTest() throws SQLException {

execute( "CREATE DATABASE " + graphName + " IF NOT EXISTS" );

execute( DmlInsertTest.CREATE_COMPLEX_GRAPH_2, graphName );
Expand All @@ -191,7 +185,6 @@ public void deletePlacementDataTest() throws SQLException {
} finally {
removeStore( "store1" );
}

}


Expand All @@ -209,9 +202,7 @@ private void removeStore( String name ) throws SQLException {
try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {

statement.executeUpdate( String.format( "ALTER ADAPTERS DROP \"%s\"", name ) );

}
}
}
Expand Down
Loading
Loading