use of edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean in project dataverse by IQSS.
the class CreatePrivateUrlCommandTest method setUp.
@Before
public void setUp() {
dataset = new Dataset();
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public PrivateUrlServiceBean privateUrl() {
return new PrivateUrlServiceBean() {
@Override
public PrivateUrl getPrivateUrlFromDatasetId(long datasetId) {
if (datasetId == privateUrlAlreadyExists) {
Dataset dataset = new Dataset();
dataset.setId(privateUrlAlreadyExists);
String token = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
RoleAssignment roleAssignment = new RoleAssignment(null, privateUrlUser, dataset, token);
return new PrivateUrl(roleAssignment, dataset, "FIXME");
} else if (datasetId == latestVersionIsNotDraft) {
return null;
} else {
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 SystemConfig systemConfig() {
return new SystemConfig() {
@Override
public String getDataverseSiteUrl() {
return "https://dataverse.example.edu";
}
};
}
});
}
use of edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean in project dataverse by IQSS.
the class DeletePrivateUrlCommandTest method setUp.
@Before
public void setUp() {
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public PrivateUrlServiceBean privateUrl() {
return new PrivateUrlServiceBean() {
@Override
public PrivateUrl getPrivateUrlFromDatasetId(long datasetId) {
if (datasetId == noPrivateUrlToDelete) {
return null;
} else if (datasetId == hasPrivateUrlToDelete) {
Dataset dataset = new Dataset();
dataset.setId(hasPrivateUrlToDelete);
String token = null;
PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
RoleAssignment roleAssignment = new RoleAssignment(null, privateUrlUser, dataset, token);
return new PrivateUrl(roleAssignment, dataset, "FIXME");
} else {
return null;
}
}
};
}
@Override
public DataverseRoleServiceBean roles() {
return new DataverseRoleServiceBean() {
@Override
public List<RoleAssignment> directRoleAssignments(RoleAssignee roas, DvObject dvo) {
RoleAssignment roleAssignment = new RoleAssignment();
List<RoleAssignment> list = new ArrayList<>();
list.add(roleAssignment);
return list;
}
@Override
public void revoke(RoleAssignment ra) {
// no-op
}
};
}
});
}
Aggregations