@Test void testToEntityMappings() { Attribute targetAttribute = attrMetaFactory.create().setName("targetAttribute"); List<Attribute> sourceAttributes = Lists.newArrayList(); EntityType sourceEntityType = entityTypeFactory.create("source"); EntityType targetEntityType = entityTypeFactory.create("target"); targetEntityType.addAttribute(targetAttribute); List<AttributeMapping> attributeMappings = Lists.newArrayList(); attributeMappings.add( new AttributeMapping( "1", "targetAttribute", targetAttribute, "algorithm", sourceAttributes)); List<EntityMapping> entityMappings = singletonList( new EntityMapping(AUTO_ID, sourceEntityType, targetEntityType, attributeMappings)); Entity attributeMappingEntity = new DynamicEntity(attrMappingMeta); attributeMappingEntity.set(EntityMappingMetadata.IDENTIFIER, AUTO_ID); attributeMappingEntity.set(AttributeMappingMetadata.TARGET_ATTRIBUTE, "targetAttribute"); attributeMappingEntity.set(AttributeMappingMetadata.SOURCE_ATTRIBUTES, "sourceAttributes"); attributeMappingEntity.set(AttributeMappingMetadata.ALGORITHM, "algorithm"); List<Entity> attributeMappingEntities = Lists.newArrayList(); attributeMappingEntities.add(attributeMappingEntity); List<Entity> entityMappingEntities = Lists.newArrayList(); Entity entityMappingEntity = new DynamicEntity(entityMappingMeta); entityMappingEntity.set(EntityMappingMetadata.IDENTIFIER, AUTO_ID); entityMappingEntity.set(EntityMappingMetadata.TARGET_ENTITY_TYPE, "targetAttribute"); entityMappingEntity.set(EntityMappingMetadata.ATTRIBUTE_MAPPINGS, attributeMappingEntities); entityMappingEntities.add(entityMappingEntity); when(dataService.getEntityType( entityMappingEntity.getString(EntityMappingMetadata.TARGET_ENTITY_TYPE))) .thenReturn(targetEntityType); when(dataService.getEntityType( entityMappingEntity.getString(EntityMappingMetadata.SOURCE_ENTITY_TYPE))) .thenReturn(sourceEntityType); assertEquals(entityMappings, entityMappingRepository.toEntityMappings(entityMappingEntities)); }
@Override public List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities) { return Lists.transform(entityMappingEntities, this::toEntityMapping); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities) { return Lists.transform(entityMappingEntities, this::toEntityMapping); } }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities) { return Lists.transform(entityMappingEntities, this::toEntityMapping); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities) { return Lists.transform(entityMappingEntities, this::toEntityMapping); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); @Override List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities); @Override List<Entity> upsert(Collection<EntityMapping> entityMappings); }
EntityMappingRepositoryImpl implements EntityMappingRepository { @Override public List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities) { return Lists.transform(entityMappingEntities, this::toEntityMapping); } EntityMappingRepositoryImpl(AttributeMappingRepository attributeMappingRepository); @Override List<EntityMapping> toEntityMappings(List<Entity> entityMappingEntities); @Override List<Entity> upsert(Collection<EntityMapping> entityMappings);  }