use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class IndividualStudyServiceTest method test_loosing_git_base_and_clone_repos.
@Test
public void test_loosing_git_base_and_clone_repos() throws IOException {
Study study = new Study();
Stream.of("a", "b", "c").forEach(name -> {
study.setName(en(name + " en").forFr(name + " fr"));
individualStudyService.save(study);
individualStudyService.publish(study.getId(), true);
});
FileUtil.delete(Config.BASE_REPO);
FileUtil.delete(Config.BASE_CLONE);
Study draft = individualStudyService.findDraft(study.getId());
draft.setName(en("d en").forFr("d fr"));
individualStudyService.save(draft);
individualStudyService.publish(draft.getId(), true);
StudyState studyState = individualStudyService.findStateById(draft.getId());
assertThat(studyState.isPublished()).isTrue();
assertThat(studyState.getPublishedTag()).isEqualTo("1");
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class IndividualStudyServiceTest method test_delete_study_conflict.
@Test
public void test_delete_study_conflict() {
Study study = new Study();
study.setName(en("name en").forFr("name fr"));
individualStudyService.save(study);
Network network = new Network();
network.setId("test");
network.setStudyIds(new ArrayList() {
{
add(study.getId());
}
});
networkRepository.save(network);
assertThat(studyStateRepository.findAll()).hasSize(1);
exception.expect(ConstraintException.class);
individualStudyService.delete(study.getId());
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class IndividualStudyServiceTest method test_find_all_draft_studies.
@Test
public void test_find_all_draft_studies() {
Stream.of("cancer", "gout", "diabetes").forEach(name -> {
Study draft = new Study();
draft.setName(en(name + " en").forFr(name + " fr"));
individualStudyService.save(draft);
});
List<Study> drafts = individualStudyService.findAllDraftStudies();
assertThat(drafts.size()).isEqualTo(3);
assertThat(drafts.get(2).getName().get("en")).isEqualTo("diabetes en");
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class IndividualStudyServiceTest method testCreateStudyWithContacts.
@Test
public void testCreateStudyWithContacts() throws Exception {
Study study = new Study();
study.setId("test");
Person person = new Person();
person.setEmail("test@test.com");
List<Person> persons = Lists.newArrayList();
persons.add(person);
study.getMemberships().get(Membership.CONTACT).addAll(persons.stream().map(e -> new Membership(e, "contact")).collect(Collectors.toList()));
individualStudyService.save(study);
Study retrievedStudy = individualStudyService.findDraft(study.getId());
List<Person> retrievedPersons = retrievedStudy.getMemberships().get(Membership.CONTACT).stream().map(Membership::getPerson).collect(Collectors.toList());
assertThat(retrievedPersons).contains(person);
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class TestDataCollectionEventSort method test_study_population_sort_with_duplicate_event_dates.
@Test
public void test_study_population_sort_with_duplicate_event_dates() {
Study study = new Study();
study.setId("01234567889");
study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("B", 2014, 1, 2035, 12), createEvent("C", 2010, 1, 2020, 12)));
Population population = Iterables.get(study.getPopulations(), 0);
SortedSet<DataCollectionEvent> events = population.getDataCollectionEvents();
assertThat(events.size()).isEqualTo(3);
assertThat(Iterables.get(events, 0).getStart()).isEqualTo(of(2010, 1));
assertThat(Iterables.get(events, 1).getStart()).isEqualTo(of(2010, 1));
}
Aggregations