use of org.sagebionetworks.bridge.cache.ViewCache in project BridgeServer2 by Sage-Bionetworks.
the class SpringConfig method genericViewCache.
@Bean(name = "genericViewCache")
@Autowired
public ViewCache genericViewCache(CacheProvider cacheProvider) {
ViewCache cache = new ViewCache();
cache.setCacheProvider(cacheProvider);
cache.setObjectMapper(BridgeObjectMapper.get());
cache.setCachePeriod(BridgeConstants.BRIDGE_VIEW_EXPIRE_IN_SECONDS);
return cache;
}
use of org.sagebionetworks.bridge.cache.ViewCache in project BridgeServer2 by Sage-Bionetworks.
the class TagControllerTest method getTagsNotCached.
@Test
public void getTagsNotCached() throws Exception {
when(mockViewCache.getView(eq(CacheKey.tagList()), any())).thenReturn(null);
CacheProvider mockProvider = mock(CacheProvider.class);
ViewCache viewCache = new ViewCache();
viewCache.setCacheProvider(mockProvider);
viewCache.setObjectMapper(BridgeObjectMapper.get());
controller.setViewCache(viewCache);
Map<String, List<String>> map = ImmutableMap.of("a", ImmutableList.of("1", "2", "3"));
when(mockService.getTags()).thenReturn(map);
String retValue = controller.getTags();
assertEquals(retValue, JSON);
}
use of org.sagebionetworks.bridge.cache.ViewCache in project BridgeServer2 by Sage-Bionetworks.
the class UserProfileControllerTest method before.
@BeforeMethod
public void before() {
MockitoAnnotations.initMocks(this);
app = new DynamoApp();
app.setIdentifier(TEST_APP_ID);
app.setDataGroups(USER_DATA_GROUPS);
app.setUserProfileAttributes(TEST_STUDY_ATTRIBUTES);
when(mockConsentService.getConsentStatuses(any())).thenReturn(CONSENT_STATUSES_MAP);
when(mockAppService.getApp((String) any())).thenReturn(app);
ViewCache viewCache = new ViewCache();
viewCache.setCachePeriod(BRIDGE_VIEW_EXPIRE_IN_SECONDS);
viewCache.setObjectMapper(BridgeObjectMapper.get());
viewCache.setCacheProvider(mockCacheProvider);
controller.setViewCache(viewCache);
SessionUpdateService sessionUpdateService = new SessionUpdateService();
sessionUpdateService.setCacheProvider(mockCacheProvider);
sessionUpdateService.setConsentService(mockConsentService);
sessionUpdateService.setNotificationTopicService(mockNotificationTopicService);
controller.setSessionUpdateService(sessionUpdateService);
session = new UserSession(new StudyParticipant.Builder().withHealthCode(HEALTH_CODE).withId(TEST_USER_ID).build());
session.setAppId(TEST_APP_ID);
doReturn(session).when(controller).getAuthenticatedSession();
doReturn(mockRequest).when(controller).request();
doReturn(mockResponse).when(controller).response();
}
use of org.sagebionetworks.bridge.cache.ViewCache in project BridgeServer2 by Sage-Bionetworks.
the class ApplicationControllerTest method before.
@BeforeMethod
public void before() {
MockitoAnnotations.initMocks(this);
ViewCache viewCache = new ViewCache();
viewCache.setCachePeriod(BridgeConstants.APP_LINKS_EXPIRE_IN_SECONDS);
viewCache.setObjectMapper(new ObjectMapper());
viewCache.setCacheProvider(cacheProvider);
controller.setViewCache(viewCache);
app = App.create();
app.setIdentifier(TEST_APP_ID);
app.setName("<Test App>");
app.setSupportEmail("support@email.com");
app.setPasswordPolicy(PasswordPolicy.DEFAULT_PASSWORD_POLICY);
doReturn(app).when(appService).getApp(TEST_APP_ID);
}
use of org.sagebionetworks.bridge.cache.ViewCache in project BridgeServer2 by Sage-Bionetworks.
the class SpringConfig method appLinkViewCache.
@Bean(name = "appLinkViewCache")
@Autowired
public ViewCache appLinkViewCache(CacheProvider cacheProvider) {
ViewCache cache = new ViewCache();
cache.setCacheProvider(cacheProvider);
cache.setObjectMapper(new ObjectMapper());
cache.setCachePeriod(BridgeConstants.APP_LINKS_EXPIRE_IN_SECONDS);
return cache;
}
Aggregations