use of org.hl7.fhir.r4.model.Condition in project BridgeServer2 by Sage-Bionetworks.
the class DynamoHealthDataEx3DaoTest method getRecordsForApp.
@Test
public void getRecordsForApp() {
// Mock dependencies.
DynamoHealthDataRecordEx3 record = new DynamoHealthDataRecordEx3();
doReturn(ImmutableList.of(record)).when(dao).queryHelper(any());
// Execute.
ForwardCursorPagedResourceList<HealthDataRecordEx3> resultList = dao.getRecordsForApp(TestConstants.TEST_APP_ID, CREATED_ON_START, CREATED_ON_END, BridgeConstants.API_DEFAULT_PAGE_SIZE, null);
assertEquals(resultList.getItems().size(), 1);
assertSame(resultList.getItems().get(0), record);
assertNull(resultList.getNextPageOffsetKey());
// Validate.
ArgumentCaptor<DynamoDBQueryExpression<DynamoHealthDataRecordEx3>> queryCaptor = ArgumentCaptor.forClass(DynamoDBQueryExpression.class);
verify(dao).queryHelper(queryCaptor.capture());
DynamoDBQueryExpression<DynamoHealthDataRecordEx3> query = queryCaptor.getValue();
assertFalse(query.isConsistentRead());
assertEquals(query.getIndexName(), DynamoHealthDataRecordEx3.APPID_CREATEDON_INDEX);
assertEquals(query.getHashKeyValues().getAppId(), TestConstants.TEST_APP_ID);
assertEquals(query.getLimit().intValue(), BridgeConstants.API_DEFAULT_PAGE_SIZE + 1);
assertEquals(query.getRangeKeyConditions().size(), 1);
Condition rangeKeyCondition = query.getRangeKeyConditions().get("createdOn");
assertEquals(rangeKeyCondition.getComparisonOperator(), ComparisonOperator.BETWEEN.toString());
assertEquals(rangeKeyCondition.getAttributeValueList().size(), 2);
assertEquals(rangeKeyCondition.getAttributeValueList().get(0).getN(), String.valueOf(CREATED_ON_START));
assertEquals(rangeKeyCondition.getAttributeValueList().get(1).getN(), String.valueOf(CREATED_ON_END));
}
use of org.hl7.fhir.r4.model.Condition in project BridgeServer2 by Sage-Bionetworks.
the class DynamoHealthDataEx3DaoTest method getRecordsForHealthCode.
@Test
public void getRecordsForHealthCode() {
// Mock dependencies.
DynamoHealthDataRecordEx3 record = new DynamoHealthDataRecordEx3();
doReturn(ImmutableList.of(record)).when(dao).queryHelper(any());
// Execute.
ForwardCursorPagedResourceList<HealthDataRecordEx3> resultList = dao.getRecordsForHealthCode(TestConstants.HEALTH_CODE, CREATED_ON_START, CREATED_ON_END, BridgeConstants.API_DEFAULT_PAGE_SIZE, null);
assertEquals(resultList.getItems().size(), 1);
assertSame(resultList.getItems().get(0), record);
assertNull(resultList.getNextPageOffsetKey());
// Validate.
ArgumentCaptor<DynamoDBQueryExpression<DynamoHealthDataRecordEx3>> queryCaptor = ArgumentCaptor.forClass(DynamoDBQueryExpression.class);
verify(dao).queryHelper(queryCaptor.capture());
DynamoDBQueryExpression<DynamoHealthDataRecordEx3> query = queryCaptor.getValue();
assertFalse(query.isConsistentRead());
assertEquals(query.getIndexName(), DynamoHealthDataRecordEx3.HEALTHCODE_CREATEDON_INDEX);
assertEquals(query.getHashKeyValues().getHealthCode(), TestConstants.HEALTH_CODE);
assertEquals(query.getLimit().intValue(), BridgeConstants.API_DEFAULT_PAGE_SIZE + 1);
assertEquals(query.getRangeKeyConditions().size(), 1);
Condition rangeKeyCondition = query.getRangeKeyConditions().get("createdOn");
assertEquals(rangeKeyCondition.getComparisonOperator(), ComparisonOperator.BETWEEN.toString());
assertEquals(rangeKeyCondition.getAttributeValueList().size(), 2);
assertEquals(rangeKeyCondition.getAttributeValueList().get(0).getN(), String.valueOf(CREATED_ON_START));
assertEquals(rangeKeyCondition.getAttributeValueList().get(1).getN(), String.valueOf(CREATED_ON_END));
}
use of org.hl7.fhir.r4.model.Condition in project BridgeServer2 by Sage-Bionetworks.
the class DynamoHealthDataEx3DaoTest method getRecordsForHealthCode_offsetKeyAfterCreatedOnStart.
@Test
public void getRecordsForHealthCode_offsetKeyAfterCreatedOnStart() {
// Mock dependencies.
DynamoHealthDataRecordEx3 record = new DynamoHealthDataRecordEx3();
doReturn(ImmutableList.of(record)).when(dao).queryHelper(any());
// Execute.
dao.getRecordsForHealthCode(TestConstants.HEALTH_CODE, CREATED_ON_START, CREATED_ON_END, BridgeConstants.API_DEFAULT_PAGE_SIZE, String.valueOf(CREATED_ON_START + 10000));
// Validate.
ArgumentCaptor<DynamoDBQueryExpression<DynamoHealthDataRecordEx3>> queryCaptor = ArgumentCaptor.forClass(DynamoDBQueryExpression.class);
verify(dao).queryHelper(queryCaptor.capture());
DynamoDBQueryExpression<DynamoHealthDataRecordEx3> query = queryCaptor.getValue();
Condition rangeKeyCondition = query.getRangeKeyConditions().get("createdOn");
assertEquals(rangeKeyCondition.getAttributeValueList().get(0).getN(), String.valueOf(CREATED_ON_START + 10000));
}
use of org.hl7.fhir.r4.model.Condition in project BridgeServer2 by Sage-Bionetworks.
the class DynamoHealthDataEx3DaoTest method getRecordsForHealthCode_offsetKeyBeforeCreatedOnStart.
@Test
public void getRecordsForHealthCode_offsetKeyBeforeCreatedOnStart() {
// Mock dependencies.
DynamoHealthDataRecordEx3 record = new DynamoHealthDataRecordEx3();
doReturn(ImmutableList.of(record)).when(dao).queryHelper(any());
// Execute.
dao.getRecordsForHealthCode(TestConstants.HEALTH_CODE, CREATED_ON_START, CREATED_ON_END, BridgeConstants.API_DEFAULT_PAGE_SIZE, String.valueOf(CREATED_ON_START - 10000));
// Validate.
ArgumentCaptor<DynamoDBQueryExpression<DynamoHealthDataRecordEx3>> queryCaptor = ArgumentCaptor.forClass(DynamoDBQueryExpression.class);
verify(dao).queryHelper(queryCaptor.capture());
DynamoDBQueryExpression<DynamoHealthDataRecordEx3> query = queryCaptor.getValue();
Condition rangeKeyCondition = query.getRangeKeyConditions().get("createdOn");
assertEquals(rangeKeyCondition.getAttributeValueList().get(0).getN(), String.valueOf(CREATED_ON_START));
}
use of org.hl7.fhir.r4.model.Condition in project BridgeServer2 by Sage-Bionetworks.
the class DynamoNotificationTopicDao method listTopics.
@Override
public List<NotificationTopic> listTopics(String appId, boolean includeDeleted) {
checkNotNull(appId);
// Consistent reads is set to true, because this is the table's primary key, and having reliable tests is more
// important than saving a small amount of DDB capacity.
DynamoNotificationTopic hashKey = new DynamoNotificationTopic();
hashKey.setAppId(appId);
DynamoDBQueryExpression<DynamoNotificationTopic> query = new DynamoDBQueryExpression<DynamoNotificationTopic>();
query.withConsistentRead(true);
query.withHashKeyValues(hashKey);
if (!includeDeleted) {
query.withQueryFilterEntry("deleted", new Condition().withComparisonOperator(ComparisonOperator.NE).withAttributeValueList(new AttributeValue().withN("1")));
}
QueryResultPage<DynamoNotificationTopic> resultPage = mapper.queryPage(DynamoNotificationTopic.class, query);
List<DynamoNotificationTopic> topicList = resultPage.getResults();
// Load criteria.
topicList.forEach(this::loadCriteria);
return ImmutableList.copyOf(topicList);
}
Aggregations