Search in sources :

Example 21 with ExpressionExperiment

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());
}
Also used : AclPrincipalSid(gemma.gsec.acl.domain.AclPrincipalSid) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AclPrincipalSid(gemma.gsec.acl.domain.AclPrincipalSid) AclGrantedAuthoritySid(gemma.gsec.acl.domain.AclGrantedAuthoritySid) Sid(org.springframework.security.acls.model.Sid) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 22 with ExpressionExperiment

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) {
    }
}
Also used : ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 23 with ExpressionExperiment

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 );
}
Also used : GrantedAuthority(org.springframework.security.core.GrantedAuthority) AclGrantedAuthoritySid(gemma.gsec.acl.domain.AclGrantedAuthoritySid) AccessControlEntry(org.springframework.security.acls.model.AccessControlEntry) MutableAcl(org.springframework.security.acls.model.MutableAcl) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AclPrincipalSid(gemma.gsec.acl.domain.AclPrincipalSid) AclGrantedAuthoritySid(gemma.gsec.acl.domain.AclGrantedAuthoritySid) Sid(org.springframework.security.acls.model.Sid) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 24 with ExpressionExperiment

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);
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) Before(org.junit.Before)

Example 25 with ExpressionExperiment

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);
}
Also used : Collection(java.util.Collection) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Aggregations

ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)214 Test (org.junit.Test)71 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)42 InputStream (java.io.InputStream)36 GeoSeries (ubic.gemma.core.loader.expression.geo.model.GeoSeries)29 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)29 GZIPInputStream (java.util.zip.GZIPInputStream)28 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)26 HashSet (java.util.HashSet)25 BioAssaySet (ubic.gemma.model.expression.experiment.BioAssaySet)25 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)23 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)22 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)20 Collection (java.util.Collection)18 StopWatch (org.apache.commons.lang3.time.StopWatch)18 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)18 Taxon (ubic.gemma.model.genome.Taxon)14 Before (org.junit.Before)12 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11