Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
1b09b5dd
Commit
1b09b5dd
authored
13 years ago
by
kaloyane
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-2441] minor: added test for multiple sample deletion
SVN: 22405
parent
9818cf52
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java
+48
-15
48 additions, 15 deletions
...d/openbis/generic/server/dataaccess/db/SampleDAOTest.java
with
48 additions
and
15 deletions
openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java
+
48
−
15
View file @
1b09b5dd
...
...
@@ -36,6 +36,8 @@ import org.testng.AssertJUnit;
import
org.testng.annotations.Test
;
import
ch.rinn.restrictions.Friend
;
import
ch.systemsx.cisd.common.collections.CollectionStyle
;
import
ch.systemsx.cisd.common.collections.CollectionUtils
;
import
ch.systemsx.cisd.openbis.generic.server.business.bo.util.SampleOwner
;
import
ch.systemsx.cisd.openbis.generic.server.dataaccess.IEventDAO
;
import
ch.systemsx.cisd.openbis.generic.server.dataaccess.ISampleDAO
;
...
...
@@ -301,7 +303,7 @@ public final class SampleDAOTest extends AbstractDAOTest
assertNotNull
(
experiment
);
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
// test successful deletion of sample
assertNull
(
sampleDAO
.
tryGetByTechId
(
TechId
.
create
(
sampleToDelete
)));
...
...
@@ -314,23 +316,54 @@ public final class SampleDAOTest extends AbstractDAOTest
new
TechId
(
HibernateUtils
.
getId
(
experiment
))));
}
private
void
deleteSample
(
SamplePE
sample
)
public
final
void
testDeleteMultipleSamples
()
{
final
ISampleDAO
sampleDAO
=
daoFactory
.
getSampleDAO
();
final
SamplePE
sample1
=
findSample
(
"3VCP5"
,
"CISD"
);
final
SamplePE
sample2
=
findSample
(
"EMPTY-MP"
,
"CISD"
);
// delete
deleteSamples
(
new
SamplePE
[]
{
sample1
,
sample2
});
// test successful deletion of sample
assertNull
(
sampleDAO
.
tryGetByTechId
(
TechId
.
create
(
sample1
)));
assertNull
(
sampleDAO
.
tryGetByTechId
(
TechId
.
create
(
sample2
)));
}
private
void
deleteSamples
(
SamplePE
...
samples
)
{
// before deletion there shouldn't be any entry about deletion of the sample in event table
assertNull
(
tryGetDeletionEvent
(
sample
));
for
(
SamplePE
sample
:
samples
)
{
assertNull
(
tryGetDeletionEvent
(
sample
));
}
List
<
TechId
>
sampleIds
=
new
ArrayList
<
TechId
>();
sampleIds
.
add
(
TechId
.
create
(
sample
));
final
PersonPE
registrator
=
getSystemPerson
();
final
String
reason
=
"reason"
+
sample
.
getPermId
();
List
<
TechId
>
sampleIds
=
new
ArrayList
<
TechId
>();
List
<
String
>
identifiers
=
new
ArrayList
<
String
>();
for
(
SamplePE
sample
:
samples
)
{
identifiers
.
add
(
sample
.
getPermId
());
sampleIds
.
add
(
TechId
.
create
(
sample
));
}
String
commaSeparatedIdentifiers
=
CollectionUtils
.
abbreviate
(
identifiers
,
-
1
,
CollectionStyle
.
NO_BOUNDARY
);
final
String
reason
=
"reason "
+
commaSeparatedIdentifiers
;
daoFactory
.
getSampleDAO
().
delete
(
sampleIds
,
registrator
,
reason
);
// after deletion there should be an entry about deletion of the sample in event table
final
EventPE
event
=
tryGetDeletionEvent
(
sample
);
assertNotNull
(
event
);
assertEquals
(
reason
,
event
.
getReason
());
assertEquals
(
registrator
,
event
.
getRegistrator
());
for
(
SamplePE
sample
:
samples
)
{
final
EventPE
event
=
tryGetDeletionEvent
(
sample
);
assertNotNull
(
event
);
assertEquals
(
reason
,
event
.
getReason
());
assertEquals
(
commaSeparatedIdentifiers
,
event
.
getIdentifiers
());
assertEquals
(
registrator
,
event
.
getRegistrator
());
}
}
private
EventPE
tryGetDeletionEvent
(
SamplePE
sample
)
...
...
@@ -356,7 +389,7 @@ public final class SampleDAOTest extends AbstractDAOTest
int
beforeDeletionPropertiesRowCount
=
countRowsInTable
(
TableNames
.
SAMPLE_PROPERTIES_TABLE
);
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
// test successful deletion of sample
assertNull
(
sampleDAO
.
tryGetByTechId
(
TechId
.
create
(
sampleToDelete
)));
...
...
@@ -387,7 +420,7 @@ public final class SampleDAOTest extends AbstractDAOTest
int
rowsInAttachmentContents
=
countRowsInTable
(
ATT_CONTENTS_TABLE
);
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
// test successful deletion of sample
assertNull
(
sampleDAO
.
tryGetByTechId
(
TechId
.
create
(
sampleToDelete
)));
...
...
@@ -414,7 +447,7 @@ public final class SampleDAOTest extends AbstractDAOTest
assertTrue
(
sampleToDelete
.
getContained
().
isEmpty
());
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
}
@Test
(
expectedExceptions
=
DataIntegrityViolationException
.
class
,
groups
=
"broken"
)
...
...
@@ -431,7 +464,7 @@ public final class SampleDAOTest extends AbstractDAOTest
assertTrue
(
sampleToDelete
.
getContained
().
isEmpty
());
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
}
@Test
(
expectedExceptions
=
DataIntegrityViolationException
.
class
)
...
...
@@ -447,7 +480,7 @@ public final class SampleDAOTest extends AbstractDAOTest
assertFalse
(
sampleToDelete
.
getContained
().
isEmpty
());
// delete
deleteSample
(
sampleToDelete
);
deleteSample
s
(
sampleToDelete
);
}
private
SpacePE
findSpace
(
String
spaceCode
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment