From b0a4b38ca530e2086313a61d79c38674286e3692 Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 11 Mar 2013 07:37:11 +0000 Subject: [PATCH] Test for search filtered by state is added. --- .../test/splat/service/TestSearchService.java | 24 ++++++++++++++++++- .../splat/util/TestEntitiesGenerator.java | 4 +--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java index b8b03fe..f9dc920 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java @@ -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()); diff --git a/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java b/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java index 7e8c9f3..f534c4b 100644 --- a/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java +++ b/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java @@ -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()) - .setState(ProgressState.inWORK); + .setSimulationContexts(new ArrayList()); Study study = new Study(studyProps); return study; } -- 2.39.2