Skip to content

Commit

Permalink
Reformat line indents
Browse files Browse the repository at this point in the history
  • Loading branch information
alyaa999 committed Aug 17, 2024
1 parent f0fb99a commit a7a48e0
Show file tree
Hide file tree
Showing 25 changed files with 502 additions and 490 deletions.
238 changes: 122 additions & 116 deletions dbms/src/test/java/org/polypheny/db/cypher/Functions/AggregateTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.polypheny.db.cypher.CypherTestTemplate;
import org.polypheny.db.cypher.helper.TestLiteral;
import org.polypheny.db.webui.models.results.GraphResult;
import java.util.List;

public class ListFunTest extends CypherTestTemplate {

Expand Down Expand Up @@ -81,4 +82,44 @@ assert containsRows( res, true, true,
Row.of( TestLiteral.from( 1 ), TestLiteral.from( 2 ), TestLiteral.from( 3 ) ) );
}


@Test
public void returnLabelsFunTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH (a)"
+ "RETURN labels(a)" );

assert containsRows( res, true, false, Row.of( TestLiteral.from( List.of( "Person" ) ) ) );
}


@Test
public void returnNodesFunTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN nodes(p)" );
assert res.getData().length == 1;
assert containsRows( res, true, false, Row.of( TestLiteral.from( List.of( MAX, KIRA ) ) ) );

}


@Test
public void returnRelationsFunTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN relationships(p)" );
assert res.getData().length == 1;
}


