Search in sources :

Example 11 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class DiffExMetaAnalyzerServiceTest method cleanup.

private void cleanup() {
    for (GeneDifferentialExpressionMetaAnalysisSummaryValueObject vo : geneDiffExMetaAnalysisHelperService.loadAllMetaAnalyses()) {
        analysisService.delete(vo.getId());
    }
    this.deleteSet("GSE2018");
    this.deleteSet("GSE2111");
    this.deleteSet("GSE6344");
    ArrayDesign gpl96 = arrayDesignService.findByShortName("GPL96");
    ArrayDesign gpl97 = arrayDesignService.findByShortName("GPL97");
    if (gpl96 != null) {
        for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl96)) {
            experimentService.remove(ee);
        }
        arrayDesignService.remove(gpl96);
    }
    if (gpl97 != null) {
        for (ExpressionExperiment ee : arrayDesignService.getExpressionExperiments(gpl97)) {
            experimentService.remove(ee);
        }
        arrayDesignService.remove(gpl97);
    }
    Collection<Gene> genes = geneService.loadAll();
    for (Gene gene : genes) {
        try {
            geneService.remove(gene);
        } catch (Exception e) {
            log.warn("Failed to remove gene " + gene);
        }
    }
}
Also used : Gene(ubic.gemma.model.genome.Gene) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException)

Example 12 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class AclAdviceTest method testNumExperiments.

@Test
public void testNumExperiments() {
    this.runAsAdmin();
    ArrayDesign ad = super.getTestPersistentArrayDesign(10, true);
    ExpressionExperiment ee = super.getTestPersistentBasicExpressionExperiment(ad);
    securityService.makePrivate(ee);
    ExpressionExperiment ee2 = super.getTestPersistentBasicExpressionExperiment(ad);
    securityService.makePublic(ee2);
    // admin can see everything
    assertEquals(2, arrayDesignService.getExpressionExperiments(ad).size());
    // anonymous can only see the public set
    this.runAsAnonymous();
    assertEquals(1, arrayDesignService.numExperiments(ad));
    // make the other data set public too...
    this.runAsAdmin();
    securityService.makePublic(ee);
    // anonymous can see both
    this.runAsAnonymous();
    assertEquals(2, arrayDesignService.numExperiments(ad));
    // logged-in user can also see both
    String user = RandomStringUtils.randomAlphabetic(10);
    this.makeUser(user);
    this.runAsUser(user);
    assertEquals(2, arrayDesignService.numExperiments(ad));
    // make data set private
    this.runAsAdmin();
    securityService.makePrivate(ee);
    assertEquals(2, arrayDesignService.numExperiments(ad));
    // user can't see data set that is now private
    this.runAsUser(user);
    assertEquals(1, arrayDesignService.numExperiments(ad));
    // make the data set owned by user; now they can see both that one and the public one
    this.runAsAdmin();
    securityService.setOwner(ee, user);
    this.runAsUser(user);
    assertEquals(2, arrayDesignService.numExperiments(ad));
    // anonymous can only see the public one.
    this.runAsAnonymous();
    assertEquals(1, arrayDesignService.numExperiments(ad));
    // create a new user group, add user to it, make ee2 private to group
    this.runAsAdmin();
    String group = RandomStringUtils.randomAlphabetic(10);
    securityService.createGroup(group);
    securityService.addUserToGroup(user, group);
    securityService.makeReadableByGroup(ee2, group);
    securityService.makePrivate(ee2);
    assertEquals(2, arrayDesignService.numExperiments(ad));
    // anonymous can't see private groups
    this.runAsAnonymous();
    assertEquals(0, arrayDesignService.numExperiments(ad));
    // user can view experiment he owns as well as one shared with him
    this.runAsUser(user);
    assertEquals(2, arrayDesignService.numExperiments(ad));
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 13 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class AclAdviceTest method testArrayDesignAclsUser.

@Test
public void testArrayDesignAclsUser() {
    String userName = "testuser" + RandomStringUtils.randomAlphabetic(3);
    this.makeUser(userName);
    this.runAsUser(userName);
    ArrayDesign ad = this.getTestPersistentArrayDesign(2, true, false, false);
    aclTestUtils.checkHasAcl(ad);
    aclTestUtils.checkHasAces(ad);
    Sid owner = securityService.getOwner(ad);
    assertEquals(userName, ((AclPrincipalSid) owner).getPrincipal());
    arrayDesignService.update(ad);
    assertEquals(userName, ((AclPrincipalSid) owner).getPrincipal());
    arrayDesignService.remove(ad);
    aclTestUtils.checkDeletedAcl(ad);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) AclPrincipalSid(gemma.gsec.acl.domain.AclPrincipalSid) Sid(org.springframework.security.acls.model.Sid) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 14 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class AclAdviceTest method testArrayDesignAcls.

/*
     * Create Array design, check ACLs are put on correctly and removed when the design is removed. Array Designs are
     * _simple_ compared to EEs!
     */
@Test
public void testArrayDesignAcls() {
    // need to modify
    ArrayDesign ad = this.getTestPersistentArrayDesign(2, true, false, false);
    aclTestUtils.checkHasAcl(ad);
    aclTestUtils.checkHasAces(ad);
    Sid owner = securityService.getOwner(ad);
    assertEquals("administrator", ((AclPrincipalSid) owner).getPrincipal());
    arrayDesignService.remove(ad);
    aclTestUtils.checkDeletedAcl(ad);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) AclPrincipalSid(gemma.gsec.acl.domain.AclPrincipalSid) Sid(org.springframework.security.acls.model.Sid) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Example 15 with ArrayDesign

use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.

the class SecurityServiceTest method testMakePrivateWithoutPermission.

/*
     * Tests changing object level security on the ArrayDesign from public to private WITHOUT the correct permission
     * (You need to be administrator).
     */
@Test
public void testMakePrivateWithoutPermission() {
    this.makeUser("unauthorizedTestUser");
    // test setup.
    this.runAsUser("unauthorizedTestUser");
    ArrayDesign ad = this.arrayDesignService.findByName(this.arrayDesignName).iterator().next();
    try {
        this.securityService.makePrivate(ad);
        fail("Should have gotten a unauthorized user exception");
    } catch (AccessDeniedException e) {
    // ok.
    }
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest) Test(org.junit.Test)

Aggregations

ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)186 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)43 Test (org.junit.Test)32 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)26 InputStream (java.io.InputStream)25 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)24 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)24 Taxon (ubic.gemma.model.genome.Taxon)23 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)19 HashSet (java.util.HashSet)16 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)16 Collection (java.util.Collection)14 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)13 StopWatch (org.apache.commons.lang3.time.StopWatch)12 Before (org.junit.Before)12 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)12 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)9 GZIPInputStream (java.util.zip.GZIPInputStream)8 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)8 File (java.io.File)7