Search in sources :

Example 1 with NE

use of org.hisp.dhis.common.QueryOperator.NE in project dhis2-core by dhis2.

the class EventsAnalyticsManagerTest method verifyGetEventsWithMissingValueNeFilter.

@Test
void verifyGetEventsWithMissingValueNeFilter() {
    String expected = "ax.\"fWIAEtYVEGk\" is not null";
    testIt(NE, NV, Collections.singleton((capturedSql) -> assertThat(capturedSql, containsString(expected))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) ListGrid(org.hisp.dhis.system.grid.ListGrid) BeforeEach(org.junit.jupiter.api.BeforeEach) ValueType(org.hisp.dhis.common.ValueType) DataType(org.hisp.dhis.analytics.DataType) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DhisConvenienceTest.createProgramIndicator(org.hisp.dhis.DhisConvenienceTest.createProgramIndicator) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) Period(org.hisp.dhis.period.Period) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) PERIOD_DIM_ID(org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID) Collection(java.util.Collection) DimensionType(org.hisp.dhis.common.DimensionType) Test(org.junit.jupiter.api.Test) DhisConvenienceTest.createOrganisationUnit(org.hisp.dhis.DhisConvenienceTest.createOrganisationUnit) NV(org.hisp.dhis.analytics.QueryKey.NV) DhisConvenienceTest.createDataElement(org.hisp.dhis.DhisConvenienceTest.createDataElement) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) ProgramType(org.hisp.dhis.program.ProgramType) QueryFilter(org.hisp.dhis.common.QueryFilter) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) ProgramIndicatorService(org.hisp.dhis.program.ProgramIndicatorService) Mockito.mock(org.mockito.Mockito.mock) Strictness(org.mockito.quality.Strictness) ORGUNIT_DIM_ID(org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID) QueryItem(org.hisp.dhis.common.QueryItem) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) Mock(org.mockito.Mock) CoreMatchers.not(org.hamcrest.CoreMatchers.not) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) Captor(org.mockito.Captor) Program(org.hisp.dhis.program.Program) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) DataElement(org.hisp.dhis.dataelement.DataElement) NE(org.hisp.dhis.common.QueryOperator.NE) ArgumentCaptor(org.mockito.ArgumentCaptor) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) ImmutableList(com.google.common.collect.ImmutableList) DefaultProgramIndicatorSubqueryBuilder(org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder) GridHeader(org.hisp.dhis.common.GridHeader) AnalyticsAggregationType(org.hisp.dhis.analytics.AnalyticsAggregationType) DATA_X_DIM_ID(org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID) DimensionalObjectUtils.getList(org.hisp.dhis.common.DimensionalObjectUtils.getList) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) IN(org.hisp.dhis.common.QueryOperator.IN) ExecutionPlanStore(org.hisp.dhis.analytics.analyze.ExecutionPlanStore) EQ(org.hisp.dhis.common.QueryOperator.EQ) QueryOperator(org.hisp.dhis.common.QueryOperator) AggregationType(org.hisp.dhis.analytics.AggregationType) OPTION_SEP(org.hisp.dhis.common.DimensionalObject.OPTION_SEP) Mockito.when(org.mockito.Mockito.when) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) Grid(org.hisp.dhis.common.Grid) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) PeriodType(org.hisp.dhis.period.PeriodType) Collections(java.util.Collections) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 2 with NE

use of org.hisp.dhis.common.QueryOperator.NE in project dhis2-core by dhis2.

the class EnrollmentAnalyticsManagerTest method verifyGetEnrollmentsWithMissingValueNeFilter.

