Skip to content
Snippets Groups Projects
Commit 6e4462c6 authored by buczekp's avatar buczekp
Browse files

[LMS-1772] minor deprecation

SVN: 18638
parent c0ac414a
No related branches found
No related tags found
No related merge requests found
...@@ -53,9 +53,9 @@ class AbundanceHandler extends AbstractHandler ...@@ -53,9 +53,9 @@ class AbundanceHandler extends AbstractHandler
private final IEncapsulatedOpenBISService openbisService; private final IEncapsulatedOpenBISService openbisService;
private final ExperimentIdentifier experimentIdentifier; private final ExperimentIdentifier experimentIdentifier;
private final SpaceIdentifier msData; private final SpaceIdentifier msData;
private final Experiment experiment; private final Experiment experiment;
private final Map<String, SampleOrError> samplesOrErrors = new HashMap<String, SampleOrError>(); private final Map<String, SampleOrError> samplesOrErrors = new HashMap<String, SampleOrError>();
...@@ -69,7 +69,9 @@ class AbundanceHandler extends AbstractHandler ...@@ -69,7 +69,9 @@ class AbundanceHandler extends AbstractHandler
this.openbisService = openbisService; this.openbisService = openbisService;
this.experimentIdentifier = experimentIdentifier; this.experimentIdentifier = experimentIdentifier;
this.experiment = experiment; this.experiment = experiment;
msData = new SpaceIdentifier(experimentIdentifier.getDatabaseInstanceCode(), Constants.MS_DATA_SPACE); msData =
new SpaceIdentifier(experimentIdentifier.getDatabaseInstanceCode(),
Constants.MS_DATA_SPACE);
sampleType = new SampleType(); sampleType = new SampleType();
sampleType.setCode(Constants.SEARCH_SAMPLE_TYPE); sampleType.setCode(Constants.SEARCH_SAMPLE_TYPE);
} }
...@@ -88,14 +90,14 @@ class AbundanceHandler extends AbstractHandler ...@@ -88,14 +90,14 @@ class AbundanceHandler extends AbstractHandler
} }
} }
@SuppressWarnings("deprecation")
private Sample getOrCreateSample(String parameterName, String proteinName) private Sample getOrCreateSample(String parameterName, String proteinName)
{ {
SampleOrError sampleOrError = samplesOrErrors.get(parameterName); SampleOrError sampleOrError = samplesOrErrors.get(parameterName);
if (sampleOrError == null) if (sampleOrError == null)
{ {
// first we look for a sample in space MS_DATA // first we look for a sample in space MS_DATA
SampleIdentifier sampleIdentifier = SampleIdentifier sampleIdentifier = new SampleIdentifier(msData, parameterName);
new SampleIdentifier(msData, parameterName);
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample = ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample =
openbisService.tryGetSampleWithExperiment(sampleIdentifier); openbisService.tryGetSampleWithExperiment(sampleIdentifier);
sampleOrError = new SampleOrError(); sampleOrError = new SampleOrError();
......
...@@ -43,29 +43,44 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; ...@@ -43,29 +43,44 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier;
/** /**
*
*
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public class AbundanceHandlerTest extends AssertJUnit public class AbundanceHandlerTest extends AssertJUnit
{ {
private static final String SPACE_CODE = "G1"; private static final String SPACE_CODE = "G1";
private static final SpaceIdentifier SPACE_IDENTIFIER = new SpaceIdentifier((String) null, SPACE_CODE);
private static final SpaceIdentifier SPACE_IDENTIFIER = new SpaceIdentifier((String) null,
SPACE_CODE);
private static final String EXPERIMENT_CODE = "E1"; private static final String EXPERIMENT_CODE = "E1";
private static final GroupIdentifier GROUP_IDENTIFIER = new GroupIdentifier((String) null, Constants.MS_DATA_SPACE);
private static final GroupIdentifier GROUP_IDENTIFIER = new GroupIdentifier((String) null,
Constants.MS_DATA_SPACE);
private static final String PARAMETER_VALUE = "1234.5"; private static final String PARAMETER_VALUE = "1234.5";
private static final double ABUNDANCE = 1234.5; private static final double ABUNDANCE = 1234.5;
private static final String PARAMETER_NAME = "abc12"; private static final String PARAMETER_NAME = "abc12";
private static final SampleIdentifier SAMPLE_IDENTIFER =
new SampleIdentifier(GROUP_IDENTIFIER, PARAMETER_NAME); private static final SampleIdentifier SAMPLE_IDENTIFER = new SampleIdentifier(GROUP_IDENTIFIER,
private static final ExperimentIdentifier EXPERIMENT_IDENTIFIER = PARAMETER_NAME);
new ExperimentIdentifier(new ProjectIdentifier(SPACE_CODE, "P1"), EXPERIMENT_CODE);
private static final ExperimentIdentifier EXPERIMENT_IDENTIFIER = new ExperimentIdentifier(
new ProjectIdentifier(SPACE_CODE, "P1"), EXPERIMENT_CODE);
private static final String SAMPLE_PERM_ID = "s12-34"; private static final String SAMPLE_PERM_ID = "s12-34";
private static final String EXPERIMENT_PERM_ID = "e12345-42"; private static final String EXPERIMENT_PERM_ID = "e12345-42";
private static final long EXPERIMENT_ID = 42; private static final long EXPERIMENT_ID = 42;
private static final long SAMPLE_ID = 43; private static final long SAMPLE_ID = 43;
private static final long PROTEIN_ID = 4711; private static final long PROTEIN_ID = 4711;
private static final String PROTEIN_NAME = "my protein"; private static final String PROTEIN_NAME = "my protein";
private static final ListSamplesByPropertyCriteria CRITERIA = private static final ListSamplesByPropertyCriteria CRITERIA =
new ListSamplesByPropertyCriteria(AbundanceHandler.MZXML_FILENAME, PARAMETER_NAME, new ListSamplesByPropertyCriteria(AbundanceHandler.MZXML_FILENAME, PARAMETER_NAME,
SPACE_CODE, null); SPACE_CODE, null);
...@@ -135,32 +150,34 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -135,32 +150,34 @@ public class AbundanceHandlerTest extends AssertJUnit
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
@Test @Test
public void testAddTwoAbundanceValuesForASampleIdentifiedByPropertyButNoSampleFound() public void testAddTwoAbundanceValuesForASampleIdentifiedByPropertyButNoSampleFound()
{ {
prepareCreateSampleIdentifiedByProperty(Arrays.<Sample>asList()); prepareCreateSampleIdentifiedByProperty(Arrays.<Sample> asList());
try try
{ {
handler.addAbundancesToDatabase(createParameter(PARAMETER_VALUE), PROTEIN_ID, PROTEIN_NAME); handler.addAbundancesToDatabase(createParameter(PARAMETER_VALUE), PROTEIN_ID,
PROTEIN_NAME);
fail("UserFailureException expected"); fail("UserFailureException expected");
} catch (UserFailureException e) } catch (UserFailureException e)
{ {
assertEquals("Protein '" + PROTEIN_NAME assertEquals("Protein '" + PROTEIN_NAME
+ "' has an abundance value for an unidentified sample: " + PARAMETER_NAME, e + "' has an abundance value for an unidentified sample: " + PARAMETER_NAME,
.getMessage()); e.getMessage());
} }
try try
{ {
handler.addAbundancesToDatabase(createParameter(PARAMETER_VALUE), PROTEIN_ID, PROTEIN_NAME); handler.addAbundancesToDatabase(createParameter(PARAMETER_VALUE), PROTEIN_ID,
PROTEIN_NAME);
fail("UserFailureException expected"); fail("UserFailureException expected");
} catch (UserFailureException e) } catch (UserFailureException e)
{ {
assertEquals("Protein '" + PROTEIN_NAME assertEquals("Protein '" + PROTEIN_NAME
+ "' has an abundance value for an unidentified sample: " + PARAMETER_NAME, e + "' has an abundance value for an unidentified sample: " + PARAMETER_NAME,
.getMessage()); e.getMessage());
} }
context.assertIsSatisfied(); context.assertIsSatisfied();
...@@ -187,14 +204,14 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -187,14 +204,14 @@ public class AbundanceHandlerTest extends AssertJUnit
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
@Test @Test
public void testAddAbundanceValuesForASampleIdentifiedByProperty() public void testAddAbundanceValuesForASampleIdentifiedByProperty()
{ {
final Sample sample = new Sample(); final Sample sample = new Sample();
sample.setPermId(SAMPLE_PERM_ID); sample.setPermId(SAMPLE_PERM_ID);
sample.setIdentifier("blabla"); sample.setIdentifier("blabla");
prepareCreateSampleIdentifiedByProperty(Arrays.<Sample>asList(sample)); prepareCreateSampleIdentifiedByProperty(Arrays.<Sample> asList(sample));
prepareCreateSample(); prepareCreateSample();
context.checking(new Expectations() context.checking(new Expectations()
{ {
...@@ -203,6 +220,7 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -203,6 +220,7 @@ public class AbundanceHandlerTest extends AssertJUnit
one(service).registerSample(with(new BaseMatcher<NewSample>() one(service).registerSample(with(new BaseMatcher<NewSample>()
{ {
@SuppressWarnings("deprecation")
public boolean matches(Object item) public boolean matches(Object item)
{ {
if (item instanceof NewSample) if (item instanceof NewSample)
...@@ -210,10 +228,10 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -210,10 +228,10 @@ public class AbundanceHandlerTest extends AssertJUnit
NewSample newSample = (NewSample) item; NewSample newSample = (NewSample) item;
assertEquals(SPACE_IDENTIFIER + "/" + PARAMETER_NAME + "_" assertEquals(SPACE_IDENTIFIER + "/" + PARAMETER_NAME + "_"
+ EXPERIMENT_CODE, newSample.getIdentifier()); + EXPERIMENT_CODE, newSample.getIdentifier());
assertEquals(EXPERIMENT_IDENTIFIER.toString(), newSample assertEquals(EXPERIMENT_IDENTIFIER.toString(),
.getExperimentIdentifier()); newSample.getExperimentIdentifier());
assertEquals(sample.getIdentifier(), newSample assertEquals(sample.getIdentifier(),
.getParentIdentifier()); newSample.getParentIdentifier());
return true; return true;
} }
return false; return false;
...@@ -252,7 +270,7 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -252,7 +270,7 @@ public class AbundanceHandlerTest extends AssertJUnit
{ {
one(service).registerSample(with(new BaseMatcher<NewSample>() one(service).registerSample(with(new BaseMatcher<NewSample>()
{ {
@SuppressWarnings("deprecation")
public boolean matches(Object item) public boolean matches(Object item)
{ {
if (item instanceof NewSample) if (item instanceof NewSample)
...@@ -260,8 +278,8 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -260,8 +278,8 @@ public class AbundanceHandlerTest extends AssertJUnit
NewSample newSample = (NewSample) item; NewSample newSample = (NewSample) item;
assertEquals(SPACE_IDENTIFIER + "/" + PARAMETER_NAME + "_" assertEquals(SPACE_IDENTIFIER + "/" + PARAMETER_NAME + "_"
+ EXPERIMENT_CODE, newSample.getIdentifier()); + EXPERIMENT_CODE, newSample.getIdentifier());
assertEquals(EXPERIMENT_IDENTIFIER.toString(), newSample assertEquals(EXPERIMENT_IDENTIFIER.toString(),
.getExperimentIdentifier()); newSample.getExperimentIdentifier());
assertEquals(PARAMETER_NAME, newSample.getParentIdentifier()); assertEquals(PARAMETER_NAME, newSample.getParentIdentifier());
return true; return true;
} }
...@@ -290,7 +308,7 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -290,7 +308,7 @@ public class AbundanceHandlerTest extends AssertJUnit
} }
}); });
} }
private void prepareCreateSampleIdentifiedByProperty(final List<Sample> samples) private void prepareCreateSampleIdentifiedByProperty(final List<Sample> samples)
{ {
prepareGetSample(null); prepareGetSample(null);
...@@ -315,7 +333,7 @@ public class AbundanceHandlerTest extends AssertJUnit ...@@ -315,7 +333,7 @@ public class AbundanceHandlerTest extends AssertJUnit
} }
}); });
} }
private void prepareGetSample(final Sample sample) private void prepareGetSample(final Sample sample)
{ {
context.checking(new Expectations() context.checking(new Expectations()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment