]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Test for search filtered by state is added.
authorrkv <rkv@opencascade.com>
Mon, 11 Mar 2013 07:37:11 +0000 (07:37 +0000)
committerrkv <rkv@opencascade.com>
Mon, 11 Mar 2013 07:37:11 +0000 (07:37 +0000)
Workspace/Siman-Common/src/test/splat/service/TestSearchService.java
Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java

index b8b03fec8d1be5fcb9321ac76da9556c813ccb44..f9dc920bc57e3b31fa569c34825b8546252f13f9 100644 (file)
@@ -19,6 +19,7 @@ import org.splat.dal.bo.som.ContributorRelation;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
@@ -251,10 +252,11 @@ public class TestSearchService extends BaseTest {
                aStudy.setReference("TEST_REF");
                Long refStudyId = _studyDAO.create(aStudy);
 
-               // ============== STUDY 3: Private : thirdUser : otherUser is contributor
+               // ============== STUDY 3: Private : inDraft : thirdUser : otherUser is contributor
                // Create private study of third user with otherUser as a reviewer
                aStudy = TestEntitiesGenerator.getTestStudy(thirdUser);
                aStudy.setTitle("3.This is a private study of third user");
+               aStudy.setProgressState(ProgressState.inDRAFT);
                Long reviewStudyId = _studyDAO.create(aStudy);
 
                // Create validation cycle for the last study
@@ -300,6 +302,16 @@ public class TestSearchService extends BaseTest {
                Assert.assertEquals(res.get(1).getIndex(), refStudyId); // Public study
                Assert.assertEquals(res.get(2).getIndex(), titleStudyId); // Public study
 
+               // Search for logged in study contributor
+               // filtered by state
+               filter = new StudySearchFilterDTO();
+               filter.setConnectedUserId(otherUser.getIndex());
+               filter.setState(ProgressState.inDRAFT);
+               res = _searchService.selectStudiesWhere(filter);
+               Assert.assertNotNull(res);
+               Assert.assertEquals(res.size(), 1);
+               Assert.assertEquals(res.get(0).getIndex(), reviewStudyId); // OtherUser is reviewer in this study
+
                // Search by study title contents
                filter = new StudySearchFilterDTO();
                filter.setWords("study public");
@@ -420,6 +432,7 @@ public class TestSearchService extends BaseTest {
                _userDAO.create(thirdUser);
                KnowledgeElementType ktype1 = new KnowledgeElementType("testKType1");
                KnowledgeElementType ktype2 = new KnowledgeElementType("testKType2");
+               ktype2.setState(ProgressState.inWORK);
                _knowledgeElementTypeDAO.create(ktype1);
                _knowledgeElementTypeDAO.create(ktype2);
 
@@ -541,6 +554,15 @@ public class TestSearchService extends BaseTest {
                Assert.assertEquals(res.get(0).getTitle(), kelm11.getTitle());
                Assert.assertEquals(res.get(1).getTitle(), kelm12.getTitle());
 
+               // Search by author goodUser as not logged in user and filter by state
+               filter = new KnowledgeSearchFilterDTO();
+               filter.setAuthor(String.valueOf(goodUser.getIndex()));
+               filter.setState(ProgressState.inWORK);
+               res = _searchService.selectKnowledgeElementsWhere(filter);
+               Assert.assertNotNull(res);
+               Assert.assertEquals(res.size(), 1);
+               Assert.assertEquals(res.get(0).getTitle(), kelm12.getTitle());
+
                // Search for other logged in study contributor (what is visible for otherUser by default)
                filter = new KnowledgeSearchFilterDTO();
                filter.setConnectedUserId(otherUser.getIndex());
index 7e8c9f3e11fd710802b679e30d00e6b0d00a983f..f534c4bf3890cb3e79318c29d671de996d5021c9 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Date;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
@@ -63,8 +62,7 @@ public class TestEntitiesGenerator {
                                .setTitle("a test study")
                                // .setDescription("description")
                                .setDate(new Date()).setReference("test reference")
-                               .setSimulationContexts(new ArrayList<SimulationContext>())
-                               .setState(ProgressState.inWORK);
+                               .setSimulationContexts(new ArrayList<SimulationContext>());
                Study study = new Study(studyProps);
                return study;
        }