@Test public void hibernateMigrate() throws Exception { this.mocker.registerMockComponent(ComponentManager.class); ComponentManager cm = this.mocker.getInstance(ComponentManager.class); XWikiHibernateStore store = mock(XWikiHibernateStore.class); when(cm.getInstance(XWikiStoreInterface.class, "hibernate")).thenReturn(store); Execution e = this.mocker.getInstance(Execution.class); ExecutionContext ec = mock(ExecutionContext.class); when(e.getContext()).thenReturn(ec); XWikiContext xc = mock(XWikiContext.class); when(ec.getProperty("xwikicontext")).thenReturn(xc); @SuppressWarnings("deprecation") ArgumentCaptor<HibernateCallback<Object>> callbackCaptor = new ArgumentCaptor<>(); this.mocker.getComponentUnderTest().migrate(); Mockito.verify(store).executeWrite(Matchers.same(xc), callbackCaptor.capture()); XWiki xwiki = mock(XWiki.class); when(xc.getWiki()).thenReturn(xwiki); HibernateCallback<Object> callback = callbackCaptor.getValue(); Assert.assertNotNull(callback); Session session = mock(Session.class); Query q = mock(Query.class); when(session.createQuery(Matchers.anyString())).thenReturn(q); List<String> docs = new ArrayList<>(); docs.add("data.hasNoVisibility"); when(q.list()).thenReturn(docs); DocumentReferenceResolver<String> resolver = this.mocker.getInstance(DocumentReferenceResolver.TYPE_STRING, "current"); DocumentReference r1 = new DocumentReference("xwiki", "data", "hasNoVisibility"); when(resolver.resolve("data.hasNoVisibility")).thenReturn(r1); XWikiDocument p1 = mock(XWikiDocument.class); when(xwiki.getDocument(r1, xc)).thenReturn(p1); BaseObject o1 = mock(BaseObject.class); when(p1.newXObject(Visibility.CLASS_REFERENCE, xc)).thenReturn(o1); callback.doInHibernate(session); verify(o1).set("visibility", "private", xc); }
@Override public void hibernateMigrate() throws DataMigrationException, XWikiException { getStore().executeWrite(getXWikiContext(), new AddVisObjectCallback()); }
R54692PhenoTips1378DataMigration extends AbstractHibernateDataMigration { @Override public void hibernateMigrate() throws DataMigrationException, XWikiException { getStore().executeWrite(getXWikiContext(), new AddVisObjectCallback()); } }
R54692PhenoTips1378DataMigration extends AbstractHibernateDataMigration { @Override public void hibernateMigrate() throws DataMigrationException, XWikiException { getStore().executeWrite(getXWikiContext(), new AddVisObjectCallback()); }  }
R54692PhenoTips1378DataMigration extends AbstractHibernateDataMigration { @Override public void hibernateMigrate() throws DataMigrationException, XWikiException { getStore().executeWrite(getXWikiContext(), new AddVisObjectCallback()); }  @Override String getDescription(); @Override XWikiDBVersion getVersion(); @Override void hibernateMigrate(); }
R54692PhenoTips1378DataMigration extends AbstractHibernateDataMigration { @Override public void hibernateMigrate() throws DataMigrationException, XWikiException { getStore().executeWrite(getXWikiContext(), new AddVisObjectCallback()); }  @Override String getDescription(); @Override XWikiDBVersion getVersion(); @Override void hibernateMigrate();  }