use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class IndividualStudyServiceTest method test_update_study.
@Test
public void test_update_study() throws Exception {
Study study = new Study();
study.setName(en("name en to update").forFr("name fr to update"));
individualStudyService.save(study);
study.setName(en("new name en").forFr("new name fr"));
individualStudyService.save(study);
List<StudyState> studyStates = studyStateRepository.findAll();
assertThat(studyStates).hasSize(1);
StudyState studyState = studyStates.get(0);
//
assertThat(studyState.getId()).isNotEmpty().isEqualTo(study.getId());
verify(eventBus, times(2)).post(any(DraftStudyUpdatedEvent.class));
Study retrievedStudy = individualStudyService.findDraft(study.getId());
assertThat(retrievedStudy).areFieldsEqualToEachOther(study);
}
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 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_loosing_git_clone_repo.
@Test
public void test_loosing_git_clone_repo() 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_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("4");
}
Aggregations