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;
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
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");
_userDAO.create(thirdUser);
KnowledgeElementType ktype1 = new KnowledgeElementType("testKType1");
KnowledgeElementType ktype2 = new KnowledgeElementType("testKType2");
+ ktype2.setState(ProgressState.inWORK);
_knowledgeElementTypeDAO.create(ktype1);
_knowledgeElementTypeDAO.create(ktype2);
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());
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;
.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;
}