|
1 | 1 | package org.labkey.laboratory; |
2 | 2 |
|
3 | 3 | import org.junit.After; |
| 4 | +import org.junit.Assert; |
4 | 5 | import org.junit.Before; |
5 | 6 | import org.junit.Test; |
6 | 7 | import org.labkey.api.collections.CaseInsensitiveHashMap; |
| 8 | +import org.labkey.api.data.Container; |
| 9 | +import org.labkey.api.data.ContainerManager; |
| 10 | +import org.labkey.api.data.DbSchema; |
| 11 | +import org.labkey.api.data.DbSchemaType; |
| 12 | +import org.labkey.api.data.SimpleFilter; |
7 | 13 | import org.labkey.api.data.TableInfo; |
8 | 14 | import org.labkey.api.data.TableSelector; |
9 | 15 | import org.labkey.api.data.WorkbookContainerType; |
@@ -33,7 +39,10 @@ public class WorkbookTestCase extends WorkbookContainerType.AbstractTestCase |
33 | 39 | public void setUp() throws Exception |
34 | 40 | { |
35 | 41 | _context = TestContext.get(); |
36 | | - doInitialSetUp(PROJECT_NAME); |
| 42 | + if (_project == null) |
| 43 | + { |
| 44 | + doInitialSetUp(PROJECT_NAME); |
| 45 | + } |
37 | 46 | } |
38 | 47 |
|
39 | 48 | @Test |
@@ -66,11 +75,26 @@ public void testCrossContainerBehaviorsForSimpleSchema() throws Exception |
66 | 75 | testCrossContainerBehaviors(_project, _workbooks, LaboratoryModule.SCHEMA_NAME, LaboratorySchema.TABLE_SAMPLE_TYPE, LaboratorySchema.TABLE_SAMPLES, "samplename", "sampletype", Arrays.asList("Value1", "Value2", "Value3", "Value4"), extraRowValues); |
67 | 76 | } |
68 | 77 | } |
| 78 | + |
| 79 | + // Verify laboratory.workbooks rows get deleted: |
| 80 | + Container newWorkbook = ContainerManager.createContainer(_project, null, "Title3", null, WorkbookContainerType.NAME, _context.getUser()); |
| 81 | + |
| 82 | + TableInfo ti = DbSchema.get(LaboratoryModule.SCHEMA_NAME, DbSchemaType.Module).getTable(LaboratorySchema.TABLE_WORKBOOKS); |
| 83 | + TableSelector ts = new TableSelector(ti, new SimpleFilter(FieldKey.fromString("container"), newWorkbook.getId()), null); |
| 84 | + Assert.assertTrue("laboratory.workbooks row should exist", ts.exists()); |
| 85 | + |
| 86 | + ContainerManager.delete(newWorkbook, TestContext.get().getUser()); |
| 87 | + Assert.assertFalse("laboratory.workbooks row should have been deleted", ts.exists()); |
69 | 88 | } |
70 | 89 |
|
71 | 90 | @After |
72 | 91 | public void onComplete() |
73 | 92 | { |
74 | 93 | doCleanup(PROJECT_NAME); |
| 94 | + if (_project != null) |
| 95 | + { |
| 96 | + TableSelector ts = new TableSelector(DbSchema.get(LaboratoryModule.SCHEMA_NAME, DbSchemaType.Module).getTable(LaboratorySchema.TABLE_WORKBOOKS), new SimpleFilter(FieldKey.fromString("parentContainer"), _project.getId()), null); |
| 97 | + Assert.assertFalse("laboratory.workbooks rows should have been deleted", ts.exists()); |
| 98 | + } |
75 | 99 | } |
76 | 100 | } |
0 commit comments