use of org.sagebionetworks.repo.web.query.QueryStatement in project Synapse-Repository-Services by Sage-Bionetworks.
the class QueryParserTest method testCompoundIdWithSpaces.
/**
* @throws Exception
*/
@Test
public void testCompoundIdWithSpaces() throws Exception {
QueryStatement stmt = new QueryStatement("select * from dataset where dataset.\"Number of Samples\" == 100");
assertEquals("dataset", stmt.getTableName());
assertNotNull(stmt.getSearchCondition());
assertEquals(1, stmt.getSearchCondition().size());
assertTrue(stmt.getSearchCondition().get(0) instanceof Expression);
Expression expression = (Expression) stmt.getSearchCondition().get(0);
assertEquals("dataset", expression.getId().getTableName());
assertEquals("Number of Samples", expression.getId().getFieldName());
assertEquals(new Long(100), expression.getValue());
}
use of org.sagebionetworks.repo.web.query.QueryStatement in project Synapse-Repository-Services by Sage-Bionetworks.
the class QueryParserTest method testSelectMultiple.
@Test
public void testSelectMultiple() throws Exception {
QueryStatement stmt = new QueryStatement("select etag, name, id from enity where parentId == null");
// This is what we expect the parser to find.
List<String> expectedSelect = new ArrayList<String>();
expectedSelect.add("etag");
expectedSelect.add("name");
expectedSelect.add("id");
assertNotNull(stmt);
assertNotNull(stmt.getSelect());
assertEquals(expectedSelect, stmt.getSelect());
}
use of org.sagebionetworks.repo.web.query.QueryStatement in project Synapse-Repository-Services by Sage-Bionetworks.
the class QueryParserTest method testWhereEqualsNumber.
/**
* @throws Exception
*/
@Test
public void testWhereEqualsNumber() throws Exception {
QueryStatement stmt = new QueryStatement("select * from dataset where \"Number of Samples\" == 100");
assertEquals("dataset", stmt.getTableName());
assertNotNull(stmt.getSearchCondition());
assertEquals(1, stmt.getSearchCondition().size());
assertTrue(stmt.getSearchCondition().get(0) instanceof Expression);
Expression expression = (Expression) stmt.getSearchCondition().get(0);
assertEquals("Number of Samples", expression.getId().getFieldName());
assertEquals(new Long(100), expression.getValue());
}
use of org.sagebionetworks.repo.web.query.QueryStatement in project Synapse-Repository-Services by Sage-Bionetworks.
the class QueryParserTest method testLayerQuery.
/**
* @throws Exception
*/
@Test
public void testLayerQuery() throws Exception {
QueryStatement stmt = new QueryStatement("select * from layer where dataset.id == \"123\"");
assertEquals("layer", stmt.getTableName());
assertNotNull(stmt.getSearchCondition());
assertEquals(1, stmt.getSearchCondition().size());
assertTrue(stmt.getSearchCondition().get(0) instanceof Expression);
Expression expression = (Expression) stmt.getSearchCondition().get(0);
assertEquals("dataset", expression.getId().getTableName());
assertEquals("id", expression.getId().getFieldName());
assertEquals("123", expression.getValue());
}
use of org.sagebionetworks.repo.web.query.QueryStatement in project Synapse-Repository-Services by Sage-Bionetworks.
the class QueryParserTest method testNullValue.
@Test
public void testNullValue() throws Exception {
QueryStatement stmt = new QueryStatement("select * from enity where parentId == null");
assertNotNull(stmt.getSearchCondition());
assertEquals(1, stmt.getSearchCondition().size());
Expression expr = stmt.getSearchCondition().get(0);
assertNotNull(expr);
assertEquals("parentId", expr.getId().getFieldName());
assertEquals(null, expr.getValue());
}
Aggregations