@Test public void init_test_empty_domains() { when(applicationRepository.findAll()).thenReturn(Single.just(Collections.emptyList())); when(certificateRepository.findAll()).thenReturn(Single.just(Collections.emptySet())); when(domainRepository.findAll()).thenReturn(Single.just(Collections.emptySet())); syncManager.refresh(); verify(securityDomainManager, never()).deploy(any(Domain.class)); verify(securityDomainManager, never()).update(any(Domain.class)); verify(securityDomainManager, never()).undeploy(any(String.class)); }
public void refresh() { logger.debug("Refreshing sync state..."); long nextLastRefreshAt = System.currentTimeMillis(); try { if (lastRefreshAt == -1) { logger.debug("Initial synchronization"); deployDomains(); deployClients(); deployCertificates(); } else { logger.debug("Events synchronization"); List<Event> events = eventRepository.findByTimeFrame(lastRefreshAt - lastDelay, nextLastRefreshAt).blockingGet(); if (events != null && !events.isEmpty()) { Map<AbstractMap.SimpleEntry, Event> sortedEvents = events .stream() .collect( toMap( event -> new AbstractMap.SimpleEntry<>(event.getType(), event.getPayload().getId()), event -> event, BinaryOperator.maxBy(comparing(Event::getCreatedAt)), LinkedHashMap::new)); computeEvents(sortedEvents.values()); } } lastRefreshAt = nextLastRefreshAt; lastDelay = System.currentTimeMillis() - nextLastRefreshAt; } catch (Exception ex) { logger.error("An error occurs while synchronizing the security domains", ex); } }
SyncManager implements InitializingBean { public void refresh() { logger.debug("Refreshing sync state..."); long nextLastRefreshAt = System.currentTimeMillis(); try { if (lastRefreshAt == -1) { logger.debug("Initial synchronization"); deployDomains(); deployClients(); deployCertificates(); } else { logger.debug("Events synchronization"); List<Event> events = eventRepository.findByTimeFrame(lastRefreshAt - lastDelay, nextLastRefreshAt).blockingGet(); if (events != null && !events.isEmpty()) { Map<AbstractMap.SimpleEntry, Event> sortedEvents = events .stream() .collect( toMap( event -> new AbstractMap.SimpleEntry<>(event.getType(), event.getPayload().getId()), event -> event, BinaryOperator.maxBy(comparing(Event::getCreatedAt)), LinkedHashMap::new)); computeEvents(sortedEvents.values()); } } lastRefreshAt = nextLastRefreshAt; lastDelay = System.currentTimeMillis() - nextLastRefreshAt; } catch (Exception ex) { logger.error("An error occurs while synchronizing the security domains", ex); } } }
SyncManager implements InitializingBean { public void refresh() { logger.debug("Refreshing sync state..."); long nextLastRefreshAt = System.currentTimeMillis(); try { if (lastRefreshAt == -1) { logger.debug("Initial synchronization"); deployDomains(); deployClients(); deployCertificates(); } else { logger.debug("Events synchronization"); List<Event> events = eventRepository.findByTimeFrame(lastRefreshAt - lastDelay, nextLastRefreshAt).blockingGet(); if (events != null && !events.isEmpty()) { Map<AbstractMap.SimpleEntry, Event> sortedEvents = events .stream() .collect( toMap( event -> new AbstractMap.SimpleEntry<>(event.getType(), event.getPayload().getId()), event -> event, BinaryOperator.maxBy(comparing(Event::getCreatedAt)), LinkedHashMap::new)); computeEvents(sortedEvents.values()); } } lastRefreshAt = nextLastRefreshAt; lastDelay = System.currentTimeMillis() - nextLastRefreshAt; } catch (Exception ex) { logger.error("An error occurs while synchronizing the security domains", ex); } }  }
SyncManager implements InitializingBean { public void refresh() { logger.debug("Refreshing sync state..."); long nextLastRefreshAt = System.currentTimeMillis(); try { if (lastRefreshAt == -1) { logger.debug("Initial synchronization"); deployDomains(); deployClients(); deployCertificates(); } else { logger.debug("Events synchronization"); List<Event> events = eventRepository.findByTimeFrame(lastRefreshAt - lastDelay, nextLastRefreshAt).blockingGet(); if (events != null && !events.isEmpty()) { Map<AbstractMap.SimpleEntry, Event> sortedEvents = events .stream() .collect( toMap( event -> new AbstractMap.SimpleEntry<>(event.getType(), event.getPayload().getId()), event -> event, BinaryOperator.maxBy(comparing(Event::getCreatedAt)), LinkedHashMap::new)); computeEvents(sortedEvents.values()); } } lastRefreshAt = nextLastRefreshAt; lastDelay = System.currentTimeMillis() - nextLastRefreshAt; } catch (Exception ex) { logger.error("An error occurs while synchronizing the security domains", ex); } }  @Override void afterPropertiesSet(); void refresh(); }
SyncManager implements InitializingBean { public void refresh() { logger.debug("Refreshing sync state..."); long nextLastRefreshAt = System.currentTimeMillis(); try { if (lastRefreshAt == -1) { logger.debug("Initial synchronization"); deployDomains(); deployClients(); deployCertificates(); } else { logger.debug("Events synchronization"); List<Event> events = eventRepository.findByTimeFrame(lastRefreshAt - lastDelay, nextLastRefreshAt).blockingGet(); if (events != null && !events.isEmpty()) { Map<AbstractMap.SimpleEntry, Event> sortedEvents = events .stream() .collect( toMap( event -> new AbstractMap.SimpleEntry<>(event.getType(), event.getPayload().getId()), event -> event, BinaryOperator.maxBy(comparing(Event::getCreatedAt)), LinkedHashMap::new)); computeEvents(sortedEvents.values()); } } lastRefreshAt = nextLastRefreshAt; lastDelay = System.currentTimeMillis() - nextLastRefreshAt; } catch (Exception ex) { logger.error("An error occurs while synchronizing the security domains", ex); } }  @Override void afterPropertiesSet(); void refresh();  }