use of org.sagebionetworks.bridge.services.HealthDataService in project BridgeServer2 by Sage-Bionetworks.
the class UploadValidationTaskFactoryTest method test.
@Test
public void test() {
// test dao and handlers
List<UploadValidationHandler> handlerList = Collections.emptyList();
UploadDao dao = mock(UploadDao.class);
FileHelper fileHelper = new FileHelper();
HealthDataService healthDataService = new HealthDataService();
// set up task factory
UploadValidationTaskFactory taskFactory = new UploadValidationTaskFactory();
taskFactory.setFileHelper(fileHelper);
taskFactory.setHandlerList(handlerList);
taskFactory.setUploadDao(dao);
taskFactory.setHealthDataService(healthDataService);
// inputs
App app = TestUtils.getValidApp(UploadValidationTaskFactoryTest.class);
Upload upload = Upload.create();
upload.setHealthCode(HEALTH_CODE);
// execute and validate
UploadValidationTask task = taskFactory.newTask(app.getIdentifier(), upload);
assertEquals(task.getContext().getHealthCode(), HEALTH_CODE);
assertSame(task.getContext().getAppId(), app.getIdentifier());
assertSame(task.getContext().getUpload(), upload);
assertSame(task.getFileHelper(), fileHelper);
assertSame(task.getHandlerList(), handlerList);
assertSame(task.getUploadDao(), dao);
assertSame(task.getHealthDataService(), healthDataService);
}
use of org.sagebionetworks.bridge.services.HealthDataService in project BridgeServer2 by Sage-Bionetworks.
the class UploadValidationTaskTest method setup.
@BeforeMethod
public void setup() throws IOException {
// Mock health data service
HealthDataRecord testRecord = makeRecordWithId(RECORD_ID);
HealthDataService healthDataService = mock(HealthDataService.class);
when(healthDataService.getRecordById(eq(RECORD_ID))).thenReturn(testRecord);
// Set up context
App app = TestUtils.getValidApp(UploadValidationTaskTest.class);
upload = Upload.create();
upload.setUploadId("test-upload");
ctx = new UploadValidationContext();
ctx.setAppId(app.getIdentifier());
ctx.setUpload(upload);
// Set up other pre-reqs
inMemoryFileHelper = new InMemoryFileHelper();
mockDao = mock(UploadDao.class);
// Set up task. Spy so we can verify some calls.
task = spy(new UploadValidationTask(ctx));
task.setFileHelper(inMemoryFileHelper);
task.setHandlerList(handlerList);
task.setHealthDataService(healthDataService);
task.setUploadDao(mockDao);
}
Aggregations