use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class DeletePrivateUrlCommandTest method testSuccessfulDelete.
@Test
public void testSuccessfulDelete() {
dataset = new Dataset();
dataset.setId(hasPrivateUrlToDelete);
String actual = null;
try {
testEngine.submit(new DeletePrivateUrlCommand(null, dataset));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertNull(actual);
/**
* @todo How would we confirm that the role assignement is actually
* gone? Really all we're testing above is that there was no
* IllegalCommandException from submitting the command.
*/
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class RequestRsyncScriptCommandTest method testHappyPath.
@Test
public void testHappyPath() throws Exception {
dataset = new Dataset();
dataset.setIdentifier("42");
HttpServletRequest aHttpServletRequest = null;
DataverseRequest dataverseRequest = new DataverseRequest(MocksFactory.makeAuthenticatedUser("First", "Last"), aHttpServletRequest);
ScriptRequestResponse scriptRequestResponse = testEngine.submit(new RequestRsyncScriptCommand(dataverseRequest, dataset));
assertEquals("theScript", scriptRequestResponse.getScript());
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class ReturnDatasetToAuthorCommandTest method testDatasetNull.
/*
if (theDataset == null) {
throw new IllegalCommandException("Can't return to author. Dataset is null.", this);
}
if (!theDataset.getLatestVersion().isInReview()) {
throw new IllegalCommandException("Latest version of dataset " + theDataset.getIdentifier() + " is not In Review. Only such versions my be returned to author.", this);
}
if (theDataset.getLatestVersion().getReturnReason() == null || theDataset.getLatestVersion().getReturnReason().isEmpty()){
throw new IllegalCommandException("You must enter a reason for returning a dataset to its author.", this);
}
*/
@Test
public void testDatasetNull() {
dataset = null;
String expected = "Cannot return the dataset to the author(s) because it is null.";
String actual = null;
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new ReturnDatasetToAuthorCommand(dataverseRequest, dataset, ""));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(updatedDataset);
}
use of edu.harvard.iq.dataverse.Dataset in project dataverse by IQSS.
the class ReturnDatasetToAuthorCommandTest 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 NoOpTestEntityManager();
}
@Override
public DatasetServiceBean datasets() {
return new DatasetServiceBean() {
{
em = new NoOpTestEntityManager();
}
@Override
public DatasetVersionUser getDatasetVersionUser(DatasetVersion version, User user) {
return null;
}
@Override
public WorkflowComment addWorkflowComment(WorkflowComment comment) {
return comment;
}
@Override
public void removeDatasetLocks(Long datasetId, DatasetLock.Reason aReason) {
}
};
}
@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.Dataset in project dataverse by IQSS.
the class UpdateDatasetThumbnailCommandTest method setUp.
@Before
public void setUp() {
dataset = new Dataset();
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public DataFileServiceBean files() {
return new DataFileServiceBean() {
@Override
public DataFile find(Object object) {
if (object == unfindableFile) {
return null;
} else if (object == thumbnailUnexpectedlyAbsent) {
return new DataFile();
} else {
return null;
}
}
};
}
@Override
public DatasetServiceBean datasets() {
return new DatasetServiceBean() {
@Override
public Dataset setDatasetFileAsThumbnail(Dataset dataset, DataFile datasetFileThumbnailToSwitchTo) {
return dataset;
}
};
}
@Override
public SystemConfig systemConfig() {
return new SystemConfig() {
@Override
public String getDataverseSiteUrl() {
return "https://dataverse.example.edu";
}
};
}
});
}
Aggregations