// Path: resource-server/src/main/java/org/openmhealth/dsu/domain/DataPointSearchCriteria.java
// public class DataPointSearchCriteria {
// 
//     private String userId;
//     private String schemaNamespace;
//     private String schemaName;
//     private SchemaVersion schemaVersion;
//     private Range<OffsetDateTime> creationTimestampRange;
// 
//     public DataPointSearchCriteria(String userId, String schemaNamespace, String schemaName, String schemaVersion) {
// 
//         checkNotNull(userId);
//         checkArgument(!isNullOrEmpty(userId));
// 
//         // TODO determine how restrictive the search criteria should be
//         checkNotNull(schemaNamespace);
//         checkNotNull(schemaName);
//         checkNotNull(schemaVersion);
// 
//         checkArgument(isValidNamespace(schemaNamespace));
//         checkArgument(isValidName(schemaName));
//         checkArgument(isValidVersion(schemaVersion));
// 
//         this.userId = userId;
//         this.schemaNamespace = schemaNamespace;
//         this.schemaName = schemaName;
//         this.schemaVersion = new SchemaVersion(schemaVersion);
//     }
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public String getSchemaNamespace() {
//         return schemaNamespace;
//     }
// 
//     public String getSchemaName() {
//         return schemaName;
//     }
// 
//     public SchemaVersion getSchemaVersion() {
//         return schemaVersion;
//     }
// 
//     public Optional<Range<OffsetDateTime>> getCreationTimestampRange() {
//         return Optional.ofNullable(creationTimestampRange);
//     }
// 
//     public void setCreationTimestampRange(Range<OffsetDateTime> creationTimestampRange) {
//         this.creationTimestampRange = creationTimestampRange;
//     }
// }


import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.openmhealth.dsu.factory.DataPointFactory.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openmhealth.dsu.domain.DataPointSearchCriteria;
import org.openmhealth.schema.domain.omh.DataPoint;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.google.common.collect.Lists.newArrayList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.empty;
    }

    @Test
    public void findBySearchCriteriaShouldOnlyReturnDataPointsMatchingSchemaMajorVersion() {

        DataPointSearchCriteria searchCriteria = newSearchCriteriaBuilder().setSchemaVersionMajor(0).build();

        List<DataPoint> dataPoints = newArrayList(repository.findBySearchCriteria(searchCriteria, null, null));

        assertThat(dataPoints, empty());
    }

    @Test
    public void findBySearchCriteriaShouldOnlyReturnDataPointsMatchingSchemaMinorVersion() {

        DataPointSearchCriteria searchCriteria = newSearchCriteriaBuilder().setSchemaVersionMinor(0).build();

        List<DataPoint> dataPoints = newArrayList(repository.findBySearchCriteria(searchCriteria, null, null));

        assertThat(dataPoints, empty());
    }

    @Test
    public void findBySearchCriteriaShouldReturnDataPointsMatchingSchemaVersionQualifier() {

        DataPoint newTestDataPoint = newDataPointBuilder().setSchemaVersionQualifier("RC1").build();

        newTestDataPoint = repository.save(newTestDataPoint);
        testDataPoints.add(newTestDataPoint);

// Path: resource-server/src/main/java/org/openmhealth/dsu/domain/DataPointSearchCriteria.java
// public class DataPointSearchCriteria {
// 
//     private String userId;
//     private String schemaNamespace;
//     private String schemaName;
//     private SchemaVersion schemaVersion;
//     private Range<OffsetDateTime> creationTimestampRange;
// 
//     public DataPointSearchCriteria(String userId, String schemaNamespace, String schemaName, String schemaVersion) {
// 
//         checkNotNull(userId);
//         checkArgument(!isNullOrEmpty(userId));
// 
//         // TODO determine how restrictive the search criteria should be
//         checkNotNull(schemaNamespace);
//         checkNotNull(schemaName);
//         checkNotNull(schemaVersion);
// 
//         checkArgument(isValidNamespace(schemaNamespace));
//         checkArgument(isValidName(schemaName));
//         checkArgument(isValidVersion(schemaVersion));
// 
//         this.userId = userId;
//         this.schemaNamespace = schemaNamespace;
//         this.schemaName = schemaName;
//         this.schemaVersion = new SchemaVersion(schemaVersion);
//     }
// 
//     public String getUserId() {
//         return userId;
//     }
// 
//     public String getSchemaNamespace() {
//         return schemaNamespace;
//     }
// 
//     public String getSchemaName() {
//         return schemaName;
//     }
// 
//     public SchemaVersion getSchemaVersion() {
//         return schemaVersion;
//     }
// 
//     public Optional<Range<OffsetDateTime>> getCreationTimestampRange() {
//         return Optional.ofNullable(creationTimestampRange);
//     }
// 
//     public void setCreationTimestampRange(Range<OffsetDateTime> creationTimestampRange) {
//         this.creationTimestampRange = creationTimestampRange;
//     }
// }


// Path: resource-server/src/test/java/org/openmhealth/dsu/repository/DataPointRepositoryIntegrationTests.java
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.openmhealth.dsu.factory.DataPointFactory.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openmhealth.dsu.domain.DataPointSearchCriteria;
import org.openmhealth.schema.domain.omh.DataPoint;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.google.common.collect.Lists.newArrayList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.empty;

    }

    @Test
    public void findBySearchCriteriaShouldOnlyReturnDataPointsMatchingSchemaMajorVersion() {

        DataPointSearchCriteria searchCriteria = newSearchCriteriaBuilder().setSchemaVersionMajor(0).build();

        List<DataPoint> dataPoints = newArrayList(repository.findBySearchCriteria(searchCriteria, null, null));

        assertThat(dataPoints, empty());
    }

    @Test
    public void findBySearchCriteriaShouldOnlyReturnDataPointsMatchingSchemaMinorVersion() {

        DataPointSearchCriteria searchCriteria = newSearchCriteriaBuilder().setSchemaVersionMinor(0).build();

        List<DataPoint> dataPoints = newArrayList(repository.findBySearchCriteria(searchCriteria, null, null));

        assertThat(dataPoints, empty());
    }

    @Test
    public void findBySearchCriteriaShouldReturnDataPointsMatchingSchemaVersionQualifier() {

        DataPoint newTestDataPoint = newDataPointBuilder().setSchemaVersionQualifier("RC1").build();

        newTestDataPoint = repository.save(newTestDataPoint);
        testDataPoints.add(newTestDataPoint);

        DataPointSearchCriteria searchCriteria = newSearchCriteriaBuilder().setSchemaVersionQualifier("RC1").build();