Search in sources :

Example 1 with DataCollectionEvent

use of org.obiba.mica.study.domain.DataCollectionEvent in project mica2 by obiba.

the class TestDataCollectionEventSort method test_partial_date_fields.

@Test
public void test_partial_date_fields() {
    Population population = createPopulation("Test Population", createEvent("A", 2010, null, 2020, null), createEvent("A", 1997, 1, 2000, null));
    DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
    assertThat(event.getStart()).isEqualTo(of(1997, 1));
}
Also used : DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 2 with DataCollectionEvent

use of org.obiba.mica.study.domain.DataCollectionEvent 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));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 3 with DataCollectionEvent

use of org.obiba.mica.study.domain.DataCollectionEvent in project mica2 by obiba.

the class TestDataCollectionEventSort method test_study_population_sort.

@Test
public void test_study_population_sort() {
    Study study = new Study();
    study.setId("01234567889");
    study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("A", 2014, 1, 2035, 12)));
    study.addPopulation(createPopulation("Population001", createEvent("A", 1997, 8, 1998, 12), createEvent("A", 1996, 1, 2000, 12)));
    Population population = Iterables.get(study.getPopulations(), 0);
    DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
    assertThat(event.getStart()).isEqualTo(of(1996, 1));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 4 with DataCollectionEvent

use of org.obiba.mica.study.domain.DataCollectionEvent in project mica2 by obiba.

the class TestDataCollectionEventSort method test_study_population_sort_with_duplicate_events.

@Test
public void test_study_population_sort_with_duplicate_events() {
    Study study = new Study();
    study.setId("01234567889");
    study.addPopulation(createPopulation("Population001", createEvent("A", "A", 2010, 1, 2020, 12), createEvent("A", "A", 2014, 1, 2035, 12), createEvent("A", "A", 2010, 1, 2020, 12)));
    Population population = Iterables.get(study.getPopulations(), 0);
    SortedSet<DataCollectionEvent> events = population.getDataCollectionEvents();
    assertThat(events.size()).isEqualTo(2);
    assertThat(Iterables.get(events, 0).getStart()).isEqualTo(of(2010, 1));
    assertThat(Iterables.get(events, 1).getStart()).isEqualTo(of(2014, 1));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 5 with DataCollectionEvent

use of org.obiba.mica.study.domain.DataCollectionEvent in project mica2 by obiba.

the class TestDataCollectionEventSort method createPopulation.

private Population createPopulation(String name, DataCollectionEvent... events) {
    Population population = new Population();
    population.setName(en(name));
    for (DataCollectionEvent event : events) {
        population.addDataCollectionEvent(event);
    }
    return population;
}
Also used : DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population)

Aggregations

DataCollectionEvent (org.obiba.mica.study.domain.DataCollectionEvent)12 Population (org.obiba.mica.study.domain.Population)9 Test (org.junit.Test)7 Study (org.obiba.mica.study.domain.Study)3 NotNull (javax.validation.constraints.NotNull)2 StudyTable (org.obiba.mica.core.domain.StudyTable)2 BaseStudy (org.obiba.mica.study.domain.BaseStudy)2 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 EventBus (com.google.common.eventbus.EventBus)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 StreamSupport (java.util.stream.StreamSupport)1 Inject (javax.inject.Inject)1