use of edu.harvard.iq.dataverse.engine.TestCommandContext in project dataverse by IQSS.
the class CreateDatasetVersionCommandTest method testCantCreateTwoDraftVersions.
@Test(expected = IllegalCommandException.class)
public void testCantCreateTwoDraftVersions() throws Exception {
DatasetVersion dsvNew = new DatasetVersion();
dsvNew.setVersionState(DatasetVersion.VersionState.DRAFT);
// Execute
CreateDatasetVersionCommand sut = new CreateDatasetVersionCommand(makeRequest(), makeDataset(), dsvNew);
TestDataverseEngine testEngine = new TestDataverseEngine(new TestCommandContext());
testEngine.submit(sut);
}
use of edu.harvard.iq.dataverse.engine.TestCommandContext 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.TestCommandContext in project dataverse by IQSS.
the class UpdatePermissionRootCommandTest method setUp.
@Before
public void setUp() {
mockBean = new DataverseServiceBean() {
@Override
public Dataverse save(Dataverse dv) {
serviceBeanCalled = true;
return dv;
}
};
testCommandContext = new TestCommandContext() {
@Override
public DataverseServiceBean dataverses() {
return mockBean;
}
};
serviceBeanCalled = false;
}
Aggregations