@Test void testCopyAlgorithms() { EntityMapping sourceEntityMapping = mock(EntityMapping.class); AttributeMapping attributeMapping = mock(AttributeMapping.class); when(attributeMapping.getIdentifier()).thenReturn("MyIdentifier"); when(attributeMapping.getAlgorithmState()).thenReturn(AlgorithmState.CURATED); when(sourceEntityMapping.getAttributeMappings()) .thenReturn(Collections.singletonList(attributeMapping)); EntityMapping targetEntityMapping = mock(EntityMapping.class); algorithmServiceImpl.copyAlgorithms(sourceEntityMapping, targetEntityMapping); ArgumentCaptor<AttributeMapping> attributeMappingCaptor = ArgumentCaptor.forClass(AttributeMapping.class); verify(targetEntityMapping).addAttributeMapping(attributeMappingCaptor.capture()); AttributeMapping attributeMappingCopy = attributeMappingCaptor.getValue(); assertNull(attributeMappingCopy.getIdentifier()); assertEquals(DISCUSS, attributeMappingCopy.getAlgorithmState()); }
@Override public void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping) { sourceEntityMapping .getAttributeMappings() .forEach(attributeMapping -> copyAlgorithm(attributeMapping, targetEntityMapping)); }
AlgorithmServiceImpl implements AlgorithmService { @Override public void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping) { sourceEntityMapping .getAttributeMappings() .forEach(attributeMapping -> copyAlgorithm(attributeMapping, targetEntityMapping)); } }
AlgorithmServiceImpl implements AlgorithmService { @Override public void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping) { sourceEntityMapping .getAttributeMappings() .forEach(attributeMapping -> copyAlgorithm(attributeMapping, targetEntityMapping)); } AlgorithmServiceImpl(
      SemanticSearchService semanticSearchService,
      AlgorithmGeneratorService algorithmGeneratorService,
      EntityManager entityManager,
      JsMagmaScriptEvaluator jsMagmaScriptEvaluator); }
AlgorithmServiceImpl implements AlgorithmService { @Override public void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping) { sourceEntityMapping .getAttributeMappings() .forEach(attributeMapping -> copyAlgorithm(attributeMapping, targetEntityMapping)); } AlgorithmServiceImpl(
      SemanticSearchService semanticSearchService,
      AlgorithmGeneratorService algorithmGeneratorService,
      EntityManager entityManager,
      JsMagmaScriptEvaluator jsMagmaScriptEvaluator); @Override String generateAlgorithm(
      Attribute targetAttribute,
      EntityType targetEntityType,
      List<Attribute> sourceAttributes,
      EntityType sourceEntityType); @Override void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping); @Override @RunAsSystem void autoGenerateAlgorithm(
      EntityType sourceEntityType, EntityType targetEntityType, EntityMapping mapping); @Override Iterable<AlgorithmEvaluation> applyAlgorithm(
      Attribute targetAttribute, String algorithm, Iterable<Entity> sourceEntities, int depth); @Override Object apply(AttributeMapping attributeMapping, Entity sourceEntity, int depth); @Override Collection<String> getSourceAttributeNames(String algorithmScript); }
AlgorithmServiceImpl implements AlgorithmService { @Override public void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping) { sourceEntityMapping .getAttributeMappings() .forEach(attributeMapping -> copyAlgorithm(attributeMapping, targetEntityMapping)); } AlgorithmServiceImpl(
      SemanticSearchService semanticSearchService,
      AlgorithmGeneratorService algorithmGeneratorService,
      EntityManager entityManager,
      JsMagmaScriptEvaluator jsMagmaScriptEvaluator); @Override String generateAlgorithm(
      Attribute targetAttribute,
      EntityType targetEntityType,
      List<Attribute> sourceAttributes,
      EntityType sourceEntityType); @Override void copyAlgorithms(EntityMapping sourceEntityMapping, EntityMapping targetEntityMapping); @Override @RunAsSystem void autoGenerateAlgorithm(
      EntityType sourceEntityType, EntityType targetEntityType, EntityMapping mapping); @Override Iterable<AlgorithmEvaluation> applyAlgorithm(
      Attribute targetAttribute, String algorithm, Iterable<Entity> sourceEntities, int depth); @Override Object apply(AttributeMapping attributeMapping, Entity sourceEntity, int depth); @Override Collection<String> getSourceAttributeNames(String algorithmScript);  }