use of edu.harvard.iq.dataverse.Dataverse in project dataverse by IQSS.
the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNonDataset.
@Test
public void testGetDatasetFromRoleAssignmentNonDataset() {
DataverseRole aRole = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
RoleAssignee anAssignee = privateUrlUser;
DvObject nonDataset = new Dataverse();
String privateUrlToken = null;
RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
use of edu.harvard.iq.dataverse.Dataverse in project dataverse by IQSS.
the class MoveDataverseCommandTest method setUp.
@Before
public void setUp() {
root = new Dataverse();
root.setName("root");
root.setId(1l);
childA = new Dataverse();
childA.setName("childA");
childA.setId(2l);
childB = new Dataverse();
childB.setName("childB");
childB.setId(3l);
grandchildAA = new Dataverse();
grandchildAA.setName("grandchildAA");
grandchildAA.setId(4l);
childA.setOwner(root);
childB.setOwner(root);
grandchildAA.setOwner(childA);
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public DataverseServiceBean dataverses() {
return new DataverseServiceBean() {
@Override
public Dataverse save(Dataverse dataverse) {
// no-op. The superclass accesses databases which we don't have.
return dataverse;
}
};
}
});
}
use of edu.harvard.iq.dataverse.Dataverse in project dataverse by IQSS.
the class UpdatePermissionRootCommandTest method testNoChange.
@Test
public void testNoChange() throws CommandException {
Dataverse dv = MocksFactory.makeDataverse();
DataverseEngine ngn = new TestDataverseEngine(testCommandContext);
dv.setPermissionRoot(false);
UpdatePermissionRootCommand sut = new UpdatePermissionRootCommand(false, MocksFactory.makeRequest(), dv);
Dataverse result = ngn.submit(sut);
assertFalse(result.isPermissionRoot());
assertFalse(serviceBeanCalled);
dv.setPermissionRoot(true);
sut = new UpdatePermissionRootCommand(true, MocksFactory.makeRequest(), dv);
result = ngn.submit(sut);
assertTrue(result.isPermissionRoot());
assertFalse(serviceBeanCalled);
}
use of edu.harvard.iq.dataverse.Dataverse in project dataverse by IQSS.
the class UpdatePermissionRootCommandTest method testChange.
@Test
public void testChange() throws CommandException {
Dataverse dv = MocksFactory.makeDataverse();
DataverseEngine ngn = new TestDataverseEngine(testCommandContext);
dv.setPermissionRoot(false);
UpdatePermissionRootCommand sut = new UpdatePermissionRootCommand(true, MocksFactory.makeRequest(), dv);
Dataverse result = ngn.submit(sut);
assertTrue(result.isPermissionRoot());
assertTrue(serviceBeanCalled);
dv.setPermissionRoot(true);
sut = new UpdatePermissionRootCommand(false, MocksFactory.makeRequest(), dv);
result = ngn.submit(sut);
assertFalse(result.isPermissionRoot());
assertTrue(serviceBeanCalled);
}
use of edu.harvard.iq.dataverse.Dataverse in project dataverse by IQSS.
the class FileUtilTest method testIsDownloadPopupRequiredHasGuestBook.
@Test
public void testIsDownloadPopupRequiredHasGuestBook() {
DatasetVersion datasetVersion = new DatasetVersion();
datasetVersion.setVersionState(DatasetVersion.VersionState.RELEASED);
Dataset dataset = new Dataset();
datasetVersion.setDataset(dataset);
Guestbook guestbook = new Guestbook();
guestbook.setEnabled(true);
dataset.setGuestbook(guestbook);
Dataverse dataverse = new Dataverse();
guestbook.setDataverse(dataverse);
assertEquals(true, FileUtil.isDownloadPopupRequired(datasetVersion));
}
Aggregations