use of org.hamcrest.object.HasToString in project xwiki-platform by xwiki.
the class XWikiHibernateRecycleBinStoreTest method getAllDeletedDocuments.
@Test
public void getAllDeletedDocuments() throws Exception {
XWikiDocument document = mock(XWikiDocument.class);
when(document.getFullName()).thenReturn("Space.Page");
when(document.getLanguage()).thenReturn("ro");
List<XWikiDeletedDocument> deletedVersions = Arrays.asList(mock(XWikiDeletedDocument.class, "v1"), mock(XWikiDeletedDocument.class, "v2"));
Criteria criteria = mock(Criteria.class);
when(criteria.list()).thenReturn(deletedVersions);
when(session.createCriteria(XWikiDeletedDocument.class)).thenReturn(criteria);
assertArrayEquals(deletedVersions.toArray(new XWikiDeletedDocument[2]), mocker.getComponentUnderTest().getAllDeletedDocuments(document, xcontext, true));
// Too bad the restrictions don't implement equals..
verify(criteria).add(argThat(new HasToString<SimpleExpression>(equalTo("fullName=Space.Page"))));
verify(criteria).add(argThat(new HasToString<SimpleExpression>(equalTo("language=ro"))));
verify(criteria).addOrder(argThat(new HasToString<Order>(equalTo("date desc"))));
}
use of org.hamcrest.object.HasToString in project xwiki-platform by xwiki.
the class XWikiHibernateRecycleBinStoreTest method getAllDeletedDocumentsWhenLanguageIsEmpty.
@Test
public void getAllDeletedDocumentsWhenLanguageIsEmpty() throws Exception {
Criteria criteria = mock(Criteria.class);
when(session.createCriteria(XWikiDeletedDocument.class)).thenReturn(criteria);
mocker.getComponentUnderTest().getAllDeletedDocuments(mock(XWikiDocument.class), xcontext, true);
// Too bad the restrictions don't implement equals..
verify(criteria).add(argThat(new HasToString<SimpleExpression>(equalTo("fullName=null"))));
verify(criteria).add(argThat(new HasToString<SimpleExpression>(equalTo("language= or language is null"))));
}
Aggregations