@Test public void testLookupMorphBaseDefinitions() { String def1Id = "def1"; String def2Id = "def2"; String def3Id = "def3"; String def4Id = "def4"; String morphBase1 = "morphBase1"; String morphBase2 = "morphBase2"; Object def1 = mock(Object.class); Object def2 = mock(Object.class); Object def3 = mock(Object.class); Object def4 = mock(Object.class); MorphDefinition morphDefinition1 = mock(MorphDefinition.class); MorphDefinition morphDefinition2 = mock(MorphDefinition.class); MorphDefinition morphDefinition3 = mock(MorphDefinition.class); when(definitionsRegistry.getDefinitionById(eq(def1Id))).thenReturn(def1); when(definitionsRegistry.getDefinitionById(eq(def2Id))).thenReturn(def2); when(definitionsRegistry.getDefinitionById(eq(def3Id))).thenReturn(def3); when(definitionsRegistry.getDefinitionById(eq(def4Id))).thenReturn(def4); when(definitionUtils.getMorphDefinition(eq(def1))).thenReturn(morphDefinition1); when(definitionUtils.getMorphDefinition(eq(def2))).thenReturn(morphDefinition2); when(definitionUtils.getMorphDefinition(eq(def3))).thenReturn(morphDefinition3); when(morphDefinition1.getDefault()).thenReturn(morphBase1); when(morphDefinition2.getDefault()).thenReturn(morphBase2); when(morphDefinition3.getDefault()).thenReturn(morphBase2); Set<String> result = tested.lookupMorphBaseDefinitions(new HashSet<String>(3) {{ add(def1Id); add(def2Id); add(def3Id); add(def4Id); }}); assertTrue(result.contains(morphBase1)); assertTrue(result.contains(morphBase2)); assertTrue(result.contains(def4Id)); }
public Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds) { final Set<String> result = new LinkedHashSet<>(); for (final String definitionId : definitionIds) { final Object definition = definitionsRegistry.getDefinitionById(definitionId); final MorphDefinition morphDefinition = definitionUtils.getMorphDefinition(definition); final boolean hasMorphBase = null != morphDefinition; final String id = hasMorphBase ? morphDefinition.getDefault() : definitionId; result.add(id); } return result; }
CommonDomainLookups { public Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds) { final Set<String> result = new LinkedHashSet<>(); for (final String definitionId : definitionIds) { final Object definition = definitionsRegistry.getDefinitionById(definitionId); final MorphDefinition morphDefinition = definitionUtils.getMorphDefinition(definition); final boolean hasMorphBase = null != morphDefinition; final String id = hasMorphBase ? morphDefinition.getDefault() : definitionId; result.add(id); } return result; } }
CommonDomainLookups { public Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds) { final Set<String> result = new LinkedHashSet<>(); for (final String definitionId : definitionIds) { final Object definition = definitionsRegistry.getDefinitionById(definitionId); final MorphDefinition morphDefinition = definitionUtils.getMorphDefinition(definition); final boolean hasMorphBase = null != morphDefinition; final String id = hasMorphBase ? morphDefinition.getDefault() : definitionId; result.add(id); } return result; } @Inject  CommonDomainLookups(final DefinitionUtils definitionUtils,
                               final DefinitionsCacheRegistry definitionsRegistry,
                               final RuleManager ruleManager);   CommonDomainLookups(final DefinitionUtils definitionUtils,
                        final DefinitionsCacheRegistry definitionsRegistry,
                        final RuleManager ruleManager,
                        final Function<String, DomainLookupsCache> cacheBuilder); }
CommonDomainLookups { public Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds) { final Set<String> result = new LinkedHashSet<>(); for (final String definitionId : definitionIds) { final Object definition = definitionsRegistry.getDefinitionById(definitionId); final MorphDefinition morphDefinition = definitionUtils.getMorphDefinition(definition); final boolean hasMorphBase = null != morphDefinition; final String id = hasMorphBase ? morphDefinition.getDefault() : definitionId; result.add(id); } return result; } @Inject  CommonDomainLookups(final DefinitionUtils definitionUtils,
                               final DefinitionsCacheRegistry definitionsRegistry,
                               final RuleManager ruleManager);   CommonDomainLookups(final DefinitionUtils definitionUtils,
                        final DefinitionsCacheRegistry definitionsRegistry,
                        final RuleManager ruleManager,
                        final Function<String, DomainLookupsCache> cacheBuilder); CommonDomainLookups setDomain(final String defSetId); Set<String> lookupTargetConnectors(final Node<? extends Definition<Object>, ? extends Edge> sourceNode); Set<String> lookupTargetNodes(final Graph<?, ? extends Node> graph,
                                         final Node<? extends Definition<Object>, ? extends Edge> sourceNode,
                                         final String edgeId); Set<String> lookupTargetNodes(final Graph<?, ? extends Node> graph,
                                         final Node<? extends Definition<Object>, ? extends Edge> sourceNode,
                                         final String edgeId,
                                         final Predicate<String> definitionIdsAllowedFilter); Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds); @PreDestroy void destroy(); }
CommonDomainLookups { public Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds) { final Set<String> result = new LinkedHashSet<>(); for (final String definitionId : definitionIds) { final Object definition = definitionsRegistry.getDefinitionById(definitionId); final MorphDefinition morphDefinition = definitionUtils.getMorphDefinition(definition); final boolean hasMorphBase = null != morphDefinition; final String id = hasMorphBase ? morphDefinition.getDefault() : definitionId; result.add(id); } return result; } @Inject  CommonDomainLookups(final DefinitionUtils definitionUtils,
                               final DefinitionsCacheRegistry definitionsRegistry,
                               final RuleManager ruleManager);   CommonDomainLookups(final DefinitionUtils definitionUtils,
                        final DefinitionsCacheRegistry definitionsRegistry,
                        final RuleManager ruleManager,
                        final Function<String, DomainLookupsCache> cacheBuilder); CommonDomainLookups setDomain(final String defSetId); Set<String> lookupTargetConnectors(final Node<? extends Definition<Object>, ? extends Edge> sourceNode); Set<String> lookupTargetNodes(final Graph<?, ? extends Node> graph,
                                         final Node<? extends Definition<Object>, ? extends Edge> sourceNode,
                                         final String edgeId); Set<String> lookupTargetNodes(final Graph<?, ? extends Node> graph,
                                         final Node<? extends Definition<Object>, ? extends Edge> sourceNode,
                                         final String edgeId,
                                         final Predicate<String> definitionIdsAllowedFilter); Set<String> lookupMorphBaseDefinitions(final Set<String> definitionIds); @PreDestroy void destroy();  }