@@ -0,0 +1,2165 @@
+package ca.uhn.fhir.rest.param;%0A%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport ca.uhn.fhir.context.FhirContext;%0Aimport ca.uhn.fhir.rest.api.QualifiedParamList;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0Aimport org.mockito.Mockito;%0A%0A@RunWith(JUnit4.class)%0Apublic class DateRangeParamTest %7B%0A%09private FhirContext fhirContext;%0A%0A%09@Before%0A%09public void initMockContext() %7B%0A%09%09fhirContext = Mockito.mock(FhirContext.class);%0A%09%7D%0A%0A%09/** Can happen e.g. when the query parameter for %7B@code _lastUpdated%7D is left empty. */%0A%09@Test%0A%09public void testParamWithoutPrefixAndWithoutValue() %7B%0A%09%09QualifiedParamList qualifiedParamList = new QualifiedParamList(1);%0A%09%09qualifiedParamList.add(%22%22);%0A%0A%09%09List%3CQualifiedParamList%3E params = new ArrayList%3C%3E(1);%0A%09%09params.add(qualifiedParamList);%0A%09%09DateRangeParam dateRangeParam = new DateRangeParam();%0A%09%09dateRangeParam.setValuesAsQueryTokens(fhirContext, %22_lastUpdated%22, params);%0A%0A%09%09assertTrue(dateRangeParam.isEmpty());%0A%09%7D%0A%0A%09/** Can happen e.g. when the query parameter for %7B@code _lastUpdated%7D is given as %7B@code lt%7D without any value. */%0A%09@Test%0A%09public void testUpperBoundWithPrefixWithoutValue() %7B%0A%09%09QualifiedParamList qualifiedParamList = new QualifiedParamList(1);%0A%09%09qualifiedParamList.add(%22lt%22);%0A%0A%09%09List%3CQualifiedParamList%3E params = new ArrayList%3C%3E(1);%0A%09%09params.add(qualifiedParamList);%0A%09%09DateRangeParam dateRangeParam = new DateRangeParam();%0A%09%09dateRangeParam.setValuesAsQueryTokens(fhirContext, %22_lastUpdated%22, params);%0A%0A%09%09assertTrue(dateRangeParam.isEmpty());%0A%09%7D%0A%0A%09/** Can happen e.g. when the query parameter for %7B@code _lastUpdated%7D is given as %7B@code gt%7D without any value. */%0A%09@Test%0A%09public void testLowerBoundWithPrefixWithoutValue() %7B%0A%09%09QualifiedParamList qualifiedParamList = new QualifiedParamList(1);%0A%09%09qualifiedParamList.add(%22gt%22);%0A%0A%09%09List%3CQualifiedParamList%3E params = new ArrayList%3C%3E(1);%0A%09%09params.add(qualifiedParamList);%0A%09%09DateRangeParam dateRangeParam = new DateRangeParam();%0A%09%09dateRangeParam.setValuesAsQueryTokens(fhirContext, %22_lastUpdated%22, params);%0A%0A%09%09assertTrue(dateRangeParam.isEmpty());%0A%09%7D%0A%7D%0A

Add some test demonstrating null pointer problems in the DateRangeParam class