use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testRemoveGuestbook.
/**
* Moving to ChildB
* Guestbook is null because target does not include it
*/
@Test
public void testRemoveGuestbook() throws Exception {
DataverseRequest aRequest = new DataverseRequest(auth, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, childB, true));
assertNull(moved.getGuestbook());
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testKeepGuestbookInherit.
/**
* Moving to grandchildBB
* Guestbook is not null because target inherits it.
*/
@Test
public void testKeepGuestbookInherit() throws Exception {
DataverseRequest aRequest = new DataverseRequest(auth, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, grandchildBB, null));
assertNotNull(moved.getGuestbook());
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testInvalidMovePublishedToUnpublished.
/**
* Moving published DS to unpublished DV
* @throws IllegalCommandException
*/
@Test(expected = IllegalCommandException.class)
public void testInvalidMovePublishedToUnpublished() throws Exception {
DataverseRequest aRequest = new DataverseRequest(auth, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, childDraft, null));
fail();
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class SubmitDatasetForReviewCommandTest method setUp.
@Before
public void setUp() {
dataset = new Dataset();
HttpServletRequest aHttpServletRequest = null;
dataverseRequest = new DataverseRequest(MocksFactory.makeAuthenticatedUser("First", "Last"), aHttpServletRequest);
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public AuthenticationServiceBean authentication() {
return new AuthenticationServiceBean() {
@Override
public AuthenticatedUser getAuthenticatedUser(String id) {
return MocksFactory.makeAuthenticatedUser("First", "Last");
}
};
}
@Override
public IndexServiceBean index() {
return new IndexServiceBean() {
@Override
public Future<String> indexDataset(Dataset dataset, boolean doNormalSolrDocCleanUp) {
return null;
}
};
}
@Override
public EntityManager em() {
return new TestEntityManager() {
@Override
public <T> T merge(T entity) {
return entity;
}
@Override
public void flush() {
// nothing to do here
}
};
}
@Override
public DatasetServiceBean datasets() {
return new DatasetServiceBean() {
{
em = new NoOpTestEntityManager();
}
@Override
public DatasetVersionUser getDatasetVersionUser(DatasetVersion version, User user) {
return null;
}
@Override
public DatasetLock addDatasetLock(Long datasetId, DatasetLock.Reason reason, Long userId, String info) {
return null;
}
};
}
@Override
public DataverseRoleServiceBean roles() {
return new DataverseRoleServiceBean() {
@Override
public DataverseRole findBuiltinRoleByAlias(String alias) {
return new DataverseRole();
}
@Override
public RoleAssignment save(RoleAssignment assignment) {
// no-op
return assignment;
}
};
}
@Override
public PermissionServiceBean permissions() {
return new PermissionServiceBean() {
@Override
public List<AuthenticatedUser> getUsersWithPermissionOn(Permission permission, DvObject dvo) {
// We only need permissions for notifications, which we are testing in InReviewWorkflowIT.
return Collections.emptyList();
}
};
}
});
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class CreateDataverseCommandTest method testCustomOptions.
@Test
public void testCustomOptions() throws CommandException {
Dataverse dv = makeDataverse();
Timestamp creation = timestamp(1990, 12, 12);
AuthenticatedUser creator = makeAuthenticatedUser("Joe", "Walsh");
dv.setCreateDate(creation);
dv.setId(null);
dv.setCreator(creator);
dv.setDefaultContributorRole(null);
dv.setOwner(makeDataverse());
dv.setDataverseType(Dataverse.DataverseType.JOURNALS);
dv.setDefaultContributorRole(roles.findBuiltinRoleByAlias(DataverseRole.MANAGER));
final DataverseRequest request = makeRequest();
List<DatasetFieldType> expectedFacets = Arrays.asList(makeDatasetFieldType(), makeDatasetFieldType(), makeDatasetFieldType());
List<DataverseFieldTypeInputLevel> dftils = Arrays.asList(makeDataverseFieldTypeInputLevel(makeDatasetFieldType()), makeDataverseFieldTypeInputLevel(makeDatasetFieldType()), makeDataverseFieldTypeInputLevel(makeDatasetFieldType()));
CreateDataverseCommand sut = new CreateDataverseCommand(dv, request, new LinkedList(expectedFacets), new LinkedList(dftils));
Dataverse result = engine.submit(sut);
assertEquals(creation, result.getCreateDate());
assertNotNull(result.getId());
assertEquals(creator, result.getCreator());
assertEquals(Dataverse.DataverseType.JOURNALS, result.getDataverseType());
assertEquals(roles.findBuiltinRoleByAlias(DataverseRole.MANAGER), result.getDefaultContributorRole());
// Assert that the creator is admin.
final RoleAssignment roleAssignment = roles.directRoleAssignments(dv).get(0);
assertEquals(roles.findBuiltinRoleByAlias(DataverseRole.ADMIN), roleAssignment.getRole());
assertEquals(dv, roleAssignment.getDefinitionPoint());
assertEquals(roleAssignment.getAssigneeIdentifier(), request.getUser().getIdentifier());
assertTrue(result.isPermissionRoot());
assertTrue(result.isThemeRoot());
assertTrue(indexCalled);
assertTrue(facetsDeleted);
int i = 0;
for (DataverseFacet df : createdFacets) {
assertEquals(i, df.getDisplayOrder());
assertEquals(result, df.getDataverse());
assertEquals(expectedFacets.get(i), df.getDatasetFieldType());
i++;
}
assertTrue(dftilsDeleted);
for (DataverseFieldTypeInputLevel dftil : createdDftils) {
assertEquals(result, dftil.getDataverse());
}
}
Aggregations