From 45d06278bcd678db5bc05a28f2b6d0991cab6c5c Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Thu, 29 Sep 2011 14:52:45 +0000 Subject: [PATCH] Test fixed, dead classes removed SVN: 23149 --- .../InternalAbundanceColumnDefinition.java | 82 ------------------- .../columns/ProteinColDefKind.java | 80 ------------------ .../ListProteinOriginalDataProvider.java | 63 -------------- .../server/PhosphoNetXClientServiceTest.java | 19 ++++- 4 files changed, 18 insertions(+), 226 deletions(-) delete mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java delete mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/ProteinColDefKind.java delete mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListProteinOriginalDataProvider.java diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java deleted file mode 100644 index 98cb74c6a6b..00000000000 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2009 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns; - -import java.util.Map; - -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinition; -import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo; - -public final class InternalAbundanceColumnDefinition extends AbstractColumnDefinition<ProteinInfo> -{ - private static final Double ZERO = new Double(1e-40); - - private long sampleID; - - private Map<String, String> properties; - - // GWT only - public InternalAbundanceColumnDefinition() - { - super(); - } - - public InternalAbundanceColumnDefinition(String headerTextOrNull, - Map<String, String> propertiesOrNull, int width, boolean isHidden, long sampleID) - { - super(headerTextOrNull, width, isHidden, true, false); - this.properties = propertiesOrNull; - this.sampleID = sampleID; - } - - public String getIdentifier() - { - return "abundance-" + Long.toString(sampleID); - } - - @Override - protected String tryGetValue(ProteinInfo entity) - { - Double abundance = tryToGetAbundance(entity); - return abundance == null ? null : Double.toString(abundance); - } - - @Override - public Comparable<?> tryGetComparableValue(GridRowModel<ProteinInfo> rowModel) - { - Double abundance = tryToGetAbundance(rowModel.getOriginalObject()); - return abundance == null ? ZERO : abundance; - } - - @Override - public String tryToGetProperty(String key) - { - return properties == null ? null : properties.get(key); - } - - private Double tryToGetAbundance(ProteinInfo entity) - { - Map<Long, Double> abundances = entity.getAbundances(); - if (abundances == null) - { - return null; - } - return abundances.get(sampleID); - } - -} \ No newline at end of file diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/ProteinColDefKind.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/ProteinColDefKind.java deleted file mode 100644 index 4e762dfb3dc..00000000000 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/ProteinColDefKind.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2009 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns; - -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; -import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.Dict; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo; - -/** - * @author Franz-Josef Elmer - */ -public enum ProteinColDefKind implements IColumnDefinitionKind<ProteinInfo> -{ - ACCESSION_NUMBER(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.ACCESSION_NUMBER) - { - @Override - public String tryGetValue(ProteinInfo entity) - { - return entity.getAccessionNumber(); - } - }), - - DESCRIPTION(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.PROTEIN_DESCRIPTION) - { - @Override - public String tryGetValue(ProteinInfo entity) - { - return entity.getDescription(); - } - }), - - COVERAGE(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.COVERAGE, 100, false, true) - { - @Override - public String tryGetValue(ProteinInfo entity) - { - return Double.toString(entity.getCoverage()); - } - - @Override - public Comparable<?> getComparableValue(GridRowModel<ProteinInfo> entity) - { - return entity.getOriginalObject().getCoverage(); - } - }), ; - - private final AbstractColumnDefinitionKind<ProteinInfo> columnDefinitionKind; - - private ProteinColDefKind(AbstractColumnDefinitionKind<ProteinInfo> columnDefinitionKind) - { - this.columnDefinitionKind = columnDefinitionKind; - } - - public String id() - { - return name(); - } - - public AbstractColumnDefinitionKind<ProteinInfo> getDescriptor() - { - return columnDefinitionKind; - } - -} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListProteinOriginalDataProvider.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListProteinOriginalDataProvider.java deleted file mode 100644 index 6b6c6bdd7eb..00000000000 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListProteinOriginalDataProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2009 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.server; - -import java.util.List; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.client.web.server.AbstractOriginalDataProviderWithoutHeaders; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.AggregateFunction; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo; - -/** - * - * - * @author Franz-Josef Elmer - */ -class ListProteinOriginalDataProvider extends AbstractOriginalDataProviderWithoutHeaders<ProteinInfo> -{ - private final IPhosphoNetXServer server; - private final String sessionToken; - private final TechId experimentID; - private final double falseDiscoveryRate; - private final AggregateFunction aggregateFunction; - private final String treatmentTypeCode; - private final boolean aggregateOnOriginal; - - ListProteinOriginalDataProvider(IPhosphoNetXServer server, String sessionToken, - TechId experimentID, double falseDiscoveryRate, AggregateFunction function, - String treatmentTypeCode, boolean aggregateOnOriginal) - { - this.server = server; - this.sessionToken = sessionToken; - this.experimentID = experimentID; - this.falseDiscoveryRate = falseDiscoveryRate; - this.aggregateFunction = function; - this.treatmentTypeCode = treatmentTypeCode; - this.aggregateOnOriginal = aggregateOnOriginal; - } - - @Override - public List<ProteinInfo> getFullOriginalData() throws UserFailureException - { - return server.listProteinsByExperiment(sessionToken, experimentID, falseDiscoveryRate, - aggregateFunction, treatmentTypeCode, aggregateOnOriginal); - } - -} diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientServiceTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientServiceTest.java index 2e4efa31014..7f671cb5afb 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientServiceTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientServiceTest.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.server; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Properties; @@ -190,6 +191,12 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase { final TechId experimentID1 = new TechId(42L); final TechId experimentID2 = new TechId(4711L); + final AbundanceColumnDefinition colDef = new AbundanceColumnDefinition(); + colDef.setSampleCode("S1"); + Treatment treatment = new Treatment(); + treatment.setType("type1"); + treatment.setTypeCode("code"); + colDef.setTreatments(Arrays.asList(treatment)); final double fdr1 = 0.125; final double fdr2 = 0.25; final AggregateFunction f1 = AggregateFunction.MAX; @@ -205,6 +212,15 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase context.checking(new Expectations() { { + one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN, + experimentID1, treatment1); + will(returnValue(Arrays.asList(colDef))); + one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN, + experimentID1, treatment2); + will(returnValue(Arrays.asList(colDef))); + one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN, + experimentID2, treatment1); + will(returnValue(Arrays.asList(colDef))); one(server).listProteinsByExperiment(SESSION_TOKEN, experimentID1, fdr1, f1, treatment1, false); will(returnValue(Arrays.asList(p1))); @@ -239,7 +255,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase listAndCheckProteins(p4, experimentID1, fdr1, f2, treatment1, false); listAndCheckProteins(p5, experimentID1, fdr1, f1, treatment2, false); listAndCheckProteins(p6, experimentID1, fdr1, f1, treatment1, true); - assertEquals(13, cacheFolder.listFiles().length); + assertEquals(19, cacheFolder.listFiles().length); context.assertIsSatisfied(); } @@ -267,6 +283,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase ProteinInfo protein = new ProteinInfo(); protein.setId(new TechId(id)); protein.setDescription("Protein " + id); + protein.setAbundances(new HashMap<Long, Double>()); return protein; } -- GitLab