@Test void testApplyMappingToEntity() { EntityMapping entityMapping = mock(EntityMapping.class); Entity sourceEntity = mock(Entity.class); EntityType targetMetaData = mock(EntityType.class); Entity mappedEntity = mock(Entity.class); when(entityManager.create(targetMetaData, EntityManager.CreationMode.POPULATE)) .thenReturn(mappedEntity); assertEquals( mappedEntity, mappingService.applyMappingToEntity(entityMapping, sourceEntity, targetMetaData, 3)); }
Entity applyMappingToEntity( EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData, int depth) { Entity target = entityManager.create(targetMetaData, POPULATE); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping .getAttributeMappings() .forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, depth)); return target; }
MappingServiceImpl implements MappingService { Entity applyMappingToEntity( EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData, int depth) { Entity target = entityManager.create(targetMetaData, POPULATE); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping .getAttributeMappings() .forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, depth)); return target; } }
MappingServiceImpl implements MappingService { Entity applyMappingToEntity( EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData, int depth) { Entity target = entityManager.create(targetMetaData, POPULATE); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping .getAttributeMappings() .forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, depth)); return target; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); }
MappingServiceImpl implements MappingService { Entity applyMappingToEntity( EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData, int depth) { Entity target = entityManager.create(targetMetaData, POPULATE); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping .getAttributeMappings() .forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, depth)); return target; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); @Override @Transactional MappingProject addMappingProject(String projectName, String target, int depth); @Override @Transactional void deleteMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(
      String mappingProjectId, String clonedMappingProjectName); @Override List<MappingProject> getAllMappingProjects(); @Override @Transactional void updateMappingProject(MappingProject mappingProject); @Override MappingProject getMappingProject(String identifier); @Override @Transactional long applyMappings(
      String mappingProjectId,
      String entityTypeId,
      Boolean addSourceAttribute,
      String packageId,
      String label,
      Progress progress); Stream<EntityType> getCompatibleEntityTypes(EntityType target); }
MappingServiceImpl implements MappingService { Entity applyMappingToEntity( EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData, int depth) { Entity target = entityManager.create(targetMetaData, POPULATE); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping .getAttributeMappings() .forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, depth)); return target; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); @Override @Transactional MappingProject addMappingProject(String projectName, String target, int depth); @Override @Transactional void deleteMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(
      String mappingProjectId, String clonedMappingProjectName); @Override List<MappingProject> getAllMappingProjects(); @Override @Transactional void updateMappingProject(MappingProject mappingProject); @Override MappingProject getMappingProject(String identifier); @Override @Transactional long applyMappings(
      String mappingProjectId,
      String entityTypeId,
      Boolean addSourceAttribute,
      String packageId,
      String label,
      Progress progress); Stream<EntityType> getCompatibleEntityTypes(EntityType target); static final int MAPPING_BATCH_SIZE; }