@Test
public void returnRelationAndNodesFunTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN relationships(p) , nodes(p)" );
assert res.getData().length == 1;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,27 @@ public void absFunTest() {
res = execute( "RETURN ABS(5)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 5 ) ) );


res = execute("RETURN ABS(0)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(0)));
res = execute( "RETURN ABS(0)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 0 ) ) );
}


@Test
public void roundFunTest() {
GraphResult res = execute("RETURN ROUND(3)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(3)));
GraphResult res = execute( "RETURN ROUND(3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute("RETURN ROUND(-3)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(-3)));
res = execute( "RETURN ROUND(-3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( -3 ) ) );

res = execute( "RETURN ROUND(3.4)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute( "RETURN ROUND(3.5)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 4 ) ) );

res = execute("RETURN ROUND(-3.5)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(-4)));

res = execute( "RETURN ROUND(-3.5)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( -4 ) ) );


}
Expand All @@ -74,17 +72,17 @@ public void floorFunTest() {
GraphResult res = execute( "RETURN FLOOR(3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute( "RETURN FLOOR(-3)" );
res = execute( "RETURN FLOOR(-3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( -3 ) ) );

res = execute( "RETURN FLOOR(3.16)" );
res = execute( "RETURN FLOOR(3.16)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute( "RETURN FLOOR(3.9)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute("RETURN FLOOR(-3.16)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(-4)));
res = execute( "RETURN FLOOR(-3.16)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( -4 ) ) );
}


Expand All @@ -93,7 +91,7 @@ public void ceilFunTest() {
GraphResult res = execute( "RETURN CEIL(3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 4 ) ) );

res = execute( "RETURN CEIL(-3)" );
res = execute( "RETURN CEIL(-3)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 4 ) ) );

res = execute( "RETURN CEIL(3.16)" );
Expand All @@ -110,21 +108,24 @@ public void sqrtFunTest() {
GraphResult res = execute( "RETURN SQRT(9)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 3 ) ) );

res = execute("RETURN SQRT(0)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(0)));
res = execute( "RETURN SQRT(0)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 0 ) ) );
}


@Test
public void nonPerfectSquareSqrtFunTest() {
GraphResult res = execute("RETURN SQRT(8)");
assert containsRows(res, true, true, Row.of(TestLiteral.from(Math.sqrt(8))));
GraphResult res = execute( "RETURN SQRT(8)" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( Math.sqrt( 8 ) ) ) );
}


@Test
public void sqrtFunTestNegative() {
GraphResult res = execute("RETURN SQRT(-9)");
// assert containsRows(res, true, true, Row.of(TestLiteral.from(null)));
GraphResult res = execute( "RETURN SQRT(-9)" );
// assert containsRows(res, true, true, Row.of(TestLiteral.from(null)));
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public void reset() {
tearDown();
createGraph();
}
//////////////////////////
/// Scalar Functions
///////////////////////////


//////////////////////////
/// Scalar Functions
///////////////////////////
@Test
public void typeFunTest() {
execute( SINGLE_EDGE_1 );
Expand All @@ -54,6 +56,7 @@ public void idFunTest() {

}


@Test
public void testCoalesceFunTest() {
execute( SINGLE_NODE_PERSON_1 );
Expand Down Expand Up @@ -83,9 +86,10 @@ assert containsRows( result, true, false,
Row.of( TestLiteral.from( "Ann" ), TestLiteral.from( "unknown" ) ) );
}

///////////////////////////////
// Predicate Functions
/////////////////////////////

///////////////////////////////
// Predicate Functions
/////////////////////////////
@Test
public void ExistFunTest() {
execute( SINGLE_NODE_PERSON_1 );
Expand All @@ -101,46 +105,4 @@ public void ExistFunTest() {
}


///////////////////////////
//// List Functions
///////////////////////////
@Test
public void returnLabelsFunTest() {
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH (a)"
+ "RETURN labels(a)" );

assert containsRows( res, true, false, Row.of( TestLiteral.from( List.of( "Person" ) ) ) );
}

@Test
public void returnNodesFunTest()
{
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN nodes(p)" );
assert res.getData().length == 1;
assert containsRows( res , true , false ,Row.of( TestLiteral.from( List.of(MAX ,KIRA ) ) ) );

}

@Test
public void returnRelationsFunTest()
{
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN relationships(p)" );
assert res.getData().length == 1 ;
}

@Test
public void returnRelationAndNodesFunTest()
{
execute( SINGLE_EDGE_1 );
GraphResult res = execute( "MATCH p = (a)-->(b)-->(c)\n"
+ "RETURN relationships(p) , nodes(p)" );
assert res.getData().length == 1 ;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ assert containsRows( res, true, false,
TestLiteral.from( 3.0 ),
TestLiteral.from( 4321.0 ),
TestLiteral.from( "wgs-84-3d" ),
TestLiteral.from( 4979 ) ));
TestLiteral.from( 4979 ) ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ public void removeSubstringReplaceFunTest() {
}



@Test
public void stringLengthFunTest() {
GraphResult res = execute("RETURN LENGTH('Hello, world!')");
assert containsRows(res, true, true, Row.of(TestLiteral.from(13)));
GraphResult res = execute( "RETURN LENGTH('Hello, world!')" );
assert containsRows( res, true, true, Row.of( TestLiteral.from( 13 ) ) );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ public void stringIntoDurationFunTest() {
@Test
public void durationBetweenFunTest() {
GraphResult res = execute( "RETURN duration.between(date('1984-10-11'), date('2015-06-24')) AS theDuration" );
assert containsRows( res , true , false ,Row.of( TestLiteral.from( "P30Y8M13D" ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( "P30Y8M13D" ) ) );
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,53 @@
import org.polypheny.db.webui.models.results.GraphResult;

public class BooleanOperators extends CypherTestTemplate {

@BeforeEach
public void setUp() {
tearDown();
createGraph();
}


@Test
public void conjunctionOperatorTest()
{
GraphResult res = execute( "WITH true as a , false as b RETURN a AND b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from( false ) ) );
public void conjunctionOperatorTest() {
GraphResult res = execute( "WITH true as a , false as b RETURN a AND b " );
assert containsRows( res, true, false, Row.of( TestLiteral.from( false ) ) );
res = execute( "WITH true as a , true as b RETURN a AND b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(true ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( true ) ) );

}


@Test
public void disjunctionOperatorTest()
{
GraphResult res = execute( "WITH true as a , false as b RETURN a OR b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from( true ) ) );
public void disjunctionOperatorTest() {
GraphResult res = execute( "WITH true as a , false as b RETURN a OR b " );
assert containsRows( res, true, false, Row.of( TestLiteral.from( true ) ) );
res = execute( "WITH false as a , false as b RETURN a OR b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(false ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( false ) ) );

}


@Test
public void exclusiveDisjunctionOperatorTest()
{
GraphResult res = execute( "WITH true as a , false as b RETURN a XOR b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from( true ) ) );
public void exclusiveDisjunctionOperatorTest() {
GraphResult res = execute( "WITH true as a , false as b RETURN a XOR b " );
assert containsRows( res, true, false, Row.of( TestLiteral.from( true ) ) );
res = execute( "WITH true as a , true as b RETURN a XOR b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(false ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( false ) ) );
res = execute( "WITH false as a , false as b RETURN a XOR b " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(true ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( true ) ) );

}


@Test
public void negationOperatorTest()
{
public void negationOperatorTest() {
GraphResult res = execute( "WITH true as a RETURN NOT a " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(false ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( false ) ) );

res = execute( "WITH false as a RETURN NOT a " );
assert containsRows( res , true , false , Row.of( TestLiteral.from(true ) ) );
assert containsRows( res, true, false, Row.of( TestLiteral.from( true ) ) );

}

Expand Down
Loading

0 comments on commit a7a48e0

Please sign in to comment.