use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testColumnWithColumnName.
/**
* Test case for {@link QueryObjectModelFactory#column(String, String, String)}
*/
public void testColumnWithColumnName() throws RepositoryException {
Column col = qf.column(SELECTOR_NAME1, propertyName1, COLUMN_NAME);
assertEquals("Wrong selector name", SELECTOR_NAME1, col.getSelectorName());
assertEquals("Wrong property name", propertyName1, col.getPropertyName());
assertEquals("Wrong column name", COLUMN_NAME, col.getColumnName());
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testColumnAllProperties.
/**
* Test case for {@link QueryObjectModelFactory#column(String, String, String)}
*/
public void testColumnAllProperties() throws RepositoryException {
Column col = qf.column(SELECTOR_NAME1, null, null);
assertEquals("Wrong selector name", SELECTOR_NAME1, col.getSelectorName());
assertNull("Property name must be null", col.getPropertyName());
assertNull("Column name must be null", col.getColumnName());
}
use of javax.jcr.query.qom.Column in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testColumn.
/**
* Test case for {@link QueryObjectModelFactory#column(String, String, String)}
*/
public void testColumn() throws RepositoryException {
Column col = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
assertEquals("Wrong selector name", SELECTOR_NAME1, col.getSelectorName());
assertEquals("Wrong property name", propertyName1, col.getPropertyName());
assertEquals("Wrong column name", propertyName1, col.getColumnName());
}
use of javax.jcr.query.qom.Column in project pentaho-platform by pentaho.
the class DefaultDeleteHelperTest method testGetDeletedFiles1.
@Test
public void testGetDeletedFiles1() throws Exception {
final String path1 = "path1";
final Calendar date1 = Calendar.getInstance();
final Node deletedNode1 = createDeletedNode(path1, date1);
final String path2 = "path2";
final Calendar date2 = Calendar.getInstance();
final Node deletedNode2 = createDeletedNode(path2, date2);
final NodeIterator nodeIterator = mock(NodeIterator.class);
// 2 nodes in trash
when(nodeIterator.hasNext()).thenReturn(true, true, false);
when(nodeIterator.nextNode()).thenReturn(deletedNode1, deletedNode2);
final Node nodeTrash = mock(Node.class);
when(nodeTrash.getNodes()).thenReturn(nodeIterator);
final Node nodeUserFolder = mock(Node.class);
when(nodeUserFolder.hasNode(nullable(String.class))).thenReturn(true);
when(nodeUserFolder.getNode(nullable(String.class))).thenReturn(nodeTrash);
when(nodeUserFolder.getIdentifier()).thenReturn("nodeUserFolderID");
final Selector selector = mock(Selector.class);
final Value value = mock(Value.class);
final ValueFactory valueFactory = mock(ValueFactory.class);
when(valueFactory.createValue(nullable(String.class))).thenReturn(value);
final QueryObjectModel queryObjectModel = mock(QueryObjectModel.class);
final QueryObjectModelFactory qomFactory = mock(QueryObjectModelFactory.class);
when(qomFactory.createQuery(ArgumentMatchers.<Source>any(), ArgumentMatchers.<Constraint>any(), ArgumentMatchers.<Ordering[]>any(), ArgumentMatchers.<Column[]>any())).thenReturn(queryObjectModel);
when(qomFactory.selector(nullable(String.class), nullable(String.class))).thenReturn(selector);
final QueryResult queryResult = mock(QueryResult.class);
when(queryResult.getNodes()).thenReturn(nodeIterator);
final Query query = mock(Query.class);
when(query.execute()).thenReturn(queryResult);
final QueryManager queryManager = mock(QueryManager.class);
when(queryManager.getQOMFactory()).thenReturn(qomFactory);
when(queryManager.createQuery(nullable(String.class), nullable(String.class))).thenReturn(query);
final Workspace workspace = mock(Workspace.class);
when(workspace.getQueryManager()).thenReturn(queryManager);
when(session.getItem(nullable(String.class))).thenReturn(nodeUserFolder);
when(session.getValueFactory()).thenReturn(valueFactory);
when(session.getWorkspace()).thenReturn(workspace);
when(session.itemExists(nullable(String.class))).thenReturn(true);
final String someFilter = "someFilter";
final List<RepositoryFile> deletedFiles = defaultDeleteHelper.getDeletedFiles(session, pentahoJcrConstants, path1, someFilter);
assertNotNull(deletedFiles);
assertEquals(2, deletedFiles.size());
for (RepositoryFile file : deletedFiles) {
if (file.getOriginalParentFolderPath().equals(path1)) {
assertEquals(file.getDeletedDate(), date1.getTime());
} else if (file.getOriginalParentFolderPath().equals(path2)) {
assertEquals(file.getDeletedDate(), date2.getTime());
} else {
fail("Deleted file doesn't have correct path");
}
}
verify(valueFactory).createValue(someFilter);
}
use of javax.jcr.query.qom.Column in project jackrabbit-oak by apache.
the class QomTest method jcrNameConversion.
@Test
public void jcrNameConversion() throws RepositoryException {
assertEquals("[nt:base]", f.column(null, NodeType.NT_BASE, null).toString());
assertEquals("[s1].[nt:base] = [s2].[nt:base]", f.equiJoinCondition("s1", NodeType.NT_BASE, "s2", NodeType.NT_BASE).toString());
assertEquals("CONTAINS([nt:base], null)", f.fullTextSearch(null, NodeType.NT_BASE, null).toString());
assertEquals("CAST('nt:base' AS NAME)", f.literal(vf.createValue(NodeType.NT_BASE, PropertyType.NAME)).toString());
assertEquals("[nt:base] IS NOT NULL", f.propertyExistence(null, NodeType.NT_BASE).toString());
assertEquals("[nt:base]", f.propertyValue(null, NodeType.NT_BASE).toString());
assertEquals("[nt:base]", f.selector(NodeType.NT_BASE, null).toString());
Source source1 = f.selector(NodeType.NT_BASE, "selector");
Column[] columns = new Column[] { f.column("selector", null, null) };
Constraint constraint2 = f.childNode("selector", "/");
QueryObjectModel qom = f.createQuery(source1, constraint2, null, columns);
assertEquals("select [selector].* from " + "[nt:base] AS [selector] " + "where ISCHILDNODE([selector], [/])", qom.toString());
}
Aggregations