Search in sources :

Example 1 with BridgeConfig

use of org.sagebionetworks.bridge.config.BridgeConfig in project BridgeServer2 by Sage-Bionetworks.

the class TestUtils method mockConfigResolver.

public static ConfigResolver mockConfigResolver(Environment env, String subdomain) {
    BridgeConfig mockConfig = Mockito.mock(BridgeConfig.class);
    when(mockConfig.getEnvironment()).thenReturn(env);
    when(mockConfig.getHostnameWithPostfix(subdomain)).thenReturn(subdomain + "-" + env.name().toLowerCase() + ".bridge.org");
    return new ConfigResolver(mockConfig);
}
Also used : ConfigResolver(org.sagebionetworks.bridge.models.appconfig.ConfigResolver) BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig)

Example 2 with BridgeConfig

use of org.sagebionetworks.bridge.config.BridgeConfig in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppDaoTest method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    MockitoAnnotations.initMocks(this);
    BridgeConfig config = mock(BridgeConfig.class);
    when(config.getPropertyAsList(APP_WHITELIST_PROPERTY)).thenReturn(ImmutableList.of("whitelisted-app"));
    dao.setBridgeConfig(config);
}
Also used : BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with BridgeConfig

use of org.sagebionetworks.bridge.config.BridgeConfig in project BridgeServer2 by Sage-Bionetworks.

the class DynamoFPHSExternalIdentifierDaoTest method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    MockitoAnnotations.initMocks(this);
    BridgeConfig bridgeConfig = mock(BridgeConfig.class);
    when(bridgeConfig.getInt(CONFIG_KEY_ADD_LIMIT)).thenReturn(5);
    dao.setConfig(bridgeConfig);
    // These have state and change; reset every test.
    externalId = new DynamoExternalIdentifier(TEST_APP_ID, EXT_ID_STRING1);
    fphsExternalId1 = new DynamoFPHSExternalIdentifier(EXT_ID_STRING1);
    fphsExternalId2 = new DynamoFPHSExternalIdentifier(EXT_ID_STRING2);
}
Also used : BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with BridgeConfig

use of org.sagebionetworks.bridge.config.BridgeConfig in project BridgeServer2 by Sage-Bionetworks.

the class Exporter3ServiceTest method before.

@BeforeMethod
public void before() {
    MockitoAnnotations.initMocks(this);
    // Mock config. This is done separately because we need to set mock config params.
    BridgeConfig mockConfig = mock(BridgeConfig.class);
    when(mockConfig.getInt(Exporter3Service.CONFIG_KEY_TEAM_BRIDGE_ADMIN)).thenReturn((int) BRIDGE_ADMIN_TEAM_ID);
    when(mockConfig.getInt(Exporter3Service.CONFIG_KEY_TEAM_BRIDGE_STAFF)).thenReturn((int) BRIDGE_STAFF_TEAM_ID);
    when(mockConfig.getInt(Exporter3Service.CONFIG_KEY_EXPORTER_SYNAPSE_ID)).thenReturn((int) EXPORTER_SYNAPSE_ID);
    when(mockConfig.getProperty(Exporter3Service.CONFIG_KEY_EXPORTER_SYNAPSE_USER)).thenReturn(EXPORTER_SYNAPSE_USER);
    when(mockConfig.getProperty(Exporter3Service.CONFIG_KEY_RAW_HEALTH_DATA_BUCKET)).thenReturn(RAW_HEALTH_DATA_BUCKET);
    when(mockConfig.getProperty(Exporter3Service.CONFIG_KEY_SYNAPSE_TRACKING_VIEW)).thenReturn(SYNAPSE_TRACKING_VIEW_ID);
    when(mockConfig.getProperty(BridgeConstants.CONFIG_KEY_WORKER_SQS_URL)).thenReturn(WORKER_QUEUE_URL);
    exporter3Service.setConfig(mockConfig);
    // Spy getNameScopingToken to make it easier to test.
    doReturn(NAME_SCOPING_TOKEN).when(exporter3Service).getNameScopingToken();
    // Mock app service. Override some app properties for ease of testing.
    app = TestUtils.getValidApp(Exporter3ServiceTest.class);
    app.setIdentifier(TestConstants.TEST_APP_ID);
    app.setName(APP_NAME);
    when(mockAppService.getApp(TestConstants.TEST_APP_ID)).thenReturn(app);
}
Also used : BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with BridgeConfig

use of org.sagebionetworks.bridge.config.BridgeConfig in project BridgeServer2 by Sage-Bionetworks.

the class StudyConsentServiceTest method before.

@BeforeMethod
public void before() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(CREATED_ON);
    MockitoAnnotations.initMocks(this);
    BridgeConfig config = mock(BridgeConfig.class);
    when(config.getConsentsBucket()).thenReturn(CONSENT_BUCKET);
    when(config.getHostnameWithPostfix("docs")).thenReturn(PUBLICATION_BUCKET);
    service.setBridgeConfig(config);
    StudyConsentValidator validator = new StudyConsentValidator();
    validator.setConsentBodyTemplate(new ByteArrayResource("<p>This is the template</p>".getBytes()));
    service.setValidator(validator);
}
Also used : StudyConsentValidator(org.sagebionetworks.bridge.validators.StudyConsentValidator) BridgeConfig(org.sagebionetworks.bridge.config.BridgeConfig) ByteArrayResource(org.springframework.core.io.ByteArrayResource) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BridgeConfig (org.sagebionetworks.bridge.config.BridgeConfig)12 BeforeMethod (org.testng.annotations.BeforeMethod)8 Test (org.testng.annotations.Test)3 AmazonSQSClient (com.amazonaws.services.sqs.AmazonSQSClient)2 SendMessageResult (com.amazonaws.services.sqs.model.SendMessageResult)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 AWSSessionCredentials (com.amazonaws.auth.AWSSessionCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 GeneratePresignedUrlRequest (com.amazonaws.services.s3.model.GeneratePresignedUrlRequest)1 AmazonSimpleEmailServiceClient (com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient)1 SetIdentityNotificationTopicRequest (com.amazonaws.services.simpleemail.model.SetIdentityNotificationTopicRequest)1 SetIdentityNotificationTopicResult (com.amazonaws.services.simpleemail.model.SetIdentityNotificationTopicResult)1 VerifyEmailIdentityResult (com.amazonaws.services.simpleemail.model.VerifyEmailIdentityResult)1 URL (java.net.URL)1 UploadDao (org.sagebionetworks.bridge.dao.UploadDao)1 UploadDedupeDao (org.sagebionetworks.bridge.dao.UploadDedupeDao)1 DateRange (org.sagebionetworks.bridge.models.DateRange)1 ConfigResolver (org.sagebionetworks.bridge.models.appconfig.ConfigResolver)1 UploadRequest (org.sagebionetworks.bridge.models.upload.UploadRequest)1 StudyConsentValidator (org.sagebionetworks.bridge.validators.StudyConsentValidator)1