Skip to content
Snippets Groups Projects
Commit 37a33435 authored by buczekp's avatar buczekp
Browse files

[LMS-2421] fixed test expectations + solved TODO + refactoring

SVN: 22336
parent 5966fb2c
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -56,7 +56,7 @@ public class SampleDetailsTest extends GenericSystemTestCase
private static final String CISD_ID_PREFIX = "/CISD/"; private static final String CISD_ID_PREFIX = "/CISD/";
private static final String DEFAULT_GROUP = "CISD"; private static final String DEFAULT_SPACE = "CISD";
private static final String PERMLINK_TEMPLATE = private static final String PERMLINK_TEMPLATE =
"http://localhost/openbis/index.html?viewMode=SIMPLE#entity=SAMPLE&permId=%s"; "http://localhost/openbis/index.html?viewMode=SIMPLE#entity=SAMPLE&permId=%s";
...@@ -65,10 +65,15 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -65,10 +65,15 @@ public class SampleDetailsTest extends GenericSystemTestCase
private static final String CELL_PLATE_EXAMPLE = "3VCP5"; private static final String CELL_PLATE_EXAMPLE = "3VCP5";
private static final String CELL_PLATE_EXAMPLE_ID = CISD_ID_PREFIX + CELL_PLATE_EXAMPLE;
private static final String CELL_PLATE_EXAMPLE_EXPERIMENT_ID = "/CISD/NEMO/EXP10"; private static final String CELL_PLATE_EXAMPLE_EXPERIMENT_ID = "/CISD/NEMO/EXP10";
private static final String CELL_PLATE_WITH_DATA_EXAMPLE = "CP-TEST-2";
private static final String CELL_PLATE_WITH_DATA_EXAMPLE_ID = CISD_ID_PREFIX
+ CELL_PLATE_WITH_DATA_EXAMPLE;
private static final String CELL_PLATE_WITH_DATA_EXAMPLE_EXPERIMENT_ID = "/CISD/NOE/EXP-TEST-2";
private static final String CONTROL_LAYOUT_EXAMPLE_PERM_ID = "200811050919915-8"; private static final String CONTROL_LAYOUT_EXAMPLE_PERM_ID = "200811050919915-8";
private static final String CELL_PLATE_EXAMPLE_PERM_ID = "200811050946559-979"; private static final String CELL_PLATE_EXAMPLE_PERM_ID = "200811050946559-979";
...@@ -79,9 +84,7 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -79,9 +84,7 @@ public class SampleDetailsTest extends GenericSystemTestCase
private static final String CELL_PLATE_EXAMPLE_PERMLINK = StringEscapeUtils.escapeHtml(String private static final String CELL_PLATE_EXAMPLE_PERMLINK = StringEscapeUtils.escapeHtml(String
.format(PERMLINK_TEMPLATE, CELL_PLATE_EXAMPLE_PERM_ID)); .format(PERMLINK_TEMPLATE, CELL_PLATE_EXAMPLE_PERM_ID));
private static final String DIRECTLY_CONNECTED_DATA_SET_CODE = "20081105092158673-1"; private static final String DIRECTLY_CONNECTED_DATA_SET_CODE = "20081105092159222-2";
private static final String INDIRECTLY_CONNECTED_DATA_SET_CODE = "20081105092159188-3";
private static final String DEFAULT_DATA_SET_TYPE = "HCS_IMAGE"; private static final String DEFAULT_DATA_SET_TYPE = "HCS_IMAGE";
...@@ -161,8 +164,7 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -161,8 +164,7 @@ public class SampleDetailsTest extends GenericSystemTestCase
} }
@Test(groups = "broken") @Test
// FIXME LMS-2421
public void testGetSampleDataSets() public void testGetSampleDataSets()
{ {
logIntoCommonClientService(); logIntoCommonClientService();
...@@ -179,7 +181,7 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -179,7 +181,7 @@ public class SampleDetailsTest extends GenericSystemTestCase
GridRowModels<Sample> list = samples.getResultSet().getList(); GridRowModels<Sample> list = samples.getResultSet().getList();
Sample sample = getSample(list, createSampleIdentifier(CELL_PLATE_EXAMPLE)); Sample sample = getSample(list, createSampleIdentifier(CELL_PLATE_WITH_DATA_EXAMPLE));
// directly connected // directly connected
boolean showOnlyDirectlyConnected = true; boolean showOnlyDirectlyConnected = true;
...@@ -196,8 +198,11 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -196,8 +198,11 @@ public class SampleDetailsTest extends GenericSystemTestCase
final DataSet directlyConnectedDataSet = final DataSet directlyConnectedDataSet =
getDataSet(directlyConnectedResults.getResultSet().getList(), getDataSet(directlyConnectedResults.getResultSet().getList(),
DIRECTLY_CONNECTED_DATA_SET_CODE).tryGetAsDataSet(); DIRECTLY_CONNECTED_DATA_SET_CODE).tryGetAsDataSet();
checkDataSet(directlyConnectedDataSet, DIRECTLY_CONNECTED_DATA_SET_CODE, DataSetExpectations.checkThat(directlyConnectedDataSet)
CELL_PLATE_EXAMPLE_ID, CELL_PLATE_EXAMPLE_EXPERIMENT_ID, "TIFF", "xxx/yyy/zzz"); .hasCode(DIRECTLY_CONNECTED_DATA_SET_CODE)
.hasSampleWithIdentifier(CELL_PLATE_WITH_DATA_EXAMPLE_ID)
.hasExperimentWithIdentifier(CELL_PLATE_WITH_DATA_EXAMPLE_EXPERIMENT_ID)
.hasFileFormatType("3VPROPRIETARY").hasLocation("a/2");
// indirectly connected // indirectly connected
showOnlyDirectlyConnected = false; showOnlyDirectlyConnected = false;
...@@ -211,20 +216,88 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -211,20 +216,88 @@ public class SampleDetailsTest extends GenericSystemTestCase
.iterator().next().getCode()); .iterator().next().getCode());
assertEquals(6, indirectlyConnectedResults.getResultSet().getTotalLength()); assertEquals(6, indirectlyConnectedResults.getResultSet().getTotalLength());
// the directly connected data set should still be retrieved
DataSet directlyConnectedDataSet2 = DataSet directlyConnectedDataSet2 =
getDataSet(directlyConnectedResults.getResultSet().getList(), getDataSet(directlyConnectedResults.getResultSet().getList(),
DIRECTLY_CONNECTED_DATA_SET_CODE).tryGetAsDataSet(); DIRECTLY_CONNECTED_DATA_SET_CODE).tryGetAsDataSet();
checkDataSet(directlyConnectedDataSet2, directlyConnectedDataSet.getCode(), DataSetExpectations
directlyConnectedDataSet.getSample().getIdentifier(), directlyConnectedDataSet .checkThat(directlyConnectedDataSet2)
.getExperiment().getIdentifier(), directlyConnectedDataSet .hasCode(directlyConnectedDataSet.getCode())
.getFileFormatType().getCode(), directlyConnectedDataSet.getLocation()); .hasSampleWithIdentifier(directlyConnectedDataSet.getSample().getIdentifier())
.hasExperimentWithIdentifier(
DataSet indirectlyConnectedDataSet = directlyConnectedDataSet.getExperiment().getIdentifier())
.hasFileFormatType(directlyConnectedDataSet.getFileFormatType().getCode())
.hasLocation(directlyConnectedDataSet.getDataSetLocation());
final String indirectlyConnectedDataSetCode1 = "20081105092159111-1";
DataSet indirectlyConnectedDataSetThroughChildSample =
getDataSet(indirectlyConnectedResults.getResultSet().getList(),
indirectlyConnectedDataSetCode1).tryGetAsDataSet();
DataSetExpectations.checkThat(indirectlyConnectedDataSetThroughChildSample)
.hasCode(indirectlyConnectedDataSetCode1)
.hasSampleWithIdentifier(CISD_ID_PREFIX + "CP-TEST-1")
.hasExperimentWithIdentifier("/CISD/NEMO/EXP-TEST-1").hasFileFormatType("TIFF")
.hasLocation("a/1");
final String indirectlyConnectedDataSetCode2 = "20081105092259000-9";
DataSet indirectlyConnectedDataSetThroughChildDataSet =
getDataSet(indirectlyConnectedResults.getResultSet().getList(), getDataSet(indirectlyConnectedResults.getResultSet().getList(),
INDIRECTLY_CONNECTED_DATA_SET_CODE).tryGetAsDataSet(); indirectlyConnectedDataSetCode2).tryGetAsDataSet();
checkDataSet(indirectlyConnectedDataSet, INDIRECTLY_CONNECTED_DATA_SET_CODE, null, DataSetExpectations.checkThat(indirectlyConnectedDataSetThroughChildDataSet)
CELL_PLATE_EXAMPLE_EXPERIMENT_ID, "3VPROPRIETARY", "analysis/result"); .hasCode(indirectlyConnectedDataSetCode2).hasNoSample()
// TODO 2010-09-21, Piotr Buczek: check datasets connected to a different experiment .hasExperimentWithIdentifier("/CISD/DEFAULT/EXP-REUSE").hasFileFormatType("XML")
.hasLocation("xml/result-9");
}
private static class DataSetExpectations
{
public static DataSetExpectations checkThat(DataSet dataSet)
{
return new DataSetExpectations(dataSet);
}
private DataSet dataSet;
private DataSetExpectations(DataSet dataSet)
{
this.dataSet = dataSet;
}
public DataSetExpectations hasCode(String expectedCode)
{
assertEquals(expectedCode, dataSet.getCode());
return this;
}
public DataSetExpectations hasSampleWithIdentifier(String expectedSampleIdentifier)
{
assertEquals(expectedSampleIdentifier, dataSet.getSample().getIdentifier());
return this;
}
public DataSetExpectations hasNoSample()
{
assertEquals(null, dataSet.getSample());
return this;
}
public DataSetExpectations hasExperimentWithIdentifier(String expectedExperimentIdentifier)
{
assertEquals(expectedExperimentIdentifier, dataSet.getExperiment().getIdentifier());
return this;
}
public DataSetExpectations hasFileFormatType(String expectedFileFormatTypeCode)
{
assertEquals(expectedFileFormatTypeCode, dataSet.getFileFormatType().getCode());
return this;
}
public DataSetExpectations hasLocation(String expectedLocation)
{
assertEquals(expectedLocation, dataSet.getLocation());
return this;
}
} }
private void checkUserProperty(List<IEntityProperty> properties, String propertyCode, private void checkUserProperty(List<IEntityProperty> properties, String propertyCode,
...@@ -256,7 +329,7 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -256,7 +329,7 @@ public class SampleDetailsTest extends GenericSystemTestCase
private static String createSampleIdentifier(String sampleCode) private static String createSampleIdentifier(String sampleCode)
{ {
return createSampleIdentifier(DEFAULT_GROUP, sampleCode); return createSampleIdentifier(DEFAULT_SPACE, sampleCode);
} }
private static String createSampleIdentifier(String spaceCode, String sampleCode) private static String createSampleIdentifier(String spaceCode, String sampleCode)
...@@ -316,21 +389,4 @@ public class SampleDetailsTest extends GenericSystemTestCase ...@@ -316,21 +389,4 @@ public class SampleDetailsTest extends GenericSystemTestCase
return null; // satisfy compiler return null; // satisfy compiler
} }
private static void checkDataSet(DataSet dataSet, String expectedCode,
String expectedSampleIdentifierOrNull, String expectedExperimentIdentifier,
String expectedFileFormatType, String expectedLocation)
{
assertEquals(expectedCode, dataSet.getCode());
if (expectedSampleIdentifierOrNull == null)
{
assertEquals(null, dataSet.getSample());
} else
{
assertEquals(expectedSampleIdentifierOrNull, dataSet.getSample().getIdentifier());
}
assertEquals(expectedExperimentIdentifier, dataSet.getExperiment().getIdentifier());
assertEquals(expectedFileFormatType, dataSet.getFileFormatType().getCode());
assertEquals(expectedLocation, dataSet.getLocation());
}
} }
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