Skip to content
Snippets Groups Projects
Commit 708068ad authored by cramakri's avatar cramakri
Browse files

LMS-2440 Fixing broken tests.

SVN: 22354
parent 6fad9523
No related branches found
No related tags found
No related merge requests found
Showing with 33 additions and 23 deletions
...@@ -151,6 +151,8 @@ public final class TrashBOTest extends AbstractBOTest ...@@ -151,6 +151,8 @@ public final class TrashBOTest extends AbstractBOTest
{ {
final DeletionPE deletion = createDeletion(); final DeletionPE deletion = createDeletion();
final List<TechId> experimentIds = EXAMPLE_ID_LIST; final List<TechId> experimentIds = EXAMPLE_ID_LIST;
final List<TechId> dataSetIds = TechId.createList(60, 61);
final RecordingMatcher<List<TechId>> dsIdsMatcher = new RecordingMatcher<List<TechId>>();
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
...@@ -168,14 +170,19 @@ public final class TrashBOTest extends AbstractBOTest ...@@ -168,14 +170,19 @@ public final class TrashBOTest extends AbstractBOTest
will(returnValue(0)); will(returnValue(0));
// trash dependent data sets // trash dependent data sets
List<TechId> dataSetIds = TechId.createList(60, 61);
one(dataDAO).listDataSetIdsByExperimentIds(experimentIds); one(dataDAO).listDataSetIdsByExperimentIds(experimentIds);
will(returnValue(dataSetIds)); will(returnValue(dataSetIds));
one(deletionDAO).trash(EntityKind.DATA_SET, dataSetIds, deletion); oneOf(deletionDAO).trash(with(same(EntityKind.DATA_SET)), with(dsIdsMatcher),
with(same(deletion)));
will(returnValue(0)); will(returnValue(0));
} }
}); });
trashBO.trashExperiments(experimentIds); trashBO.trashExperiments(experimentIds);
// Check that the data set ids match
List<TechId> usedDsIds = dsIdsMatcher.getRecordedObjects().get(0);
assertEquals(new HashSet<TechId>().addAll(dataSetIds),
new HashSet<TechId>().addAll(usedDsIds));
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
......
...@@ -155,6 +155,8 @@ public class DatasetListerTest extends AbstractDAOTest ...@@ -155,6 +155,8 @@ public class DatasetListerTest extends AbstractDAOTest
+ " 20081105092359990-2 (HCS_IMAGE) [COMMENT: no comment]\n" + " 20081105092359990-2 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20081105092259900-1 (HCS_IMAGE) [COMMENT: no comment]\n" + " 20081105092259900-1 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20081105092359990-2 (HCS_IMAGE) [COMMENT: no comment]\n" + " 20081105092359990-2 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20110805092359990-17 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20081105092259000-18 (HCS_IMAGE) [COMMENT: no comment]\n"
+ "CP-TEST-2\n 20081105092159222-2 (HCS_IMAGE) [COMMENT: no comment]\n" + "CP-TEST-2\n 20081105092159222-2 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20081105092259000-9 (HCS_IMAGE) [COMMENT: no comment]\n" + " 20081105092259000-9 (HCS_IMAGE) [COMMENT: no comment]\n"
+ " 20081105092259900-0 (HCS_IMAGE) [COMMENT: no comment]\n" + " 20081105092259900-0 (HCS_IMAGE) [COMMENT: no comment]\n"
...@@ -216,7 +218,7 @@ public class DatasetListerTest extends AbstractDAOTest ...@@ -216,7 +218,7 @@ public class DatasetListerTest extends AbstractDAOTest
assertEquals("20081105092259900-0", dataSets.get(0).getCode()); assertEquals("20081105092259900-0", dataSets.get(0).getCode());
assertEquals("STANDARD", dataSets.get(0).getDataStore().getCode()); assertEquals("STANDARD", dataSets.get(0).getDataStore().getCode());
assertEquals(0, dataSets.get(0).getProperties().size()); assertEquals(0, dataSets.get(0).getProperties().size());
assertEquals(6, dataSets.size()); assertEquals(8, dataSets.size());
} }
@Test @Test
...@@ -235,7 +237,7 @@ public class DatasetListerTest extends AbstractDAOTest ...@@ -235,7 +237,7 @@ public class DatasetListerTest extends AbstractDAOTest
assertEquals("STANDARD", dataSets.get(0).getDataStore().getCode()); assertEquals("STANDARD", dataSets.get(0).getDataStore().getCode());
assertEquals("no comment", dataSets.get(0).getProperties().get(0).tryGetOriginalValue()); assertEquals("no comment", dataSets.get(0).getProperties().get(0).tryGetOriginalValue());
assertEquals(1, dataSets.get(0).getProperties().size()); assertEquals(1, dataSets.get(0).getProperties().size());
assertEquals(1, dataSets.size()); assertEquals(2, dataSets.size());
} }
@Test @Test
...@@ -319,7 +321,7 @@ public class DatasetListerTest extends AbstractDAOTest ...@@ -319,7 +321,7 @@ public class DatasetListerTest extends AbstractDAOTest
assertEquals("42", ((DataSet) dataSet).getShareId()); assertEquals("42", ((DataSet) dataSet).getShareId());
assertEquals(4711L, ((DataSet) dataSet).getSize().longValue()); assertEquals(4711L, ((DataSet) dataSet).getSize().longValue());
assertEquals(DataSetArchivingStatus.AVAILABLE, ((DataSet) dataSet).getStatus()); assertEquals(DataSetArchivingStatus.AVAILABLE, ((DataSet) dataSet).getStatus());
assertEquals(12, list.size()); assertEquals(14, list.size());
} }
private void assertSameDataSetsForSameCode(Map<String, ExternalData> dataSetsByCode, private void assertSameDataSetsForSameCode(Map<String, ExternalData> dataSetsByCode,
......
...@@ -157,7 +157,7 @@ public class DatasetListingQueryTest extends AbstractDAOTest ...@@ -157,7 +157,7 @@ public class DatasetListingQueryTest extends AbstractDAOTest
} }
assertEquals(1, counters.getCountOf(experiment1.getId())); assertEquals(1, counters.getCountOf(experiment1.getId()));
assertEquals(1, counters.getCountOf(experiment2.getId())); assertEquals(2, counters.getCountOf(experiment2.getId()));
assertEquals(2, counters.getNumberOfDifferentObjectsCounted()); assertEquals(2, counters.getNumberOfDifferentObjectsCounted());
} }
......
...@@ -42,20 +42,18 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; ...@@ -42,20 +42,18 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Code; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Code;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.LocatorTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.LocatorTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat; import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat;
import ch.systemsx.cisd.openbis.generic.shared.dto.TableNames;
import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE; import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyTermPE; import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyTermPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode; import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode;
/** /**
...@@ -72,6 +70,8 @@ public final class DataDAOTest extends AbstractDAOTest ...@@ -72,6 +70,8 @@ public final class DataDAOTest extends AbstractDAOTest
private final String PARENT_CODE = "20081105092159333-3"; private final String PARENT_CODE = "20081105092159333-3";
private final String PARENT_WITH_NO_CHILDREN_IN_TRASH = "20110805092359990-17";
private final String CHILD_CODE = "20081105092259000-8"; private final String CHILD_CODE = "20081105092259000-8";
private final String CONTAINER_CODE = "20110509092359990-10"; private final String CONTAINER_CODE = "20110509092359990-10";
...@@ -338,8 +338,6 @@ public final class DataDAOTest extends AbstractDAOTest ...@@ -338,8 +338,6 @@ public final class DataDAOTest extends AbstractDAOTest
assertTrue(extractedParents.contains(anotherDataSet)); assertTrue(extractedParents.contains(anotherDataSet));
} }
@Test(groups = "broken-deletion")
// FIXME LMS-2440
public final void testDeleteWithPropertiesButParentPreserved() public final void testDeleteWithPropertiesButParentPreserved()
{ {
final IDataDAO dataDAO = daoFactory.getDataDAO(); final IDataDAO dataDAO = daoFactory.getDataDAO();
...@@ -348,6 +346,10 @@ public final class DataDAOTest extends AbstractDAOTest ...@@ -348,6 +346,10 @@ public final class DataDAOTest extends AbstractDAOTest
// Deleted data set should have all collections which prevent it from deletion empty. // Deleted data set should have all collections which prevent it from deletion empty.
assertTrue(deletedData.getChildren().isEmpty()); assertTrue(deletedData.getChildren().isEmpty());
// Remember how many rows are in the properties table before we delete
int beforeDeletionPropertiesRowCount =
countRowsInTable(TableNames.DATA_SET_PROPERTIES_TABLE);
// delete // delete
dataDAO.delete(deletedData); dataDAO.delete(deletedData);
...@@ -356,15 +358,9 @@ public final class DataDAOTest extends AbstractDAOTest ...@@ -356,15 +358,9 @@ public final class DataDAOTest extends AbstractDAOTest
// test successful deletion of data set properties // test successful deletion of data set properties
assertFalse(deletedData.getProperties().isEmpty()); assertFalse(deletedData.getProperties().isEmpty());
List<EntityTypePropertyTypePE> retrievedPropertyTypes = int afterDeletionPropertiesRowCount =
daoFactory.getEntityPropertyTypeDAO(EntityKind.DATA_SET).listEntityPropertyTypes( countRowsInTable(TableNames.DATA_SET_PROPERTIES_TABLE);
deletedData.getEntityType()); assertEquals(beforeDeletionPropertiesRowCount - 1, afterDeletionPropertiesRowCount);
for (DataSetPropertyPE property : deletedData.getProperties())
{
int index = retrievedPropertyTypes.indexOf(property.getEntityTypePropertyType());
EntityTypePropertyTypePE retrievedPropertyType = retrievedPropertyTypes.get(index);
assertFalse(retrievedPropertyType.getPropertyValues().contains(property));
}
// deleted data set had parent connected that should not have been deleted // deleted data set had parent connected that should not have been deleted
// NOTE: somehow cannot get parents even though connection is the same as with children // NOTE: somehow cannot get parents even though connection is the same as with children
...@@ -392,12 +388,10 @@ public final class DataDAOTest extends AbstractDAOTest ...@@ -392,12 +388,10 @@ public final class DataDAOTest extends AbstractDAOTest
assertNull(preservedComponent.getContainer()); assertNull(preservedComponent.getContainer());
} }
@Test(groups = "broken-deletion")
// FIXME LMS-2440
public final void testDeleteParentPreservesChildren() public final void testDeleteParentPreservesChildren()
{ {
final IDataDAO dataDAO = daoFactory.getDataDAO(); final IDataDAO dataDAO = daoFactory.getDataDAO();
final DataPE deletedData = findData(PARENT_CODE); final DataPE deletedData = findData(PARENT_WITH_NO_CHILDREN_IN_TRASH);
// Deleted data set should have 'child' data sets. // Deleted data set should have 'child' data sets.
assertFalse(deletedData.getChildren().isEmpty()); assertFalse(deletedData.getChildren().isEmpty());
......
...@@ -11,3 +11,5 @@ ...@@ -11,3 +11,5 @@
13 20110509092359990-10 4 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N \N \N \N 13 20110509092359990-10 4 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N \N \N \N
14 20110509092359990-11 2 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N 1 13 \N 14 20110509092359990-11 2 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N 1 13 \N
15 20110509092359990-12 2 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N 2 13 \N 15 20110509092359990-12 2 \N 2011-05-09 10:22:59.203+02 2011-05-09 10:22:59.313+02 f t 2011-05-09 16:34:44.462776+02 8 1 t \N \N 2 13 \N
17 20110805092359990-17 2 \N 2008-11-05 09:21:59.203+01 2009-02-09 12:21:47.815468+01 f t 2009-03-23 15:34:44.462776+01 20 1 f 1044 \N \N \N \N
18 20081105092259000-18 2 \N 2008-11-05 09:22:59.203+01 2008-11-05 09:22:59.313+01 f t 2009-03-23 15:34:44.462776+01 8 1 t \N \N \N \N \N
\ No newline at end of file
...@@ -13,3 +13,5 @@ ...@@ -13,3 +13,5 @@
13 5 4 \N 12 \N 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.639+02 13 5 4 \N 12 \N 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.639+02
14 5 3 \N \N 22 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.64+02 14 5 3 \N \N 22 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.64+02
15 5 2 \N \N 2498 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.64+02 15 5 2 \N \N 2498 2 2009-09-15 08:45:48.059548+02 2009-09-15 08:45:48.64+02
19 17 1 no comment \N \N 2 2009-04-24 14:45:06.348563+02 2009-04-24 14:45:07.091+02
20 18 1 no comment \N \N 2 2009-04-24 14:45:06.348563+02 2009-04-24 14:45:07.091+02
...@@ -8,3 +8,4 @@ ...@@ -8,3 +8,4 @@
9 11 9 11
10 12 10 12
11 12 11 12
17 18
...@@ -10,3 +10,5 @@ ...@@ -10,3 +10,5 @@
12 xml/result-12 8 1 4 U \N AVAILABLE \N \N f -50 12 xml/result-12 8 1 4 U \N AVAILABLE \N \N f -50
14 contained/1 8 1 4 U \N AVAILABLE \N \N f -50 14 contained/1 8 1 4 U \N AVAILABLE \N \N f -50
15 contained/2 8 1 4 U \N AVAILABLE \N \N f -50 15 contained/2 8 1 4 U \N AVAILABLE \N \N f -50
17 a/4 4 1 4 U \N AVAILABLE \N \N f -50
18 xml/result-18 8 1 4 U \N AVAILABLE \N \N f -50
\ No newline at end of file
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