Search in sources :

Example 6 with App

use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppDaoTest method updateAppConditionalCheckFailedException.

@Test(expectedExceptions = ConcurrentModificationException.class)
public void updateAppConditionalCheckFailedException() {
    doThrow(new ConditionalCheckFailedException("")).when(mockMapper).save(any());
    App app = App.create();
    app.setVersion(2L);
    dao.updateApp(app);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) ConditionalCheckFailedException(com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException) Test(org.testng.annotations.Test)

Example 7 with App

use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppDaoTest method createApp.

@Test
public void createApp() {
    App app = App.create();
    dao.createApp(app);
    verify(mockMapper).save(app);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) Test(org.testng.annotations.Test)

Example 8 with App

use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppDaoTest method deactivateApp.

@Test
public void deactivateApp() {
    App app = App.create();
    app.setActive(true);
    app.setVersion(2L);
    when(mockMapper.load(any())).thenReturn(app);
    dao.deactivateApp(TEST_APP_ID);
    verify(mockMapper).save(appCaptor.capture());
    assertFalse(appCaptor.getValue().isActive());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) Test(org.testng.annotations.Test)

Example 9 with App

use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppTest method automaticCustomEventsIsNeverNull.

@Test
public void automaticCustomEventsIsNeverNull() {
    // Starts as empty
    App app = App.create();
    assertTrue(app.getAutomaticCustomEvents().isEmpty());
    // Set value works
    Map<String, String> dummyMap = ImmutableMap.of("3-days-after-enrollment", "P3D");
    app.setAutomaticCustomEvents(dummyMap);
    assertEquals(app.getAutomaticCustomEvents(), dummyMap);
    // Set to null makes it empty again
    app.setAutomaticCustomEvents(null);
    assertTrue(app.getAutomaticCustomEvents().isEmpty());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) Test(org.testng.annotations.Test) OAuthProviderTest(org.sagebionetworks.bridge.models.apps.OAuthProviderTest)

Example 10 with App

use of org.sagebionetworks.bridge.models.apps.App in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppTest method activityEventKeysMergeIntoCustomEvents.

@SuppressWarnings("deprecation")
@Test
public void activityEventKeysMergeIntoCustomEvents() {
    App app = App.create();
    // key3 would be future_only, except that it is already set in custom
    // events, so that will be used in preference
    app.setActivityEventKeys(Sets.newHashSet("key1", "key2", "key3"));
    app.setCustomEvents(newHashMap(ImmutableMap.of("key3", MUTABLE, "key4", IMMUTABLE)));
    assertEquals(app.getCustomEvents().get("key1"), FUTURE_ONLY);
    assertEquals(app.getCustomEvents().get("key2"), FUTURE_ONLY);
    assertEquals(app.getCustomEvents().get("key3"), MUTABLE);
    assertEquals(app.getCustomEvents().get("key4"), IMMUTABLE);
    assertTrue(app.getActivityEventKeys().isEmpty());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) Test(org.testng.annotations.Test) OAuthProviderTest(org.sagebionetworks.bridge.models.apps.OAuthProviderTest)

Aggregations

App (org.sagebionetworks.bridge.models.apps.App)389 Test (org.testng.annotations.Test)213 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)103 DynamoApp (org.sagebionetworks.bridge.dynamodb.DynamoApp)81 PostMapping (org.springframework.web.bind.annotation.PostMapping)74 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)65 Account (org.sagebionetworks.bridge.models.accounts.Account)57 GetMapping (org.springframework.web.bind.annotation.GetMapping)36 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)29 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)28 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)25 RequestContext (org.sagebionetworks.bridge.RequestContext)23 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)23 SignIn (org.sagebionetworks.bridge.models.accounts.SignIn)22 DateTime (org.joda.time.DateTime)20 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)19 AccountId (org.sagebionetworks.bridge.models.accounts.AccountId)19 JsonNode (com.fasterxml.jackson.databind.JsonNode)18 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)17 AppAndUsers (org.sagebionetworks.bridge.models.apps.AppAndUsers)16