Search in sources :

Example 11 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class DateContextTest method rangeAbsYearTestWithCoarse.

@Test
public void rangeAbsYearTestWithCoarse() {
    CDateRange mask = CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2005, 4, 21));
    List<DateContext> contexts = DateContext.generateAbsoluteContexts(mask, ExportForm.getResolutionAlignmentMap(YEARS.getThisAndCoarserSubdivisions(), YEAR));
    assertThat(contexts).extracting(DateContext::getDateRange).containsExactly(mask, CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2001, 12, 31)), CDateRange.of(LocalDate.of(2002, 1, 1), LocalDate.of(2002, 12, 31)), CDateRange.of(LocalDate.of(2003, 1, 1), LocalDate.of(2003, 12, 31)), CDateRange.of(LocalDate.of(2004, 1, 1), LocalDate.of(2004, 12, 31)), CDateRange.of(LocalDate.of(2005, 1, 1), LocalDate.of(2005, 4, 21)));
    assertThat(contexts).extracting(DateContext::getFeatureGroup).containsOnly(FeatureGroup.OUTCOME);
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) DateContext(com.bakdata.conquery.models.forms.util.DateContext) Test(org.junit.jupiter.api.Test)

Example 12 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class DateContextTest method rangeAbsYearTestWithoutCoarse.

@Test
public void rangeAbsYearTestWithoutCoarse() {
    CDateRange mask = CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2005, 4, 21));
    List<DateContext> contexts = DateContext.generateAbsoluteContexts(mask, ExportForm.getResolutionAlignmentMap(List.of(YEARS), YEAR));
    assertThat(contexts).extracting(DateContext::getDateRange).containsExactly(CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2001, 12, 31)), CDateRange.of(LocalDate.of(2002, 1, 1), LocalDate.of(2002, 12, 31)), CDateRange.of(LocalDate.of(2003, 1, 1), LocalDate.of(2003, 12, 31)), CDateRange.of(LocalDate.of(2004, 1, 1), LocalDate.of(2004, 12, 31)), CDateRange.of(LocalDate.of(2005, 1, 1), LocalDate.of(2005, 4, 21)));
    assertThat(contexts).extracting(DateContext::getFeatureGroup).containsOnly(FeatureGroup.OUTCOME);
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) DateContext(com.bakdata.conquery.models.forms.util.DateContext) Test(org.junit.jupiter.api.Test)

Example 13 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class DateContextTest method rangeAbsQuarterTestWithCoarse.

@Test
public void rangeAbsQuarterTestWithCoarse() {
    CDateRange mask = CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2003, 4, 21));
    List<DateContext> contexts = DateContext.generateAbsoluteContexts(mask, ExportForm.getResolutionAlignmentMap(QUARTERS.getThisAndCoarserSubdivisions(), QUARTER));
    assertThat(contexts).extracting(DateContext::getDateRange).containsExactly(// Complete
    mask, // Years
    CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2002, 3, 31)), CDateRange.of(LocalDate.of(2002, 4, 1), LocalDate.of(2003, 3, 31)), CDateRange.of(LocalDate.of(2003, 4, 1), LocalDate.of(2003, 4, 21)), // Quarters
    CDateRange.of(LocalDate.of(2001, 5, 23), LocalDate.of(2001, 6, 30)), CDateRange.of(LocalDate.of(2001, 7, 1), LocalDate.of(2001, 9, 30)), CDateRange.of(LocalDate.of(2001, 10, 1), LocalDate.of(2001, 12, 31)), CDateRange.of(LocalDate.of(2002, 1, 1), LocalDate.of(2002, 3, 31)), CDateRange.of(LocalDate.of(2002, 4, 1), LocalDate.of(2002, 6, 30)), CDateRange.of(LocalDate.of(2002, 7, 1), LocalDate.of(2002, 9, 30)), CDateRange.of(LocalDate.of(2002, 10, 1), LocalDate.of(2002, 12, 31)), CDateRange.of(LocalDate.of(2003, 1, 1), LocalDate.of(2003, 3, 31)), CDateRange.of(LocalDate.of(2003, 4, 1), LocalDate.of(2003, 4, 21)));
    assertThat(contexts).extracting(DateContext::getFeatureGroup).containsOnly(FeatureGroup.OUTCOME);
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) DateContext(com.bakdata.conquery.models.forms.util.DateContext) Test(org.junit.jupiter.api.Test)

Example 14 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class RangeTest method coveredQuarters.

@Test
public void coveredQuarters() {
    CDateRange dateRange = CDateRange.of(LocalDate.of(2000, 9, 2), LocalDate.of(2002, 3, 15));
    List<CDateRange> expected = new ArrayList<>();
    expected.add(CDateRange.of(LocalDate.of(2000, 9, 2), LocalDate.of(2000, 9, 30)));
    expected.add(CDateRange.of(LocalDate.of(2000, 10, 1), LocalDate.of(2000, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2001, 1, 1), LocalDate.of(2001, 3, 31)));
    expected.add(CDateRange.of(LocalDate.of(2001, 4, 1), LocalDate.of(2001, 6, 30)));
    expected.add(CDateRange.of(LocalDate.of(2001, 7, 1), LocalDate.of(2001, 9, 30)));
    expected.add(CDateRange.of(LocalDate.of(2001, 10, 1), LocalDate.of(2001, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2002, 1, 1), LocalDate.of(2002, 3, 15)));
    assertThat(dateRange.getCoveredQuarters()).containsExactlyInAnyOrderElementsOf(expected);
}
Also used : ArrayList(java.util.ArrayList) CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class RangeTest method coveredYears.

@Test
public void coveredYears() {
    CDateRange dateRange = CDateRange.of(LocalDate.of(2000, 9, 2), LocalDate.of(2005, 3, 15));
    List<CDateRange> expected = new ArrayList<>();
    expected.add(CDateRange.of(LocalDate.of(2000, 9, 2), LocalDate.of(2000, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2001, 1, 1), LocalDate.of(2001, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2002, 1, 1), LocalDate.of(2002, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2003, 1, 1), LocalDate.of(2003, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2004, 1, 1), LocalDate.of(2004, 12, 31)));
    expected.add(CDateRange.of(LocalDate.of(2005, 1, 1), LocalDate.of(2005, 3, 15)));
    assertThat(dateRange.getCoveredYears()).containsExactlyInAnyOrderElementsOf(expected);
}
Also used : ArrayList(java.util.ArrayList) CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CDateRange (com.bakdata.conquery.models.common.daterange.CDateRange)25 Test (org.junit.jupiter.api.Test)8 DateContext (com.bakdata.conquery.models.forms.util.DateContext)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CDateSet (com.bakdata.conquery.models.common.CDateSet)3 ArrayList (java.util.ArrayList)3 ExportForm (com.bakdata.conquery.apiv1.forms.export_form.ExportForm)2 LocalDate (java.time.LocalDate)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Column (com.bakdata.conquery.models.datasets.Column)1 Table (com.bakdata.conquery.models.datasets.Table)1 CBlock (com.bakdata.conquery.models.events.CBlock)1 ParsingException (com.bakdata.conquery.models.exceptions.ParsingException)1 DateAggregator (com.bakdata.conquery.models.query.queryplan.DateAggregator)1 EntityResult (com.bakdata.conquery.models.query.results.EntityResult)1 MultilineEntityResult (com.bakdata.conquery.models.query.results.MultilineEntityResult)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1