Search in sources :

Example 1 with HealthDataService

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);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) FileHelper(org.sagebionetworks.bridge.file.FileHelper) Upload(org.sagebionetworks.bridge.models.upload.Upload) HealthDataService(org.sagebionetworks.bridge.services.HealthDataService) UploadDao(org.sagebionetworks.bridge.dao.UploadDao) Test(org.testng.annotations.Test)

Example 2 with 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);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) InMemoryFileHelper(org.sagebionetworks.bridge.file.InMemoryFileHelper) HealthDataRecord(org.sagebionetworks.bridge.models.healthdata.HealthDataRecord) HealthDataService(org.sagebionetworks.bridge.services.HealthDataService) UploadDao(org.sagebionetworks.bridge.dao.UploadDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

UploadDao (org.sagebionetworks.bridge.dao.UploadDao)2 App (org.sagebionetworks.bridge.models.apps.App)2 HealthDataService (org.sagebionetworks.bridge.services.HealthDataService)2 FileHelper (org.sagebionetworks.bridge.file.FileHelper)1 InMemoryFileHelper (org.sagebionetworks.bridge.file.InMemoryFileHelper)1 HealthDataRecord (org.sagebionetworks.bridge.models.healthdata.HealthDataRecord)1 Upload (org.sagebionetworks.bridge.models.upload.Upload)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1