@Test
void verifyGetEnrollmentsWithMissingValueNeFilter() {
    String subSelect = "(select \"fWIAEtYVEGk\" from analytics_event_" + programA.getUid() + " where analytics_event_" + programA.getUid() + ".pi = ax.pi and \"fWIAEtYVEGk\" is not null and ps = '" + programStage.getUid() + "' order by executiondate desc limit 1 )";
    String expected = subSelect + " is not null";
    testIt(NE, NV, Collections.singleton((capturedSql) -> assertThat(capturedSql, containsString(expected))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) ListGrid(org.hisp.dhis.system.grid.ListGrid) BeforeEach(org.junit.jupiter.api.BeforeEach) BeanRandomizer(org.hisp.dhis.random.BeanRandomizer) Date(java.util.Date) ValueType(org.hisp.dhis.common.ValueType) AnalyticsSqlUtils.quote(org.hisp.dhis.analytics.util.AnalyticsSqlUtils.quote) RepeatableStageParams(org.hisp.dhis.common.RepeatableStageParams) RelationshipConstraint(org.hisp.dhis.relationship.RelationshipConstraint) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DhisConvenienceTest.createProgramIndicator(org.hisp.dhis.DhisConvenienceTest.createProgramIndicator) SqlRowSet(org.springframework.jdbc.support.rowset.SqlRowSet) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) Collection(java.util.Collection) Test(org.junit.jupiter.api.Test) NV(org.hisp.dhis.analytics.QueryKey.NV) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) ProgramIndicatorService(org.hisp.dhis.program.ProgramIndicatorService) Strictness(org.mockito.quality.Strictness) QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) TimeField(org.hisp.dhis.analytics.TimeField) Mock(org.mockito.Mock) CoreMatchers.not(org.hamcrest.CoreMatchers.not) PostgreSQLStatementBuilder(org.hisp.dhis.jdbc.statementbuilder.PostgreSQLStatementBuilder) Captor(org.mockito.Captor) Program(org.hisp.dhis.program.Program) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) NE(org.hisp.dhis.common.QueryOperator.NE) ArgumentCaptor(org.mockito.ArgumentCaptor) ImmutableList(com.google.common.collect.ImmutableList) DefaultProgramIndicatorSubqueryBuilder(org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder) ANALYTICS_TBL_ALIAS(org.hisp.dhis.analytics.util.AnalyticsSqlUtils.ANALYTICS_TBL_ALIAS) RelationshipType(org.hisp.dhis.relationship.RelationshipType) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) RelationshipEntity(org.hisp.dhis.relationship.RelationshipEntity) IN(org.hisp.dhis.common.QueryOperator.IN) ExecutionPlanStore(org.hisp.dhis.analytics.analyze.ExecutionPlanStore) EQ(org.hisp.dhis.common.QueryOperator.EQ) QueryOperator(org.hisp.dhis.common.QueryOperator) OPTION_SEP(org.hisp.dhis.common.DimensionalObject.OPTION_SEP) Mockito.when(org.mockito.Mockito.when) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) DhisConvenienceTest.getDate(org.hisp.dhis.DhisConvenienceTest.getDate) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Collections(java.util.Collections) DateUtils(org.hisp.dhis.util.DateUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Consumer (java.util.function.Consumer)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2 CoreMatchers.not (org.hamcrest.CoreMatchers.not)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 DhisConvenienceTest.createProgram (org.hisp.dhis.DhisConvenienceTest.createProgram)2 DhisConvenienceTest.createProgramIndicator (org.hisp.dhis.DhisConvenienceTest.createProgramIndicator)2 NV (org.hisp.dhis.analytics.QueryKey.NV)2 ExecutionPlanStore (org.hisp.dhis.analytics.analyze.ExecutionPlanStore)2 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)2 DefaultProgramIndicatorSubqueryBuilder (org.hisp.dhis.analytics.event.data.programindicator.DefaultProgramIndicatorSubqueryBuilder)2 OPTION_SEP (org.hisp.dhis.common.DimensionalObject.OPTION_SEP)2 QueryItem (org.hisp.dhis.common.QueryItem)2 QueryOperator (org.hisp.dhis.common.QueryOperator)2 EQ (org.hisp.dhis.common.QueryOperator.EQ)2 IN (org.hisp.dhis.common.QueryOperator.IN)2 NE (org.hisp.dhis.common.QueryOperator.NE)2