use of org.sagebionetworks.bridge.models.HealthDataDocumentation in project BridgeServer2 by Sage-Bionetworks.
the class HealthDataDocumentationServiceTest method getHealthDataDocumentationForId.
@Test
public void getHealthDataDocumentationForId() {
HealthDataDocumentation doc = makeValidDoc();
when(mockDao.getDocumentationByIdentifier(TEST_APP_ID, IDENTIFIER)).thenReturn(doc);
HealthDataDocumentation result = service.getHealthDataDocumentationForId(TEST_APP_ID, IDENTIFIER);
assertSame(result, doc);
verify(mockDao).getDocumentationByIdentifier(TEST_APP_ID, IDENTIFIER);
}
use of org.sagebionetworks.bridge.models.HealthDataDocumentation in project BridgeServer2 by Sage-Bionetworks.
the class HealthDataDocumentationServiceTest method createOrUpdateHealthDataDocumentation.
@Test
public void createOrUpdateHealthDataDocumentation() {
RequestContext.set(new RequestContext.Builder().withCallerUserId(TEST_USER_ID).build());
HealthDataDocumentation doc = makeValidDoc();
when(mockDao.createOrUpdateDocumentation(doc)).thenReturn(doc);
HealthDataDocumentation result = service.createOrUpdateHealthDataDocumentation(doc);
assertSame(result, doc);
assertEquals(result.getModifiedBy(), TEST_USER_ID);
assertEquals(result.getModifiedOn(), MOCK_NOW_MILLIS);
verify(mockDao).createOrUpdateDocumentation(doc);
RequestContext.set(null);
}
use of org.sagebionetworks.bridge.models.HealthDataDocumentation in project BridgeServer2 by Sage-Bionetworks.
the class DynamoHealthDataDocumentationDao method getDocumentationForParentId.
/**
* {@inheritDoc}
*/
@Override
public ForwardCursorPagedResourceList<HealthDataDocumentation> getDocumentationForParentId(@Nonnull String parentId, int pageSize, String offsetKey) {
// Create hash key.
DynamoHealthDataDocumentation key = new DynamoHealthDataDocumentation();
key.setParentId(parentId);
int pageSizeWithIndicatorRecord = pageSize + 1;
// Create query.
DynamoDBQueryExpression<DynamoHealthDataDocumentation> query = new DynamoDBQueryExpression<DynamoHealthDataDocumentation>().withHashKeyValues(key).withLimit(pageSizeWithIndicatorRecord);
// Add offset key condition to query.
if (offsetKey != null) {
Condition condition = new Condition().withComparisonOperator(ComparisonOperator.GE).withAttributeValueList(new AttributeValue().withS(offsetKey));
query.withRangeKeyCondition("identifier", condition);
}
// Query.
List<DynamoHealthDataDocumentation> dynamoList = queryHelper(query);
List<HealthDataDocumentation> list = ImmutableList.copyOf(dynamoList);
list = list.size() <= pageSizeWithIndicatorRecord ? list : list.subList(0, pageSizeWithIndicatorRecord);
// Calculate nextOffsetKey, if present.
String nextOffsetKey = null;
if (list.size() == pageSizeWithIndicatorRecord) {
nextOffsetKey = Iterables.getLast(list).getIdentifier();
}
int limit = Math.min(list.size(), pageSize);
return new ForwardCursorPagedResourceList<>(list.subList(0, limit), nextOffsetKey);
}
use of org.sagebionetworks.bridge.models.HealthDataDocumentation in project BridgeServer2 by Sage-Bionetworks.
the class HealthDataDocumentationValidatorTest method nullDocumentation.
@Test
public void nullDocumentation() {
HealthDataDocumentation doc = makeValidHealthDataDocumentation();
doc.setDocumentation(null);
assertValidatorMessage(HealthDataDocumentationValidator.INSTANCE, doc, "documentation", "cannot be null");
}
use of org.sagebionetworks.bridge.models.HealthDataDocumentation in project BridgeServer2 by Sage-Bionetworks.
the class HealthDataDocumentationValidatorTest method emptyTitle.
@Test
public void emptyTitle() {
HealthDataDocumentation doc = makeValidHealthDataDocumentation();
doc.setTitle("");
assertValidatorMessage(HealthDataDocumentationValidator.INSTANCE, doc, "title", "cannot be an empty string");
}
Aggregations