@Test public void testGetRoutingRule() throws Exception { RoutingRule ruleA = mockRule("rule-a"); Repository repository = createRepository("repo-a", "rule-a"); assertThat(routingRuleCache.getRoutingRule(repository), is(ruleA)); verify(store, times(1)).getById("rule-a"); routingRuleCache.getRoutingRule(repository); verify(store, times(1)).getById("rule-a"); assertThat(routingRuleCache.getRoutingRule(createRepository("repo-b", "rule-a")), is(ruleA)); verify(store, times(1)).getById("rule-a"); RoutingRule ruleC = mockRule("rule-c"); assertThat(routingRuleCache.getRoutingRule(createRepository("repo-c", "rule-c")), is(ruleC)); verify(store, times(1)).getById("rule-c"); }
@Nullable public RoutingRule getRoutingRule(final Repository repository) { try { return repositoryAssignedCache.get(repository).map(this::getRoutingRule).orElse(null); } catch (ExecutionException e) { log.error("An error occurred retrieving the routing rule for repository: {}", repository.getName(), e); return null; } }
RoutingRuleCache extends ComponentSupport implements EventAware { @Nullable public RoutingRule getRoutingRule(final Repository repository) { try { return repositoryAssignedCache.get(repository).map(this::getRoutingRule).orElse(null); } catch (ExecutionException e) { log.error("An error occurred retrieving the routing rule for repository: {}", repository.getName(), e); return null; } } }
RoutingRuleCache extends ComponentSupport implements EventAware { @Nullable public RoutingRule getRoutingRule(final Repository repository) { try { return repositoryAssignedCache.get(repository).map(this::getRoutingRule).orElse(null); } catch (ExecutionException e) { log.error("An error occurred retrieving the routing rule for repository: {}", repository.getName(), e); return null; } } @Inject  RoutingRuleCache(final RoutingRuleStore routingRuleStore); }
RoutingRuleCache extends ComponentSupport implements EventAware { @Nullable public RoutingRule getRoutingRule(final Repository repository) { try { return repositoryAssignedCache.get(repository).map(this::getRoutingRule).orElse(null); } catch (ExecutionException e) { log.error("An error occurred retrieving the routing rule for repository: {}", repository.getName(), e); return null; } } @Inject  RoutingRuleCache(final RoutingRuleStore routingRuleStore); @Nullable RoutingRule getRoutingRule(final Repository repository); @Nullable EntityId getRoutingRuleId(final Repository repository); @AllowConcurrentEvents @Subscribe void handle(final RepositoryDeletedEvent event); @AllowConcurrentEvents @Subscribe void handle(final RepositoryUpdatedEvent event); @AllowConcurrentEvents @Subscribe void handle(final RoutingRuleInvalidatedEvent event); }
RoutingRuleCache extends ComponentSupport implements EventAware { @Nullable public RoutingRule getRoutingRule(final Repository repository) { try { return repositoryAssignedCache.get(repository).map(this::getRoutingRule).orElse(null); } catch (ExecutionException e) { log.error("An error occurred retrieving the routing rule for repository: {}", repository.getName(), e); return null; } } @Inject  RoutingRuleCache(final RoutingRuleStore routingRuleStore); @Nullable RoutingRule getRoutingRule(final Repository repository); @Nullable EntityId getRoutingRuleId(final Repository repository); @AllowConcurrentEvents @Subscribe void handle(final RepositoryDeletedEvent event); @AllowConcurrentEvents @Subscribe void handle(final RepositoryUpdatedEvent event); @AllowConcurrentEvents @Subscribe void handle(final RoutingRuleInvalidatedEvent event);  }