use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SecurityServiceTest method testSetOwner.
@Test
public void testSetOwner() {
ExpressionExperiment ee = super.getTestPersistentBasicExpressionExperiment();
this.securityService.makePrivate(ee);
String username = "first_" + this.randomName();
this.makeUser(username);
this.securityService.setOwner(ee, username);
Sid owner = this.securityService.getOwner(ee);
assertTrue(owner instanceof AclPrincipalSid);
assertEquals(username, ((AclPrincipalSid) owner).getPrincipal());
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SecurityServiceTest method testSetPrincipalSID.
/*
* Test to ensure that on creation of principal using a username that does not exist in system exception is thrown.
* Principal ids are created in these method calls on SecurityService.
*/
@Test
public void testSetPrincipalSID() {
String username = "first_" + this.randomName();
ExpressionExperiment ee = super.getTestPersistentBasicExpressionExperiment();
this.securityService.makePrivate(ee);
try {
this.securityService.setOwner(ee, username);
fail();
} catch (Exception ignored) {
}
try {
this.securityService.makeOwnedByUser(ee, username);
fail();
} catch (Exception ignored) {
}
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SecurityServiceTest method testRemoveMultipleAcesFromPrivateExpressionExperiment.
/*
* Tests an unlikely scenario?? but if there is an acl that was duplicated with same principal, permission and
* object then both acls can be deleted.
*/
@Test
public void testRemoveMultipleAcesFromPrivateExpressionExperiment() {
// make private experiment
ExpressionExperiment ee = super.getTestPersistentBasicExpressionExperiment();
this.securityService.makePrivate(ee);
// add user and add the user to a group
String username = "salmonid";
String groupName = "fish" + this.randomName();
this.makeUser(username);
this.securityService.makeOwnedByUser(ee, username);
assertTrue(this.securityService.isEditableByUser(ee, username));
this.runAsUser(username);
this.securityService.createGroup(groupName);
// get the basic acls
MutableAcl acl = aclTestUtils.getAcl(ee);
int numberOfAces = acl.getEntries().size();
// make readable by group add first ACE read for group and check added
this.securityService.makeReadableByGroup(ee, groupName);
MutableAcl aclAfterReadableAdded = aclTestUtils.getAcl(ee);
assertEquals(numberOfAces + 1, aclAfterReadableAdded.getEntries().size());
// force the addition of duplicate ACE read, fish group on the same experiment. Note that in the current
// implementation this only adds one - we already avoid duplicates.
List<GrantedAuthority> groupAuthorities = this.userManager.findGroupAuthorities(groupName);
GrantedAuthority ga = groupAuthorities.get(0);
aclAfterReadableAdded.insertAce(aclAfterReadableAdded.getEntries().size(), BasePermission.READ, new AclGrantedAuthoritySid(this.userManager.getRolePrefix() + ga), true);
this.aclTestUtils.update(aclAfterReadableAdded);
MutableAcl aclAfterReadableAddedDuplicate = aclTestUtils.getAcl(ee);
assertEquals(numberOfAces + 1, aclAfterReadableAddedDuplicate.getEntries().size());
// remove the ace now and check removed permission completely.
this.securityService.makeUnreadableByGroup(ee, groupName);
MutableAcl aclAfterReadableAddedDuplicateRemoval = aclTestUtils.getAcl(ee);
assertEquals(numberOfAces, aclAfterReadableAddedDuplicateRemoval.getEntries().size());
List<AccessControlEntry> entriesAfterDelete = aclAfterReadableAddedDuplicateRemoval.getEntries();
assertEquals(numberOfAces, entriesAfterDelete.size());
// also check that the right ACE check the principals
Collection<String> principals = new ArrayList<>();
principals.add("AclGrantedAuthoritySid[GROUP_ADMIN]");
principals.add("AclGrantedAuthoritySid[GROUP_AGENT]");
principals.add("AclPrincipalSid[salmonid]");
principals.add("AclPrincipalSid[salmonid]");
for (AccessControlEntry accessControl : entriesAfterDelete) {
Sid sid = accessControl.getSid();
assertTrue(principals.contains(sid.toString()));
// remove it once in case found in case of duplicates
principals.remove(sid.toString());
}
// clean up the groups
this.userManager.deleteGroup(groupName);
// userManager.deleteUser( username );
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class DifferentialExpressionAnalysisServiceTest method setup.
@Before
public void setup() {
e1 = ExpressionExperiment.Factory.newInstance();
e1.setShortName(RandomStringUtils.randomAlphabetic(6));
e1 = expressionExperimentService.create(e1);
e2 = ExpressionExperiment.Factory.newInstance();
e2.setShortName(RandomStringUtils.randomAlphabetic(6));
e2 = expressionExperimentService.create(e2);
e3 = ExpressionExperiment.Factory.newInstance();
e3.setShortName(RandomStringUtils.randomAlphabetic(6));
e3 = expressionExperimentService.create(e3);
ExpressionExperiment e4 = ExpressionExperiment.Factory.newInstance();
e4.setShortName(RandomStringUtils.randomAlphabetic(6));
expressionExperimentService.create(e4);
// //////////////////
DifferentialExpressionAnalysis eAnalysis1 = DifferentialExpressionAnalysis.Factory.newInstance();
eAnalysis1.setExperimentAnalyzed(e1);
dea1_name = RandomStringUtils.randomAlphabetic(6);
eAnalysis1.setName(dea1_name);
eAnalysis1.setDescription("An analysis Test 1");
analysisService.create(eAnalysis1);
// ///////////////
DifferentialExpressionAnalysis eAnalysis2 = DifferentialExpressionAnalysis.Factory.newInstance();
eAnalysis2.setExperimentAnalyzed(e2);
dea2_name = RandomStringUtils.randomAlphabetic(6);
eAnalysis2.setName(dea2_name);
eAnalysis2.setDescription("An analysis Test 2");
analysisService.create(eAnalysis2);
// /////////////
DifferentialExpressionAnalysis eAnalysis3 = DifferentialExpressionAnalysis.Factory.newInstance();
eAnalysis3.setExperimentAnalyzed(e3);
this.testAnalysisName = RandomStringUtils.randomAlphabetic(6);
eAnalysis3.setName(testAnalysisName);
eAnalysis3.setDescription("An analysis Test 3");
analysisService.create(eAnalysis3);
// ////
DifferentialExpressionAnalysis eAnalysis4 = DifferentialExpressionAnalysis.Factory.newInstance();
eAnalysis4.setExperimentAnalyzed(e3);
testEESetName = RandomStringUtils.randomAlphabetic(6);
eAnalysis4.setName(testEESetName);
eAnalysis4.setDescription("An analysis Test 4");
analysisService.create(eAnalysis4);
}
use of ubic.gemma.model.expression.experiment.ExpressionExperiment in project Gemma by PavlidisLab.
the class SVDServiceImplTest method testsvd.
@Test
public void testsvd() throws Exception {
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("shortTest")));
// also used in the GeoDatasetServiceIntegrationTest.
try {
Collection<?> results = geoService.fetchAndLoad("GSE674", false, true, false);
ee = (ExpressionExperiment) results.iterator().next();
} catch (AlreadyExistsInSystemException e) {
ee = (ExpressionExperiment) ((Collection<?>) e.getData()).iterator().next();
}
assertNotNull(ee);
ee = eeService.thaw(ee);
processedExpressionDataVectorService.createProcessedDataVectors(ee);
ee = eeService.findByShortName("GSE674");
assertNotNull(ee);
SVDValueObject svd = svdService.svd(ee.getId());
assertNotNull(svd);
assertNotNull(svd.getvMatrix());
assertEquals(5, svd.getFactorCorrelations().size());
analysisUtilService.deleteOldAnalyses(ee);
}
Aggregations